akhauriyash/Code-Regression huggingface dataset:
// i wrote this code in my head while driving and waiting in line on eglinton ave to get onto the
// allen.  CAN YOU TELL??
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
using ll = int64_t;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T, typename U> ostream& operator<<(ostream& _s, pair<T, U> _t) {
    _s << "(" << _t.first << "," << _t.second << ")"; return _s;
}
template<typename T, typename U> istream& operator>>(istream& _s, pair<T, U> &_t) {
    _s >> _t.first >> _t.second; return _s;
}
template<typename T> ostream& operator<<(ostream& _s, vector<T> _t) {
    rep(i, 0, _t.size()) _s << (i ? " " : "") << _t[i]; return _s;
}
template<typename T> istream& operator>>(istream& _s, vector<T> &_t) {
    rep(i, 0, _t.size()) _s >> _t[i]; return _s;
}


int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    vector<bool> ok(n, true);
    set<pair<int,int>> res;
    rep(i, 0, m)  {
        int x, y;
        cin >> x >> y;
        x--; y--;
        if (y < x) {
            swap(x, y);
        }
        g[x].push_back(y);
        g[y].push_back(x);
        ok[x] = !ok[x];
        res.insert({x, y});
    }
    int nbad = 0;
    rep(i, 0, n) {
        if (!ok[i]) {
            nbad++;
        }
    }
    if (nbad % 2 != 0) {
        cout << -1 << endl;
        return 0;
    }

    vector<int> parent(n, -1);
    parent[0] = 0;
    vector<int> ord;

    vector<int> s = {0};
    while(!s.empty()) {
        int x = s.back();
        ord.push_back(x);
        s.pop_back();
        for (int y : g[x]) {
            if (parent[y] != -1) continue;
            parent[y] = x;
            s.push_back(y);
        }
    }

    reverse(ord.begin(), ord.end());

    rep(i,0,n) {
        int x = ord[i];
        int y = parent[x];

        if (!ok[x]) {
            ok[x] = true;
            ok[y] = !ok[y];
            res.erase({min(x,y), max(x,y)});
            res.insert({max(x,y), min(x,y)});
        }
    }

    for (auto e : res) {
        cout << (e.first + 1) << " " << (e.second + 1) << endl;
    }

    // if(0) {
    //     rep(x, 0, n) {
    //         for (int y : g[x]) {
    //             assert(y > x);
    //             if (!ok[x]) {
    //                 ok[x] = true;
    //                 ok[y] = !ok[y];
    //                 res.push_back({y, x});
    //             } else {
    //                 res.push_back({x, y});
    //             }
    //         }
    //     }
    //     assert(ok[n - 1]);
    //     for (auto e : res) {
    //         cout << (e.first + 1) << " " << (e.second + 1) << endl;
    //     }
    // }
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int s[10], c[10];
    for (int i = 0; i < M; i++) cin >> s[i] >> c[i];

    for (int i = 0; i < 1000; i++) {
        string str = to_string(i);
        if ((int)str.size() != N) continue;
        bool check = true;
        for (int j = 0; j < M; j++) {
            if (str[s[j] - 1] != (char)('0' + c[j])) {
                check = false;
                break;
            }
        }
        if (check) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 2e18;  
const int mod1 = 998244353;
const int mod = 1e9 + 7;

void solve()
 {
  int n;
  cin>>n;
  pii d[n];
  loop(i,0,n)
   cin>>d[i].ff>>d[i].ss;
  loop(i,0,n)
   {
    int pos = i;
    int cnt = 0;
    while(pos < n && d[pos].ff == d[pos].ss)
       {
        pos++;
        cnt++;
       }
    if(cnt >= 3)
       {
        cout<<"Yes";
        return;
       }
   }
  cout<<"No";
 }
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);  
  /*int t;
  cin>>t;
  while(t--)*/
  solve();
  // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);

    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0;i < n;i++) {
        cout << s[i] << t[i];
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
import math

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
val = list(itertools.permutations(range(1,n+1)))
#print(val)
cntp = 0
cntq = 0
for i in range(len(val)):
    if p == val[i]:
        cntp = i+1
    if q == val[i]:
        cntq = i+1
print(int(math.fabs(cntp - cntq)))

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

public class Main{
 public static void main(String[] args){
   Scanner s = new Scanner(System.in);
   int[] arr = new int[5];
   for(int i=0; i<5; i++){
   arr[i] = s.nextInt();
   }
   
   int maxd = s.nextInt();
   String status ="Yay!";
   
   outerloop:
   for(int j=0; j<4; j++){
   for(int l=j+1; l<5; l++){
   if(arr[l]-arr[j] > maxd){
   status =":(";
     break outerloop;
   }
   }
   }
   System.out.print(status);
 }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
//#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
//#define mp make_pair
#define fi first
#define se second
int d,w;
vector<vector<int> >e(11,vector<int>(11,0));

int judge(int y1,int y2,int x1,int x2)
{
    int maxin=0,minout=1e9,ans=0;
    for(int i=y1;i<=y2;i++)for(int j=x1;j<=x2;j++)maxin=max(maxin,e[i][j]);
    for(int i=y1-1;i<=y2+1;i++)for(int j=x1-1;j<=x2+1;j++)
    {
        if(i==y1-1||i==y2+1||j==x1-1||j==x2+1)
        {
            if(e[i][j]<=maxin)return 0;
            minout=min(minout,e[i][j]);
        }
    }
    for(int i=y1;i<=y2;i++)for(int j=x1;j<=x2;j++)ans+=minout-e[i][j];
    return ans;
}
int sepoint(int y,int x)
{
    int ans=0;
     for(int i=y;i<=d-2;i++)for(int j=x;j<=w-2;j++)ans=max(ans,judge(y,i,x,j));
    return ans;
}
int fipoint(int y,int x)
{
    int ans=0;
    rep(i,1,y-1)rep(j,1,x-1)ans=max(ans,sepoint(i,j));
    return ans;
}
int main()
{
    while(cin>>d>>w,d)
    {
        e.empty();
        REP(i,d)REP(j,w)cin>>e[i][j];
        cout<<fipoint(d,w)<<endl;
    }
}


Measured memory_bytes: 3152
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 998244353


def main():
    N, K = map(int, input().split())
    dp = [0] * (N + 1)
    LR = [list(map(int, input().split())) for _ in range(K)]
    dp[1] = 1
    for i in range(1, N):
        for j in range(K):
            if i + LR[j][0] <= N:
                dp[i + LR[j][0]] += dp[i]
                dp[i + LR[j][0]] %= m
            if i + LR[j][1] < N:
                dp[i + LR[j][1]+1] -= dp[i]
                dp[i + LR[j][1]+1] %= m
        # print(dp)
        if i < N-1:
            dp[i + 2] += dp[i+1]
            dp[i + 2] %= m
    print(dp[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 75900
/*
 * src.cpp
 *
 *  Created on: 2016/08/21
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

const int MAX_N=1e5;

int N;
int A[MAX_N];

int main(){
	scanf("%d",&N);
	REP(i,N){
		scanf("%d",&A[i]);
	}
	ll ans=0;
	bool flg=false;
	REP(i,N){
		if (flg){
			flg=false;
			if (A[i]>0){
				A[i]--;
				ans++;
			}
		}
		ans+=A[i]/2;
		flg = (A[i]%2==1);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=300005,mod=1000000007;
int n,h,a[N],x[N],y[N],s[N],d[N],ans;
vector<int>v;
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
void pre(int k,int l,int r)
{
	if(l==r)
	{
		x[k]=y[k]=l;
		return;
	}
	s[k<<1]=s[k]*(k<<1)%mod;
	s[k<<1|1]=s[k]*(k<<1|1)%mod;
	int mid=l+r>>1;
	pre(k<<1,l,mid);
	pre(k<<1|1,mid+1,r);
	x[k]=x[k<<1];
	y[k]=y[k<<1|1];
}
void clear(int k)
{
	d[k]=0;
	if(k==1)
		return;
	clear(k/2);
}
void rec1(int k,int t)
{
	t=t*k%mod;
	d[k]=(d[k]+t)%mod;
	if(k==1)
		return;
	rec1(k/2,t);
}
void rec2(int k,int t,int l)
{
	t=t*k%mod;
	ans=(ans+t*(d[k^1])%mod*(k/2)%mod*qp(l,mod-2)%mod)%mod;
	if(k==1)
		return;
	rec2(k/2,t,l);
}
signed main()
{
	ios::sync_with_stdio(0);
	cin>>h;
	n=(1<<h)-1;
	for(int i=1;i<=n/2+1;i++)
		cin>>a[i];
	s[1]=1;
	pre(1,1,n/2+1);
	for(int i=1;i<=n/2;i++)
	{	
		v.clear();
		for(int j=x[i<<1];j<=y[i<<1];j++)
		{
			rec1(a[j]+n/2,s[j+n/2]);
			v.push_back(a[j]+n/2);
		}
		for(int j=x[i<<1|1];j<=y[i<<1|1];j++)
			rec2(a[j]+n/2,s[j+n/2],i==1?1:s[i]*s[i/2]%mod);
		for(auto j:v)
			clear(j);
	}	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 13256
using System;
class Program {
    static void Main (string[] args) {
        string[] input = Console.ReadLine().Split(' ');
        long n = long.Parse(input[0]);
        long k = long.Parse(input[1]);
        long ans = n;
        if (n >= k) {
            ans = n % k;
        }
        if (Math.Abs(ans - k) < ans) ans = Math.Abs(ans - k);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
n, k = gets.split.map(&:to_i)
d_vals = gets.split.map{|n| (n.to_f + 1.0) / 2}
sums = d_vals.inject([0]){|acc, it| acc.push(acc.last + it)}
puts sums.drop(k).zip(sums).map{|r, l| r - l}.max


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

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

    int N;
    cin >> N;

    int ans = INT_MAX, A, B;
    for (int i=1; i<=N-i; ++i) {
        A = i;
        B = N-i;

        int cnt = 0;
        while (A) {
            cnt += A % 10;
            A /= 10;
        }
        while (B) {
            cnt += B % 10;
            B /= 10;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}

long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
int dp[3234][3234][2];
vector<int> v;
int n;
int resolve(int l, int r, bool f){
	if(l==r){
		if(f){
			return v[l];
		}else{
			return 0;
		}
	}
	int &x=dp[l][r][f];
	if(x!=-1){
		return x;
	}

	if(f){
		x=0;
		x=max(x,resolve(l+1,r,!f)+v[l]);
		x=max(x,resolve(l,r-1,!f)+v[r]);
	}else{
		x=INF;
		x=min(x,resolve(l+1,r,!f));
		x=min(x,resolve(l,r-1,!f));
	}
	return x;
}
void solve(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	v.resize(n);
	int sum=0;
	for(auto &i: v){
		cin>>i;
		sum+=i;
	}
	cout<<resolve(0,n-1,true)-resolve(0,n-1,false)<<endl;
}
//revise as variaveis e a ordem nas funções
signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 167300
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    string s; cin >> s;
    rep(i, 0, 3){
        prt(s[i]);
    }
}

Measured memory_bytes: 3628
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
ll dp[100000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a;
	cin>>n;
	vector<pll> v(n);
	for(int i=0;i<n;i++)
	{
	    cin>>v[i].fi>>v[i].se;
	}
	sor(v);
	for(int i=0;i<=2*10000;i++)
	dp[i]=llmax;
	for(int i=0;i<n;i++)
	{
	    dp[v[i].fi]=min(dp[v[i].fi],v[i].se);
	    for(int j=v[i].fi+1;j<=2*10000;j++)
	    dp[j]=min(dp[j],dp[j-v[i].fi]+dp[v[i].fi]);
	}
//	cout<<dp[2];
//	nl;
	ll ans=llmax;
	for(int i=a;i<=2*10000;i++)
	{
	    ans=min(ans,dp[i]);
	}
	cout<<ans;
	
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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


ll cake[1010][3];
ll cake2[1010][3];
ll a[8][1010];
ll x[3];
int main() {
	int N, M;
	cin >> N >> M;
	ll t = 1900 * M + 100 * (N - M);
	ll p = pow(2, M);
	ll ans = t*p;
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    std::vector<i64> ds;
    i64 px;
    std::cin >> px;
    for (int i = 1; i < n; i++) {
        i64 nx;
        std::cin >> nx;
        ds.push_back(nx - px);
        px = nx;
    }

    std::vector<i64> co(n + 1);
    for (int i = 1; i <= n; i++) co[i] = inverse(i, mod);
    for (int i = 2; i <= n; i++) co[i] = (co[i] + co[i - 1]) % mod;

    i64 ret = 0;
    for (int i = 0; i < n - 1; i++) ret = (ret + ds[i] * co[i + 1] % mod) % mod;

    for (int i = 2; i < n; i++) ret = ret * i % mod;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	void solve()
	{
		ll x,n;
		set<ll> se;
		cin>>x>>n;
		forab(i,-110,110)
		{
			se.insert(i);
		}	
		//cin>>n;
		vll A(n);
		forn(i,n)
		{
			cin>>A[i];
			se.erase(A[i]);
		}
		ll mn=10000,ele=1000;
		for(auto i:se)
		{
			if(mn==abs(i-x))
				continue;
			mn=min(mn,abs(i-x));
			if(mn==abs(i-x))
			{
				ele=(i);
			}
			//cout<<i<<" ";
		}
		cout<<ele<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
	//	cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
const char nl = '\n';
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
ll power(ll x, unsigned int y) {ll res = 1;	while (y > 0) { if (y & 1) res = res*x%mod; y = y>>1; x = x*x;} return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void solve(){
     int n;
     cin>>n;
     if(n>=30)cout<<"Yes";
     else cout<<"No";
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


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

main(){
	int N, P=0, W=0,  G=0, Y=0;
  	char sp = 'P',sw = 'W',sg = 'G',sy = 'Y';
  	char flag;
  	cin >>  N;
  
  	for (int i=0; i < N; i++){
      cin >>  flag;
      /*cout << (flag == sp) << endl; */
      if ((flag == sp) && P == 0){P = 1;}
      if ((flag == sw) && W == 0){W = 1;}
      if ((flag == sg) && G == 0){G = 1;}
      if ((flag == sy) && Y == 0){Y = 1;}
    }
  	if(W+P+G+Y == 3) cout <<"Three"<< endl;
  	else cout <<"Four"<< endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
using namespace std;
int main(){
    char str3[101],str2[101],str1[202];
    scanf("%s",str1);
    scanf("%s",str3);
    strcpy(str2, str1);
    strcat(str1, str2);
    if(strstr(str1, str3) == NULL){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
long long arr[1000009],cnt[1000009];
vector <long long > v;
void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          v.push_back(p);
} 
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    SieveOfEratosthenes(1000002);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long n,i,j,k,x,y,z;
    cin>>n;
    x=0;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
    	cnt[arr[i]]=1;
    	x=__gcd(x,arr[i]);
	}
	if (x>1)
	{
		cout<<"not coprime"<<endl;
		return 0;
	}
	z=0;
	for (i=0;i<v.size();i++)
	{
		x=0;
		for (j=v[i];j<=1000000;j+=v[i])
		{
			x+=cnt[j];
		}
		if (x>=2)
		{
			z=1;
			break;
		}
	}
	if (z==1)
	{
		cout<<"setwise coprime"<<endl;
	}
	else
	{
		cout<<"pairwise coprime"<<endl;
	}
}

Measured memory_bytes: 20444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String[] l1 = r.readLine().split(" ");

		int a = Integer.valueOf(l1[0]);
		int b = Integer.valueOf(l1[1]);

		boolean found = false;
		for (int i = 0;; ++i) {
			int ea = (int) (i * 1.08) - i;
			int eb = (int) (i * 1.1) - i;

			if (ea == a && eb == b) {
				System.out.println(i);
				found = true;
				break;
			}

			if (eb > 100) {
				break;
			}
		}

		if (!found) {
			System.out.println(-1);
		}

		r.close();
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
int main(void)
{
    int a[100], n, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i = n - 1; i >= 0; i--)
    {
        printf("%d", a[i]);
        if (i!=0)
        {
            printf(" ");
        }
        else
        {
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2044
#include<iostream>

using namespace std;

#define MAX_N 10000+5

int par[MAX_N];
int rnk[MAX_N];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rnk[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rnk[x]<rnk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rnk[x]==rnk[y]) rnk[x]++;
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

int main(){

	int n,q;
	int c,x,y;

	cin>>n>>q;

	init(n+1);
	for(int i=0;i<q;i++){

		cin>>c>>x>>y;

		if(c==0) unite(x,y);
		else cout<<same(x,y)<<endl;

	}
	
}



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

int main() {
    int n; cin >> n;
    vector<ll> lucas(n+1);
    lucas[0] = 2LL; lucas[1] = 1LL;
    for (int i = 2; i <= n; i++)
    {
        lucas[i] = lucas[i-1] + lucas[i-2];
    }
    printf("%lld\n",lucas[n]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int>a(m);
    for(int i=0; i<m; i++){
        cin >> a[i];
    }

    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    
    sort(a.begin(),a.end());

    vector<int>sa(m-1);
    for(int i=0; i<m-1; i++){
        sa[i] = abs(a[i+1]-a[i]);
    }

    sort(sa.begin(),sa.end());
    int ans=0;
    for(int i=0; i<m-n; i++){
        ans += sa[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include <iostream>

int main()
{
    int N, d1, d2; std::cin >> N;
    int count = 0;
    bool flag = true;

    for (int i=0; i<N; i++)
    {
        std::cin >> d1 >> d2;

        if (d1 == d2) count++;
        else count = 0;

        if (count >= 3)
        {
            std::cout << "Yes" << std::endl;
            flag = false;
            break;
        }
    }

    if (flag) std::cout << "No" << std::endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int dp[100][8]; 

int main() {
    int H,W,K;cin>>H>>W>>K;
    dp[0][0] = 1;
    for(int h=0; h < H; ++h){
        for(int bit=0; bit < (1<<(W-1)); ++bit){
            bitset<8> bs(bit); // bs[i] := i - i+1 horizontal line exists or not
            // check if this amida is valid
            bool check = true;
            for(int w=0; w < W-2; ++w){ // w := idx of horizontal line
                if(bs[w] && bs[w+1]) check = false;
            }
            if(!check) continue;
            //
            // sum 
            for(int w=0; w < W; ++w){ // w := idx of vertical line
                if(w > 0 && bs[w-1]){ // to left side
                    dp[h+1][w-1] = (dp[h+1][w-1] + dp[h][w]) % MOD;
                } else if(w < W-1 && bs[w]){ // to right side
                    dp[h+1][w+1] = (dp[h+1][w+1] + dp[h][w]) % MOD;
                } else {
                    dp[h+1][w] = (dp[h+1][w] + dp[h][w]) % MOD;
                }
            }
        }
    }
    cout << dp[H][K-1] << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
S = list(input())
p = 10 ** 9 + 7
# p = 10 ** 18

A = AB = ABC = 0
power = 1
for i, Si in enumerate(S):
    # print("#", A, AB, ABC)
    if Si == 'A':
        A = (A + 1 * power) % p
    elif Si == 'B':
        AB = (AB + A) % p
    elif Si == 'C':
        ABC = (ABC + AB) % p
    else:
        ABC = (3 * ABC + AB) % p
        AB = (3 * AB + A) % p
        A = (3 * A + 1 * power) % p
        power = (power * 3) % p

print(ABC)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, T;
    cin >> N >> T;
    int c[N], t[N];
    rep(i, N) cin >> c[i] >> t[i];
    int ans = inf;
    rep(i, N){
        if(t[i] <= T){
            ans = min(ans, c[i]);
        }
    }
    if(ans == inf) cout << "TLE" << endl;
    else cout << ans << endl;
}

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

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto &x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

int get_GCD(int lhs, int rhs)
{
  int a = std::max(std::abs(lhs), std::abs(rhs));
  int b = std::min(std::abs(lhs), std::abs(rhs));

  if(b == 0) return 1;

  int res = a % b;

  while(res != 0) {
    a = b;
    b = res;
    res = a % b;
  }
  return b;
}

int get_GCD(const std::vector<int> &invec)
{
  std::vector<int> vec(invec);
  auto len = vec.size();
  while(len != 1) {
    // print_container(vec, "vec" + std::to_string(len));
    std::vector<int> gcds((len + 1)/2);

    for(size_t i=0; i<len/2; i++) {
      gcds[i] = get_GCD(vec[2*i], vec[2*i+1]);
    }
    if(len % 2 == 1) {
      gcds[len/2] = vec[len-1];
    }
    vec = gcds;
    len = vec.size();
  }

  return vec[0];
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for(int i=0; i<N; i++) {
    std::cin >> A[i];
  }

  std::cout << get_GCD(A) << std::endl;

  return 0;
}


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

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

using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    string S, T;
    cin >> S >> T;

    ll ans = S.size();

    const auto d = S.size() - T.size();

    rep (i, d + 1)
    {
        ll res = 0;

        rep (j, T.size())
        {
            if (S[i + j] != T[j]) { ++res; }
        }

        ans = min(ans, res);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
const int OO = 0x3f3f3f3f;
int SOURCE, SINK;

struct edge
{
    int v, f, c;
    edge(){}
    edge(int _v, int _f, int _c)
    {
        v = _v, f = _f, c = _c;
    }
};

vector<edge> edges;
vector<int> G[MAX];
int dist[MAX], work[MAX];

void add_edge(int u, int v, int cp, int rc){
	edges.push_back(edge(v, 0, cp));
	G[u].push_back(edges.size()-1);
	edges.push_back(edge(u, 0, rc));
	G[v].push_back(edges.size()-1);
}

bool bfs(int s, int t)
{
    memset(dist, -1, sizeof(dist));
    dist[s] = 0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int e : G[u])
            if(dist[edges[e].v] == -1 and edges[e].c-edges[e].f > 0)
            {
                q.push(edges[e].v);
                dist[edges[e].v] = dist[u] + 1;
            }
    }
    return dist[t] != -1;
}

int dfs(int s, int t, int f)
{
    if(s == t) return f;
    for(int &i = work[s]; i < G[s].size(); i++)
    {
    	int e = G[s][i];
        if(dist[edges[e].v] == dist[s] + 1 and edges[e].c-edges[e].f > 0)
            if(int a = dfs(edges[e].v, t, min(f, edges[e].c-edges[e].f)))
            {
                edges[e].f += a;
                edges[e^1].f -= a;
                return a;
            }
    }
    return 0;
}

int MaxFlow(int s, int t)
{
    int mf = 0;
    while(bfs(s, t))
	{
    	memset(work, 0, sizeof(work));
        while(int a = dfs(s, t, OO))
            mf += a;
    }
    return mf;
}

int n, m, a, b;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

bool check(int x, int y)
{
	return x >= 0 and x < n and y >= 0 and y < m;
}

int vertexIn(int i, int j)
{
	return i * m + j;
}

int vertexOut(int i, int j)
{
	return i * m + j + n * m + 1;
}

int main()
{
 	cin >> n >> m;
 	SOURCE = 2 * n * m + 2;
 	SINK = 2 * n * m + 3;
 	bool fl = false;
 	for(int i = 0; i < n; i++)
 		for(int j = 0; j < m; j++)
 		{
 			char c;
 			cin >> c;
 			int cost = 1;
 			if(c == 'X') cost = OO;
 			add_edge(vertexIn(i, j), vertexOut(i, j), cost, 0);
 			if(cost == OO) add_edge(vertexOut(i, j), SINK, OO, 0);
 			for(int k = 0; k < 4; k++)
 			{
				int x = i + dx[k], y = j + dy[k];
				if(check(x, y))
 					add_edge(vertexOut(i, j), vertexIn(x, y), OO, 0);
 			}
 			if(!i or !j or i == n - 1 or j == m - 1)
			{
 				add_edge(SOURCE, vertexIn(i, j), OO, 0);
 				if(c == 'X') fl = true;
 			}
 		}	
	if(fl) return puts("-1"), 0;
 	cout << MaxFlow(SOURCE, SINK) << '\n';
 	
    return 0;
}


Measured memory_bytes: 5428
A,B = map(int, input().split())

if A > B:
  n = (A-B) / 2
  r = (A-B) % 2
  if r == 0:
    print(int(B + n))
  else:
    print('IMPOSSIBLE')
    
else:
  n = (B-A) / 2
  r = (B-A) % 2
  if r == 0:
    print(int(A + n))
  else:
    print('IMPOSSIBLE')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;

ll b, k, n = 0, z = 0, x, y, a[200005] = {};
	vector<ll> v,vec;
	string s;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	if (n % 2 == 0) {
		for (i = n - 1; i >= 0; i -= 2) {
			cout << a[i] <<" ";
		}
		for (i = 0; i < n; i += 2) {
			cout << a[i] << " ";
		}

	}
	if (n % 2 == 1) {
		for (i = n - 1; i >= 0; i -= 2) {
			cout << a[i] << " ";
		}
		for (i = 1; i < n; i += 2) {
			cout << a[i] << " ";
		}

	}
	

	return 0;

}


Measured memory_bytes: 5140
#include <iostream>
long count;

int* get_data(int& n)
{
  std::cin >> n;
  int *data = new int[n];

  for(int i=0; i<n; i++)
    std::cin >> data[i];

  return data;
}

void merge(int d[], const int start, const int middle, const int end)
{
  int n1, n2, i,j,k;
  n1 = middle - start;
  n2 = end - middle;
  int L[n1], R[n2];
  for ( i=0; i<n1; i++)
    L[i] = d[start + i];
  for ( i=0; i<n2;  i++)
    R[i] = d[middle + i];
  i = j =0;
  for(k=start; k < end; k++)
  {
    if( (j==n2 || L[i] <= R[j]) && i != n1)
    {
      d[k] = L[i];
      i++;
    }else{
      d[k] = R[j];
      j++;
      count += n1 - i;
    }
  }
}

void merge_sort(int d[], int left, int right)
{
  int middle = -1;
  if (left +1 < right)
  {
    middle = (left + right)/2;
    merge_sort(d, left, middle);
    merge_sort(d, middle, right);
    merge(d, left, middle, right);
  }
}

int main()
{
  int n;
  int *d = get_data(n);
  count = 0;

  merge_sort(d, 0, n);
 
  std::cout << count << std::endl;
  delete d;
}


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

int main(){
  int N; cin >> N;
  double ans = 0;
  if(N % 2 == 0){
    ans = 0.50000000000;
  }else{
    ans = (N + 2.000 - 1.000) / (2.000 * N);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		String[] t = String.valueOf(n).split("");

		for (int i = 0; i < t.length; i++) {
			if (!t[i].equals(t[t.length - 1 - i])) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");

	}
}


Measured memory_bytes: 22992
#include<bits/stdc++.h>
using namespace std;
const int mod1=1e9+7;
int n,i,a[1005],k,j;
long long t=1;

int main(){

   cin>>n;
   for(i=2;i<=n;i++)
   {
   	  k=i;
   	  for(j=2;j<=k;j++)
   	  {
   	  	while(k%j==0)a[j]++,k=k/j;
   	  
   	  }
   	  
   }
   for(i=2;i<=n;i++)
   {
   	 if(a[i]) t=t*(a[i]+1)%mod1;
   	  
   }
  cout<<t;
	return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

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

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define INF 1e+12
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    char s;
    cin >> s;
    s++;
    cout << s << endl;
    return 0;
}


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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

const int mod = 1e9 + 7;

#define ll long long
struct Line
{
    mutable ll k, b, p;
    bool operator<(const Line& o) const { return k < o.k; }
    bool operator<(ll x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>>
{
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b)
    {  // floored division
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y)
    {
        if (y == end())
        {
            x->p = inf;
            return false;
        }
        if (x->k == y->k)
            x->p = x->b > y->b ? inf : -inf;
        else
            x->p = div(y->b - x->b, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll b)
    {
        auto z = insert({k, b, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p) isect(x, erase(y));
    }
    ll query(ll x)
    {
        // assert(!empty());
        auto l = *lower_bound(x);
        return l.k * x + l.b;
    }
};

const int N = 2e5 + 10;
int n;
LL c;
LL h;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (~scanf("%d%lld", &n, &c))
    {
        scanf("%d", &h);

        LineContainer lc;

        LL dp = 0;
        lc.add(2 * h, -h * h);

        for (int i = 2; i <= n; i++)
        {
            scanf("%d", &h);
            LL v = -lc.query(h);
            dp = v + c + h * h;
            // debug(i, v, c, h[i], dp[i]);
            lc.add(2 * h, -h * h - dp);
        }
        printf("%lld\n", dp);
    }

    return 0;
}


Measured memory_bytes: 16276
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  int X[M];
  for (int i = 0; i < M; i++) cin >> X[i];
  sort(X, X+M);
  int len[M-1];
  for (int i = 0; i < M-1; i++) len[i] = X[i+1] - X[i];
  sort(len, len+M-1);
  //for (int i = 0; i < M-1; i++) cout << len[i] << " " << endl;
  int ans = 0;
  for (int i = 0; i < M-N; i++) ans += len[i];
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=1'000'000'007;
const double EPS=1e-14;
const bool DEBUG=true;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////


void answer(){
    long a, b, c, d;
    cin>>a>>b>>c>>d;
    long answer1 = a*c;
    long answer2 = a*d;
    long answer3 = b*c;
    long answer4 = b*d;
    cout<<max(max(answer1, answer2), max(answer3, answer4))<<endl;

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


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


int main(){
int N,X;
int amount = 0;
int num;

int m[100010];

cin >> N >> X;
for(int i = 0; i < N; ++i){
cin >>m[i];
}


for(int i = 0; i < N; ++i){
amount = amount + m[i];
}

sort(m,m+N);

num = (X - amount)/m[0];



cout << num + N << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  ll N;
  cin >> N;
  N = N * (N-1) /2;
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
inline double fabs(double x){return x>0?x:-x;}
int a[110];
int main ()
{
	int n,ans; scanf("%d",&n);
	double sum=0,mi=1e18;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	sum/=n;
	for(int i=1;i<=n;i++)
	if(fabs(a[i]-sum)<mi) mi=fabs(a[i]-sum),ans=i;
	printf("%d",ans-1);
	return 0;
}	

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int n, m, q;
int table[1000][40];

void print_table(int a, int b);

signed main()
{
    while ( cin >> n >> m >> q, n ) {
        string sw1, sw2, state1, state2;
        rep(i, n) { sw1.pb('0'); }
        rep(i, m) { state1.pb('0'); }
        memset(table, 0, sizeof(table));

        rep(loop, q) {
            cin >> sw2 >> state2;
            vi sws, swn;
            rep(i, sw2.length()) {
                if (sw2[i] == '1') {
                    sws.pb(i);
                } else {
                    swn.pb(i);
                }
            }
            rep(i, state2.length()) {
                if (state1[i] != state2[i]) {
                    for (int pos : sws) {
                        if (table[i][pos] != -1) {
                            table[i][pos] = 1;
                        }
                    }
                    for (int pos : swn) {
                        table[i][pos] = -1;
                    }
                } else {
                    for (int pos : sws) {
                        table[i][pos] = -1;
                    }
                }
            }
            sw1 = sw2;
            state1 = state2;
            //print_table(n, m);
        }
        rep(i, m) {
            int ans = -1;
            rep(j, n) {
                if (table[i][j] != -1 && ans == -1) {
                    ans = j;
                } else if (table[i][j] != -1) {
                    ans = -2;
                }
            }
            if (0 <= ans && ans <= 9) {
                cout << ans;
            } else if (10 <= ans) {
                printf("%c", 'A' + (ans - 10));
            } else {
                cout << '?';
            }
        }
        cout << endl;
    }

    return 0;
}

void print_table(int a, int b)
{
    rep(i, a) {
        rep(j, b) {
            printf("%5lld", table[j][i]);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3480
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin >> s;

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

    return 0;
}


Measured memory_bytes: 256
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], t = tmp[1];
    long[] a = readln.split.to!(long[]);

    long x = t;
    foreach (i; 0 .. n-1)
    {
        x += min(t, a[i+1]-a[i]);
    }

    x.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 11608
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define req(x,y) for(ll j=x,k=y;j<k;j++,k--)
#define rer(a,b,c) for(j=a,k=b;j<(ll)ss(c) && k>=0 && y;j++,k--)
#define ss(x) s[x].size()
#define ch(w,x,y) if(s[b][w]!=s[x][y])
#define cm(w,x,y,z) w=min(w,c[i]+f(x,y,z))

ll n,c[51],d[51][21][2],v[51][21][2],a=1e18;
string s[51];

ll f(ll b,ll p,ll g){
	if(p==ss(b))return 0;
	ll &e=v[b][p][g];
	ll &m=d[b][p][g];
	if(e)return m;
	e=1,m=1e18;
	ll l=1;
	if(!g){req(p,ss(b)-1)ch(j,b,k)l=0;}
	else{req(0,p)ch(j,b,k)l=0;}
	if(l)return m=0;
	rep(i,n){
		ll y=1;
		ll j,k;
		if(!g){
			rer(p,ss(i)-1,b)ch(j,i,k)y=0;
			if(y){if(k<0)cm(m,b,j,0);else cm(m,i,k,1);}
		}
		else{
			rer(0,p,i)ch(k,i,j)y=0;
			if(y){if(k<0)cm(m,i,j,0);else cm(m,b,k,1);}
		}
	}
	return m;
}

int main() {
	cin>>n;
	rep(i,n)cin>>s[i]>>c[i];
	rep(i,n)cm(a,i,0,0);
	cout<<(a==1e18 ? -1 : a)<<endl;
}


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

int main() {
  int N, M, from, to;
  cin >> N >> M;
  vector<int> cities(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> from >> to;
    cities.at(from-1) += 1;
    cities.at(to-1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << cities.at(i) << endl;
  }
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    multiset<int> s;
    for(int i=0;i<(1<<n);i++)
    {
        int t;
        scanf("%d",&t);
        s.insert(t);
    }
    multiset<int> v={*s.rbegin()};
    s.erase(prev(s.end()));
    while(!s.empty())
    {
        vector<int> t;
        for(multiset<int>::reverse_iterator it=v.rbegin();it!=v.rend();it++)
        {
            int a=*it;
            multiset<int>::iterator r=s.lower_bound(a);
            if(r==s.begin())
            {
                printf("No\n");
                return 0;
            }
            r--;
            t.push_back(*r);
            s.erase(r);
        }
        for(int a:t) v.insert(a);
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 13304