akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n,z,w;
	cin >> n >> z >> w;

	vector<ll> a(n+1);
	a[0] = w;
	rep(i,n) cin >> a[i+1];

	if(n==1){
		cout << abs(a[n] - w) << endl;
		return;
	}

	vector<ll> dp1(n,-1),dp2(n, MOD);
	dp1[n-1] = dp2[n-1] = abs(a[n] - a[n-1]);


	for(ll i = n-2; i >= 0; i--){
		for(ll j = i+1; j < n; j++){
			dp1[i] = max(dp1[i],dp2[j]);
			dp2[i] = min(dp2[i],dp1[j]);
		}
		dp1[i] = max(dp1[i], abs(a[n]-a[i]));
		dp2[i] = min(dp2[i], abs(a[n]-a[i]));
	}

	cout << dp1[0] << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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


int main(){
    int W, H, n, w = 0, h = 0;
    cin >> W >> H >> n;

    while(n--){
        int x, y, a;
        cin >> x >> y >> a;
        
        if(a == 1) w = max(w, x);
        if(a == 2) W = min(W, x);
        if(a == 3) h = max(h, y);
        if(a == 4) H = min(H, y);
    }
    cout << (w < W && h < H ? (W - w) * (H - h) : 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define re return
#define pb emplace_back
#define em emplace
#define er erase
#define all(x) (x).begin(), (x).end()
#define in(v); { for (auto &i : v) cin >> i; }
#define out(v); { for (auto &i : v) cout << i << ' '; cout << endl; }

#define int long long

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

const long long INFll = 1e18;



void solve() {
    int n, k; cin >> n >> k;
    vector <int> v(n); in(v);
    sort(all(v));

    if (k >= n) {
        cout << 0; return;
    }

    cout << accumulate(v.begin(), v.end() - k, 0ll);
}

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

    solve();
}


Measured memory_bytes: 1792
# AGC002C - Knot Puzzle
def main():
    N, L = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))
    B = [i + j for i, j in zip(A, A[1:])]
    x = max(B)
    if x >= L:
        idx = B.index(x) + 1
        ans = [i for i in range(1, idx)] 
        ans += [i for i in range(N - 1, idx, -1)] + [idx]
        print("Possible")
        print(*ans, sep="\n")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

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

string str,s1,s2;
int main(){
	cin>>str;
	s1="",s2="";
	int q,cnt=0;
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		if(t==1) cnt++;
		else {
			int f;char a;
			cin>>f>>a;
			if(f==1) {
				if(cnt%2) s2.insert(s2.end(),a);
				else s1.insert(s1.begin(),a);
			}
			else {
				if(cnt%2) s1.insert(s1.begin(),a);
				else s2.insert(s2.end(),a);
			}
		}
	}
	if(cnt%2){
		reverse(str.begin(),str.end());
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		cout<<s2<<str<<s1;
	}
	else cout<<s1<<str<<s2;
}

Measured memory_bytes: 1088
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<string>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*約数の個数(x含む)*/ll divi(ll x){ll i,ans=0;rep(i,2,x+1){if(x%i==0){ans++;}}return ans;}
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,degi;
 sc(n);
 string s = "";
 char c;
 while(n>0){
  degi=n%26;
  n/=26;
  if(degi){
   c=degi-1+'a';
   s=c+s;
  }
  else{
   s='z'+s;
   n--;
  }
 }
 pr(s);
return 0;}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
int n, a[135010];
struct node {
    int id, point;
} node[1<<18];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

Measured memory_bytes: 3172
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

using mat=std::vector<std::vector<ll>>;
 
mat Mul(mat a,mat b,ll mod){
  assert(a[0].size()==b.size());
 
  mat ret(a.size(),std::vector<ll>(b[0].size()));
 
  for(ll i=0;i<a.size();i++){
    for(ll j=0;j<b[0].size();j++){
      ll temp=0;
      for(ll k=0;k<a[0].size();k++){
        temp=(temp+a[i][k]*b[k][j])%mod;
      }
      ret[i][j]=temp;
    }
  }
 
  return ret;
}
 
//非再帰累乗(mod付き)
mat pow_mod(mat a, ll b, ll mod=-1) {
  ll n=a.size();
 
  mat x(n,std::vector<ll>(n,0));
 
  rep(i,0,n)x[i][i]=1;
 
  while (b > 0) {
    if (b & 1) {
      x = Mul(x,a,mod);
    }
    a =Mul(a,a,mod);
    b >>= 1;
  }
  return x;
}

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

  ll l,a,b,m;
  std::cin>>l>>a>>b>>m;
 
  mat ans(3,std::vector<ll>(1,0));
  ans[0][0]=0;ans[1][0]=a%m;ans[2][0]=1;
 
  std::vector<ll> c(19,0);
 
  rep(i,1,19){
    ll temp=(pow_mod(10,i)-a-1)/b;
    if(temp<0)c[i]=0;
    else if(temp<l) c[i]=temp+1;
    else c[i]=l;
  }
 
  rep(i,1,19){
    mat po(3,std::vector<ll>(3,0));
    po[0][0]=pow_mod(10,i,m);po[0][1]=1;
    po[1][1]=1;po[1][2]=b%m;
    po[2][2]=1;
 
    po=pow_mod(po,c[i]-c[i-1],m);
 
    ans=Mul(po,ans,m);
  }
 
  std::cout<<ans[0][0]<<"\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] pasta = {0,0,0};
		int[] juice = {0,0};
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < 3; i++){
			pasta[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++){
			juice[i] = sc.nextInt();
		}
		int min = pasta[0] + juice[0];
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 2; j++){
				if(min > pasta[i] + juice[j]) min = pasta[i] + juice[j];
			}
		}
		System.out.println(min - 50);
	}

}

Measured memory_bytes: 17164
from collections import defaultdict

N = int(input())
factors = defaultdict(int)
for n in range(2, N+1):
    for i in range(2,int(n**.5)+1):
        while n % i == 0:
            n //= i
            factors[i] += 1
    if n > 1:
        factors[n] += 1

ans = 1
for c in factors.values():
    ans *= c + 1
    ans %= 1000000007
print(ans)

Measured memory_bytes: 3444
/*
Till the roof comes off, till the lights go out
Till my legs give out, can’t shut my mouth.
Till the smoke clears out. Am I high? Perhaps
I'ma rip this shit till my bones collapse.
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <complex>


#define f first
#define s second
#define ll long long
#define sz(v)      ((int)((v).size()))
#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define len(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)

using namespace std;

typedef pair<int,ll>ii;
typedef pair<ii,int>node;
typedef complex<double>point;


const int N=2005;
const int M=101;
const double EPS = 1e-9;
const int INF =1e9;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
double getDist(point a,point b){return sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y));}
int dcmp(double x, double y) {return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;}

ll mod=1000000007;
ll power(ll base,int p){if(!p)return 1;ll ret=power(base,p/2);ret*=ret;ret%=mod;if(p&1)ret*=base,ret%=mod;return ret;}
ll modInverse(int a){return power(a,mod-2);}

int HistogramArea(vector<int>v){
  stack<int>st;
  int sol=0;
  int cur=0;
  while(cur<v.size()){
     if(st.size()&&v[st.top()]>v[cur]){
        int lft=st.top();
        st.pop();
        if(v[lft])
         sol=max(sol,(v[lft]*2-v[lft]+1)*(st.empty()?(cur*2-cur+1):((cur-st.top()-1)*2-(cur-st.top()-1)+1)));
     }
     else{
        st.push(cur++);
     }
  }
  while(st.size()){
      int lft=st.top();
      st.pop();
     if(v[lft])
      sol=max(sol,(v[lft]*2-v[lft]+1)*(st.empty()?(cur*2-cur+1):((cur-st.top()-1)*2-(cur-st.top()-1)+1)));
  }
  return sol;
}
int n,m,g[N][N];
string s[N];
bool kool(int a,int b){
  int sum=0;
  for(int i=0;i<2;i++){
    sum+=s[a][b+i]=='.';
    sum+=s[a+1][b+i]=='.';
  }
  if(sum&1)return 0;
  return 1;
}
int main()
{
    //freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
   memset(g,0,sizeof(g));
   scanf("%d%d",&n,&m);
   int sol=max(n,m);
   for(int i=0;i<n;i++)cin>>s[i];
   for(int i=0;i+1<n;i++){
    for(int j=0;j+1<m;j++){
            if(kool(i,j))g[i][j]=1;
    }
    vector<int>v;
    for(int j=0;j+1<m;j++){
        if(i>0&&g[i][j]==1)g[i][j]+=g[i-1][j];
        v.push_back(g[i][j]);
    }
    sol=max(sol,HistogramArea(v));//cout<<sol<<endl;
   }

   cout<<sol;
  return 0;
}

/*
100% reason to Remember THE NAME
*/


Measured memory_bytes: 21632
# https://drken1215.hatenablog.com/entry/2019/06/23/004700
# https://tjkendev.github.io/procon-library/python/union_find/union_find.html

def main():
    import sys
    input = sys.stdin.readline

    MX = 10 ** 5 + 10
    
    *p, = [r for r in range(MX * 2)]

    def root(x):
        if x == p[x]:
            return x
        p[x] = y = root(p[x])
        return y

    def unite(x, y):
        px = root(x)
        py = root(y)
        if px == py:
            return 0
        if px < py:
            p[py] = px
        else:
            p[px] = py
        return 1

    n = int(input())
    for _ in range(n):
        x, y = (int(x) - 1 for x in input().split())  # [1,)->[0,)
        unite(x, y + MX)

    xs = [0] * (MX * 2)
    ys = [0] * (MX * 2)

    for r in range(MX):
        xs[root(r)] += 1

    for r in range(MX, MX * 2):
        ys[root(r)] += 1

    ans = -n
    for r in range(MX * 2):
        ans += xs[r] * ys[r]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14076
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll s = 0;
    for (ll i = 0; i < N; i++) {
        s ^= a[i];
    }

    if (N == 3) {
        cout << (s == 0 ? "Yes" : "No") << endl;
    } else if (N % 3 == 0) {
        map<ll, ll> mp;
        for (ll i = 0; i < N; i++) {
            mp[a[i]]++;
        }
        bool ok = true;
        for (const auto& p : mp) {
            if (p.second % (N / 3) != 0) {
                ok = false;
                break;
            }
        }

        if (!ok) {
            cout << "No" << endl;
            return 0;
        }

        if (mp.size() == 1) {
            cout << (mp.begin()->first == 0 ? "Yes" : "No") << endl;
        } else {
            cout << (s == 0 ? "Yes" : "No") << endl;
        }
    } else {
        bool ok = true;
        for (ll i = 0; i < N; i++) {
            if (a[i] != 0) {
                ok = false;
                break;
            }
        }

        cout << (ok ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

int A, B;

int Judge(int n, vector<int> &d) {
	int i, b = B * n;
	for (i = 0; i < d.size(); i++) {
		if (d[i] <= b)
			break;
		n -= (d[i] - b) / A;
		if ((d[i] - b) % A > 0)
			n--;
		if (n < 0)
			return false;
	}
	return true;
}

int Search(int l, int r, vector<int> &d) {
	if (l == r)
		return l;
	int p = (l + r) >> 1;
	if (Judge(p, d))
		return Search(l, p, d);
	else
		return Search(p + 1, r, d);
}

int main(void) {
	int num, i, m;
	ll sum = 0;
	cin >> num >> A >> B;
	vector<int> d(num);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	sort(d.begin(), d.end(), greater<int>());
	A -= B;
	m = d[0] / B;
	if (d[0] % B > 0)
		m++;
	cout << Search(0, m, d) << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

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

    ll lc = lcm(c, d);
    ll x = b - (b / c + b / d - b / lc);
    ll y = a - 1 - ((a - 1) / c + (a - 1) / d - (a - 1) / lc);
    cout << x - y << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	PRI(a * b - a - b + 1);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s,t;
    cin >> s;
    cin >> t;
    int n = s.size();
    rep(i,n){
        int j;
        for(j=0;j<n;j++){
            if(s[(i+j)%n] != t[j]) break;
        }
        if(j==n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int d, t, s; std::cin >> d >> t >> s;
    std::cout << (s * t >= d ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  REPS(i, 1, N) { ans += i; }
  cout << ans << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  vector<ll> a(N+2);

  a[0] = 0;
  REP(i,N)cin >> a[i+1];
  a[N+1] = 0;

  ll sum=0;
  FOR(i,1,N+2){
    sum += abs(a[i]-a[i-1]);
  }

  FOR(i,1,N+1){
    cout << sum - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
  }


}



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

int main() {
  int X, N;
  cin >> X >> N;
  set<int> p;
  rep(i,N){
    int tmpP;
    cin >> tmpP;
    p.insert(tmpP);
  }

  if(p.size() == 0){
    cout << X << endl;
    return 0;
  }

  int minNum = -1;
  int minDiff = 9999999;
  for (int i = -1; i < 102; i++){
    if(p.count(i)){
      continue;
    }
    int diff = X - i;
    if (diff < 0) diff *= -1;

    if(diff < minDiff){
       minDiff = diff;
       minNum = i;
    }
    if(minDiff == diff && i < minNum){
       minNum = i;
    }
  }
  cout << minNum << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, s, n) for(int i = s; i < n; i++)
#define rRep(i, n) for(int i = n - 1; i >= 0; i--)

int32_t main() {
	FAST
	int r;
	cin >> r;
	cout << r*r << endl;	
}


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

const int MAXN = 100 + 5;

int N, Ans;
int A[MAXN << 1];

inline int read()
{
	register int x = 0;
	register char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch))
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}

int main()
{
	N = read() << 1;
	for(int i = 1; i <= N; ++i) A[i] = read();
	std::sort(A + 1, A + 1 + N);
	for(int i = 1; i <= N; i += 2) Ans += A[i];
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;


struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint fact(int n){
    if(n<=1) return 1;
    else return fact(n-1)*n;
}
mint combi(int n, int r){
    if(n<r) return 0;
    else return fact(n)/(fact(r)*fact(n-r));
}
mint fact2(int n){
    mint ans = 1;
    for(int i=1;i<=n;i++) ans *= i;
    return ans;
}
mint combi2(int n, int r){
    if(n<r) return 0;

    mint ans = 1;
    for(int i=0;i<r;i++) ans *= n-i;

    ans /= fact2(r);
    return ans;
}


int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    mint ans = 2;
    ans = ans.pow(n)-1;
    ans -= combi2(n,a);
    ans -= combi2(n,b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
package main

import "fmt"

func main() {
	var r, d, x int
	fmt.Scan(&r, &d, &x)
	arr := make([]int, 11)
	arr[0] = x
	for i := 1; i < 11; i++ {
		arr[i] = r * arr[i - 1] - d
		fmt.Println(arr[i])
	}
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int n;
int f[N + 1][3];
int a[N + 1];
int b[N + 1];
int c[N + 1];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n;
    FOR(i, 1, n)
        cin >> a[i] >> b[i] >> c[i];
    int res = 0;
    FOR(i, 1, n)
    {

        f[i][0] = max(f[i - 1][0], max(f[i - 1][1], f[i - 1][2]) + a[i]);
        f[i][1] = max(f[i - 1][1], max(f[i - 1][0], f[i - 1][2]) + b[i]);
        f[i][2] = max(f[i - 1][2], max(f[i - 1][1], f[i - 1][0]) + c[i]);
        res = max(res, max(f[i][0], max(f[i][1], f[i][2])));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
int wMax[2001][2001];
int hMax[2001][2001];

using namespace std;

int main(){
   int N,M;
   cin >> N >> M;
   int T = (N-M)*100 + M*1900;
   int p = 1<<M;
   cout << T*p << endl;
   return 0;
}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    char c;
    cin >> a >> c >> b;
    if(c == '+'){
        cout << a+b << endl;
    }
    else{
        cout << a-b << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

long max(long a, long b) {
	return (a > b) ? a : b;
}


int main() {
	int i, N, j;
	long A[100000];
	long B[100000][2];

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%ld", &A[i]);
	}

	B[0][0] = A[0];
	B[0][1] = -A[0];

	for (i = 1; i < N - 1; i++) {
		B[i][0] = max(B[i - 1][0] + A[i], B[i - 1][1] - A[i]);
		B[i][1] = max(B[i - 1][0] - A[i], B[i - 1][1] + A[i]);
	}

	printf("%ld\n", max(B[N - 2][0] + A[N - 1], B[N - 2][1] - A[N - 1]));
	
	return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(9);
    solve();
    return 0;
}
 
const int MOD = 998244353, MAXN = 3e5 + 10, INF = 1e18 + 10;

void solve() {
	string s;
	cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) {
 	    cout << "Yes" << endl;
 	}
 	else {
 	    cout << "No" << endl;
 	}	 	
}	

Measured memory_bytes: 256
N, K = map(int, input().split())
num = []

for i in range(N):
  cc = list(map(int, input().split()))
  num.append(cc)
  
num = sorted(num , key = lambda x : x[0])
  
for i in num:
  K -= i[1]
  if K <= 0:
    print(i[0])
    break
    

Measured memory_bytes: 29912
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
from collections import Counter
As = list(mapint())
count = Counter(As)
mod = 10**9+7
maxi = 0
cum = 0
pos = {}
neg = {}
pos[0] = 1
neg[0] = 1
As = sorted(list(set(As)))
for i in range(1, 10**5+5):
    pos[i] = pos[i-1]*i%mod
    neg[i] = pow(pos[i], mod-2, mod)
for a in As:
    cum += count[a]
    if cum<K:
        continue
    for i in range(1, min(K, count[a])+1):
        if cum-count[a]-K+i<0: continue
        maxi += a*pos[count[a]]*neg[i]*neg[count[a]-i]*pos[cum-count[a]]*neg[K-i]*neg[cum-count[a]-K+i]
        maxi %= mod
mini = 0
cum = 0
for a in As[::-1]:
    cum += count[a]
    if cum<K:
        continue
    for i in range(1, min(K, count[a])+1):
        if cum-count[a]-K+i<0: continue
        mini += a*pos[count[a]]*neg[i]*neg[count[a]-i]*pos[cum-count[a]]*neg[K-i]*neg[cum-count[a]-K+i]
        mini %= mod
print((maxi-mini)%mod)

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

int main()
{
  int N;
  string result;
  //int result;
  cin >> N;
  N = N % 10;

  if(N==2 || N==4 || N==5 || N==7 || N==9){
    result = "hon";
  }else if(N==0 || N==1 || N==6 || N==8){
    result = "pon";
  }else{
    result = "bon";
  }

  cout << result << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

template <typename E>
struct dual_segment_tree {
    using H = function<E(E, E)>;
    int n, height;
    H h;
    E ei;
    vector<E> lazy;
    dual_segment_tree(H h, E ei) : h(h), ei(ei) {}
    void init(int n_) {
        n = 1; height = 0;
        while (n < n_) n <<= 1, height++;
        lazy.assign(2*n, ei);
    }
    inline void propagete(int i) {
        if (lazy[i] == ei) return;
        lazy[i<<1|0] = h(lazy[i<<1|0], lazy[i]);
        lazy[i<<1|1] = h(lazy[i<<1|1], lazy[i]);
        lazy[i] = ei;
    }
    inline void thrust(int i) {
        for (int k = height; k >= 1; --k) propagete(i>>k);
    }
    void update(int a, int b, E x) {
        a += n; b += n;
        thrust(a);
        thrust(b-1);
        int l = a, r = b;
        while (l < r) {
            if (l & 1) lazy[l] = h(lazy[l], x), l++;
            if (r & 1) --r, lazy[r] = h(lazy[r], x);
            l >>= 1; r >>= 1;
        }
    }
    E get_val(int i) {
        i += n;
        thrust(i);
        return lazy[i];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, q;
    cin >> n >> q;
    const int inf = INT_MAX;
    auto f = [](int a, int b) { return b == inf ? a : b;};
    dual_segment_tree<int> seg(f, inf);
    seg.init(n);
    while (q--) {
        int com, s, t, x, i;
        cin >> com;
        if (com == 0) {
            cin >> s >> t >> x;
            seg.update(s, t+1, x);
        } else {
            cin >> i;
            cout << seg.get_val(i) << endl;
        }
    }
}



Measured memory_bytes: 3888
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
  int N, D;
  int cnt = 0;
  cin >> N >> D;
  for(int i=0;i<N;i++){
    int x, y;
    double d;
    cin >> x >> y;
    d = sqrt(pow(x, 2) + pow(y, 2));
    if (D >= d){cnt++;}
  }
  printf("%d\n", cnt);
  return 0;
}


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


#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(arr) arr.begin(),arr.end()
#define INF 2000000000
#define MOD 1000000007
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define um unordered_map
#define us unordered_set
#define ff first
#define ss second
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define REP(i,n) FOR(i,0,n)



using namespace std; 
void solve(); 
int main() 
{ 
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 

/*
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("error.txt", "w", stderr); 
	freopen("output.txt", "w", stdout); 
#endif 
*/
	ll n,k;
	cin>>n>>k;
	ll x = n%k;
	cout<<min(x,k-x)<<"\n"	;
	//cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0; 
} 
void solve() 
{ 
} 


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int a = sc.nextInt();
			int b = sc.nextInt();

			int w = 99, h = 100;
			boolean[][] block = new boolean[h][w];
			for (int i = h / 2; i < h; i++) {
				for (int j = 0; j < w; j++) {
					block[i][j] = true;
				}
			}

			for (int i = 0; i < a - 1; i++) {
				block[(i / (w / 2)) * 2 + 1][(i % (w / 2)) * 2 + 1] = true;
			}
			for (int i = 0; i < b - 1; i++) {
				block[(i / (w / 2)) * 2 + h / 2 + 1][(i % (w / 2)) * 2 + 1] = false;
			}

			out.println(h + " " + w);
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					out.print(block[i][j] ? '.' : '#');
				}
				out.println();
			}

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
const int INF=10000000;
int n,par[1005],x[1005],dp[1005][2][5005]={};
int main()
{
	scan(n);
	for(int i=2;i<=n;i++)
		scan(par[i]);
	for(int i=1;i<=n;i++)
		scan(x[i]);
	for(int now=n;now>=1;now--)
	{
		for(int sisa=x[par[now]];sisa>=0;sisa--)
		{
			for(int target=0;target<=1;target++)
			{
				int temp=dp[par[now]][target][sisa];
				temp=INF;
				
				if(sisa>=dp[now][target][x[now]])
					temp=min(temp,dp[par[now]][target][sisa-dp[now][target][x[now]]]+x[now]);
					
				if(sisa>=x[now])
					temp=min(temp,dp[par[now]][target][sisa-x[now]]+dp[now][target][x[now]]);
					
				dp[par[now]][target][sisa]=temp;
			}
		}
	}
	
	cout<<((dp[1][0][x[1]]!=INF||dp[1][1][x[1]]!=INF)?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 38400
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define ll long long 
using namespace std;

int main() {
	int a, b, c;
	string ans = "No";
	cin >> a >> b >> c;
	if (max(a, max(b, c)) == a + b + c - max(a, max(b, c))) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] spl=s.split(" ");
        int a = Integer.parseInt(spl[0]);
        int b = Integer.parseInt(spl[1]);
        int c = Integer.parseInt(spl[2]);
        
        Arrays.sort(spl);
        System.out.println(spl[0]+" "+spl[1]+" "+spl[2]);
    }
}

Measured memory_bytes: 24300
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int ans;
		
		int xs = x2 - x1;
		int ys = y2 - y1;
		
		int x3 = x2 - ys;
		int y3 = y2 + xs;
		int x4 = x3 - xs;
		int y4 = y3 - ys; 
		
   		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
		
   		sc.close();
        return ;

    }
    
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct UnionFind {
    // 親ノードの番号を持つメンバ変数
    // ただし自分が親の時は-x(xは自身を含めた子ノードの数)
    vector<int> par;
    
    //　コンストラクタでの初期化1(初期値-1を持つn次元配列)
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    // 与えられたノードの親ノードの番号を返すメンバ関数
    int root(int x) {
        // もしも親ノードが0以下なら、それは初期値なので自身が親
        if (par[x] < 0) return x;
        // 親ノードを再帰的に一番上までたどって返す
        // 単にroot(par[x])ではなく代入してるのは、根に直接張り直すため
        else return par[x] = root(par[x]);
    }
    
    // もし根が同じかどうかの判定
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    // ２つの根をマージする処理
    bool merge(int x, int y) {
        // 根をたどって、同じなら何もしない
        x = root(x); y = root(y);
        if (x == y) return false;

        // xもyも今は親ノードなので、子の数を比べる
        if (par[x] > par[y]) swap(x, y); // merge technique

        // 小さい方を親ノードにする
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    // 親ノードに入っている番号*-1 = この木のノード数を返す。
    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);
    vector<ll> B(M);

    REP(i, M){
        ll c;
        cin >> A[i] >> B[i] >> c;
        A[i]--;
        B[i]--;
    }

    UnionFind uf(N);

    // 辺を1つずつ足していく
    REP(i, M){


        ll x = A[M-i-1];
        ll y = B[M-i-1];

        // 同じ木に属すなら処理終了
        if(uf.issame(x, y)) continue;

        //最後にマージ処理をする
        uf.merge(x, y);
    }

    map<ll,ll> MAP;

    REP(i, N){
        MAP[uf.root(i)]++;
    }

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

    return 0;
}

Measured memory_bytes: 11248
#include <iostream>
using namespace std ;
int main ()
{
	int a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , x ;
	cin >> a1 ;
	cin >> a2 ;
	cin >> a3 ;
	cin >> a4 ;
	cin >> a5 ;
	cin >> a6 ;
	cin >> a7 ;
	cin >> a8 ;
	cin >> a9 ;
	cin >> a10 ;
	cout << a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 << endl;
}

Measured memory_bytes: 1160
n, s = 2.times.map {gets.to_i}

bs = Math.sqrt(n).ceil
BIG = 10**12
ans = BIG

(2..bs).each do |i|
    n1 = n
    sum = 0
    while n1 > 0
        sum += n1 % i
        n1 /= i
    end
    if sum == s
        puts i
        exit
    end
end

(1..bs).each do |ud|
    ld = s - ud
    next if ld < 0
    next if (n - ld) % ud > 0
    b = (n - ld) / ud
    if b > ld && b > ud
        ans = [ans, b].min
    end
end

if n == s
    ans = [ans, n+1].min
end

puts ans == BIG ? -1 : ans

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

#define    ll    long long int

int main( )
{
    int i, j, n, s = 0, mx = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> j;
        s += j;
        mx = max(mx, j);
    }
    cout << (s - mx / 2) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void swap(int& x, int& y) {
	int t = x;
	x = y;
	y = t;
}
void sort(int& a, int& b, int& c) {
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);
}

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

	for (int i = 0; i < n-2; i++) {
		//cout << i << "\n";
		for (int j = i+1; j < n - 1; j++) {
			for (int k = j+1; k < n; k++) {
				if (a[i] != a[j] and a[j] != a[k] and a[i] != a[k]) {
					//cout << i << j << k << "\n";
					int x = a[i];
					int y = a[j];
					int z = a[k];
					sort(x, y, z);
					if (z < x + y) {
						//cout << x << y << z << "\n";
						c += 1;
					}
				}
			}
		}
	}
	cout << c;
}

Measured memory_bytes: 3164
h, w, k = map(int, input().split())
board = [[-1 for j in range(w)] for i in range(h)]
for i in range(h):
    color = input()
    for j in range(w):
        if color[j] == "#":
            board[i][j] = 1 #黒=1
        else:
            board[i][j] = 0 #白=0
ans = 0

for row_choose in range(1<<h):
    for col_choose in range(1<<w):
        count = 0
        for i in range(h):
            for j in range(w):
                if not (row_choose & (1<<i)) and not (col_choose & (1<<j)) and board[i][j]:
                    count += 1
        if count == k:
            ans += 1

print(ans)

Measured memory_bytes: 8968