akhauriyash/Code-Regression huggingface dataset:
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

static LL f(LL x) {
	switch (x & 3) {
	case 0:
		return x;
	case 1:
		return 1;
	case 2:
		return x | 1;
	default:
		return 0;
	}
}

int main(int argc, char *argv[]) {
	LL a, b;
	cin >> a >> b;
	LL ans = f(b) ^ f(a - 1);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    ll a, b, k;
    cin >> a >> b >> k;

    ll ans1, ans2;

    if (a >= k) {
        ans1 = a - k;
        ans2 = b;
    }
    else {
        ans1 = 0;
        ans2 = max(b - k + a, 0ll);
    }

    cout << ans1 << " " << ans2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n;
	cin >> n;
	vi v(n);
	int64 s = 0;
	inpv(v);
	int mx = v[0];

	for1(i, n - 1) {
		if (v[i] > mx) mx = v[i];
		else {
			s += (int64)(mx - v[i]);
		}
	}

	cout << s;

	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a,b,c,d,e,f;
int ans[2];
double x=-1;
int main()
{
	cin>>a>>b>>c>>d>>e>>f;
    for(int i=0;100*a*i<=f;i++)
    	for(int j=0;100*a*i+100*b*j<=f;j++)
    		for(int k=0;100*a*i+100*b*j+c*k<=f;k++)
    			for(int l=0; 100*a*i+100*b*j+c*k+d*l<=f; ++l)
    				if(e*(a*i+b*j) >= c*k+d*l && x < (double)100*(c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l)))
    				{
                        x = (double)100*(c*k+d*l)/(100*(a*i+b*j)+(c*k+d*l));
                        ans[0]=100*(a*i+b*j)+c*k+d*l;
                        ans[1]=c*k+d*l;
    				}
    cout<<ans[0]<<" "<<ans[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/agc008/submissions/15248942
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
c = input()

R = c.count('R')
left = c[:R]
ans = left.count('W')

print(ans)


Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int l[500010],r[500010];

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == '<') l[i+1] = l[i] + 1;
    }
    for (int i = s.size()-1; i >= 0; --i) {
        if(s[i] == '>') r[i] = r[i+1] + 1;
    }

    ll ans = 0;
    for (int i = 0; i <= s.size(); ++i) {
        ans += max(l[i],r[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4740
using System;
using System.Collections.Generic;
public class diverta2019A {
    public static void Main() {
        int N, K, ans = 0;
        string[] str = System.Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        K = int.Parse(str[1]);
        ans = N - K + 1;
        System.Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
import * as fs from 'fs';

const args = fs.readFileSync("/dev/stdin", "utf8").split('\n')

const calc = (array: number[], edge: number): number => {
  const ev = array.map(v => (1 + v) / 2)
  // referenced and not implemented
  const res = ev.reduce(({ max, tmp }, prev, i) => {
    const v = tmp + prev
    if (i <= edge - 1) return { max: v, tmp: v }
    const t = v - ev[i - edge]
    return { max: Math.max(t, max), tmp: t }
  }, { max: 0, tmp: 0 })
  return res.max
}

const [_, k] = args[0].split(" ").map(x => +x)
const p = args[1].split(" ").map(x => +x)

console.log(calc(p, k))


Measured memory_bytes: 35544
#include <iostream>

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

  int *a = new int [n];
  for(int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }

  for(int i = n - 1; i >= 0; --i) {
    if(i != 0) {
      std::cout << a[i] << " ";
    }
    else {
      std::cout << a[i];
    }
  }
  std::cout << std::endl;

  delete[] a;

  return 0;
}

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

template <typename Tp, typename Fp>
class segment_tree{
    Tp *tree;
    const size_t len;
    const Tp e;
    const Fp f;
public:
    segment_tree(size_t n, const Tp &id, Fp fn, const Tp *values=nullptr): len(n), e(id), f(fn){
        tree = new Tp[n<<1];
        for(size_t i=0; i<n; ++i) tree[n+i] = values ? values[i] : id;
        for(size_t i=n-1; i>0; --i) tree[i] = fn(tree[i<<1 | 0], tree[i<<1 | 1]);
    }
    void set(size_t pos, const Tp &val){
        tree[pos += len] = val;
        for(pos>>=1; pos>0; pos>>=1) tree[pos] = f(tree[pos<<1 | 0], tree[pos<<1 | 1]);
    }
    void add(size_t pos, const Tp &val){
        set(pos, f(val, tree[len + pos]));
    }
    Tp get(size_t left, size_t right){
        left += len; right += len;
        Tp lval = e, rval = e;
        while(left < right){
            if(left  & 1) lval = f(lval, tree[left ++]);
            if(right & 1) rval = f(tree[--right], rval);
            left >>= 1; right >>= 1;
        }
        return f(lval, rval);
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int bin['z'-'a'+1] = {0};
    for(char c: s) ++bin[c-'a'];

    int odd = 0, oc = -1;
    for(int b: bin){ odd += b & 1; if(b & 1) oc = b; }
    if(odd > 1){ cout << -1 << endl; return 0; }
    
    deque<int> dq['z'-'a'+1];
    for(int i=0;i<s.size();++i) dq[s[i]-'a'].push_back(i);
    auto sum = [](int x, int y){ return x + y; };
    segment_tree<int, decltype(sum)> st{s.size(), 0, sum};
    
    int64_t ans = 0, n = s.size();
    while(true){
        int k = 0, mc = INT32_MAX, mxc = -1;
        for(char c='a';c<='z';++c){
            if(dq[c-'a'].size() == 0) continue;
            mc = min(mc, dq[c-'a'].front());
            mxc = max(mxc, dq[c-'a'].back());
            ++k;
        }
        if(k <= 1) break;
        int m = s[mc] - 'a', mx = s[mxc] - 'a';
        if(dq[m].size() > 1){
            st.add(dq[m].front(), 1);
            st.add(dq[m].back(), 1);
            ans += n-2 - (dq[m].back() - st.get(0, dq[m].back()));
            dq[m].pop_back();
            dq[m].pop_front();
            n -= 2;
        }else{
            st.add(dq[mx].front(), 1);
            st.add(dq[mx].back(), 1);
            ans += dq[mx].front() - st.get(0, dq[mx].front());
            dq[mx].pop_back();
            dq[mx].pop_front();
            n -= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

template <int MOD = 1000000007>
struct Mint {
    int x;

    Mint() : x(0) {}
    Mint(long long t) {
        x = t % MOD;
        if (x < 0) x += MOD;
    }

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

    Mint operator-() const {
        return Mint(-x);
    }

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

    friend ostream &operator<<(ostream &os, const Mint &a) {
        return os << a.x;
    }

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    Mint<> dp[n + 1][4];
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] != '?') {
            for (int j = 0; j <= 3; j++) {
                dp[i + 1][j] += dp[i][j];
            }
            if (s[i] == 'A') {
                dp[i + 1][1] += dp[i][0];
            } else if (s[i] == 'B') {
                dp[i + 1][2] += dp[i][1];
            } else if (s[i] == 'C') {
                dp[i + 1][3] += dp[i][2];
            }
        } else {
            for (int j = 0; j <= 3; j++) {
                dp[i + 1][j] += Mint<>(3) * dp[i][j];
            }
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][2] += dp[i][1];
            dp[i + 1][3] += dp[i][2];
        }
    }
    cout << dp[n][3] << endl;
    return 0;
}

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

using namespace std;

int main(){
	
	
	string S;
	int l=0;
	
	cin >> S ;
	
	for(int i=0; i<(int)S.size(); i++){
		
		if(S.at(i) == '+') l++;
		else l--;
		
	}
	
	cout << l << endl;
}


Measured memory_bytes: 256
INF = 10**12

def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


def main():

    n,m,l = map(int, input().split())
    d = [ [INF]*(n) for _ in range(n) ]
    for _ in range(m):
        a,b,c = map(int, input().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c

    warshall_floyd(d, n)

    d2 = [ [INF]*(n) for _ in range(n) ]
    for i in range(n):
        for j in range(n):
            if d[i][j] <= l:
                d2[i][j] = 1

    warshall_floyd(d2,n)
    ans = []
    q = int(input())
    for _ in range(q):
        s,t = map(int, input().split())
        dist = d2[s-1][t-1]
        if dist == INF: dist = 0
        ans.append(dist-1)

    for a in ans:
        print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 83048
//abc144_e.cpp
//Sun Oct 27 20:49:52 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,k;
	cin >> n >> k;

	ll a[n],f[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
	}

	for (int i=0;i<n;i++){
		cin >> f[i];
	}

	sort(a,a+n,greater<int>());
	sort(f,f+n);
	ll multi[n];
	for (int i=0;i<n;i++){
		multi[i] = a[i]*f[i];
	}
	
	ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll ok = 1000000000000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		ll tempk = 0;
		int flag = 1;
		for (int i=0;i<n;i++){
			if (multi[i]<=mid){
				continue;
			}
			ll count = (multi[i]-mid)/f[i];
			if ((multi[i]-mid)%f[i]>0){
				count++;
			}
			tempk+=count;
			if (tempk>k){
				flag = 0;
				break;
			}
		}
		if (flag) ok = mid;
		else ng = mid;
	}

	cout << ok << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Sv 10000000

vector<int> primes;
bitset<Sv> bs;
void sieve(ll upper){
	bs.set();
	bs[0] = bs[1] = 0;
	for(ll i = 2 ; i <= Sv + 1 ; ++i)if(bs[i]){
		for(ll j = i * i ; j <= Sv + 1 ; j += i)bs[j] = 0;
		primes.push_back(int(i));
	}
}
int DifPf (ll n){
	int ind = 0 , res = 0;
	long pf = primes[ind];
	while(pf * pf <= n){
		if(n % pf == 0)++res;
		while(n % pf == 0) n /= pf;
		pf = primes[++ind];
	}
	if(n != 1) ++res;
	return res;
}
ll gcd (ll a , ll b){
	return (b == 0) ? a : gcd(b,a%b);
}
int main() {
	ll a , b ;
	scanf("%lld %lld",&a,&b);
	sieve(sqrt(max(a,b)));
	printf("%d",DifPf(gcd(a,b)) + 1);
	return 0;
}

Measured memory_bytes: 7664
N, K = map(int, input().split())
D = list(map(int, input().split()))

#使うことのできるリストの作成
d = []
for i in range(10):
    if i in D:
        pass
    else:
        d += [i]

def check(i): #数値iがdのリストだけで書くことができるかを判定
    I = str(i) #文字列に変換
    # print (I)
    n = len(I) #桁数の取得
    for j in range(n): #全桁で確認
        # print (I[j])
        if int(I[j]) in d: #大丈夫ならスルー
            pass
        else: #一つでも不適ならFalseを返す
            return False
    return True

# print (check(2000))

for i in range(N, 10**5 + 1): #小さい数から全探索
    if check(i): #dの中だけで書けるかをチェック
        print (i) #書くことができるなら出力して終了
        exit()


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

using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, k, x, y;
    string key, l, r;
    cin >> n;
    map<string, int> workspace;
    // multimap<int> workspace;

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        if (k == 0)
        {
            cin >> key >> x;
            workspace[key] = x;
        }
        else if (k == 1)
        {
            cin >> key;
            auto z = workspace.find(key);
            cout << ((z == workspace.end()) ? 0 : workspace[key]) << "\n";
        }
        else if (k == 2)
        {
            cin >> key;
            workspace.erase(key);
        }
        else if (k == 3)
        {
            cin >> l >> r;
            for (auto itr = workspace.lower_bound(l); itr != workspace.upper_bound(r); itr++)
            {
                auto itr2 = *itr;
                const string a = itr2.first;
                int b = itr2.second;
                cout << a << " " << b << "\n";
            }
        }
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 27880
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
s = 0

for i in range (0,N):
  s = s + min(A[i],B[i])
  if A[i] < B[i]:
    B[i] = B[i] - A[i]
    s = s + min(A[i+1],B[i])
    A[i+1] = A[i+1] - min(A[i+1],B[i])
print(s)

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

int main() {
  int N, c = 0;
  cin >> N;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
    if (p[i] != i+1) c++;
  }

  if (c == 0 || c == 2)
    puts("YES");
  else
    puts("NO");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[11],t[11],u[11];
  int a,b,i=0;
  scanf("%s%s",s,t);
  scanf("%d%d",&a,&b);
  scanf("%s",u);
  while(s[i]!=0){
    if(s[i]!=u[i]){
      printf("%d %d",a,b-1);
      return 0;
    }
    i++;
  }
  printf("%d %d",a-1,b);
  return 0;
}


Measured memory_bytes: 128
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 998244353//1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 10005
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int a[N];
bool Prim(ll n){
    for(ll i=2;;i++){
        if(i*i>n)break;
        if(n%i==0)return 0;
    }
    return 1;
}
int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,K,n;
    scanf("%d",&n);
    rep(i,0,n+1)scanf("%d", &a[n-i]);
    ll d=0;
    rep(i, 0, n+1){
        d=gcd(d, (ll)abs(a[i]));
    }
    rep(i, 0, n+1)a[i]/=d;
    set<ll>s;
    for(ll i=2;;i++){
        if(i*i>d)break;
        if(d%i)continue;
        s.insert(i);
        while(d%i==0)d/=i;
    }
    if(d>1)s.insert(d);
    for(ll i=2; i<20000; i++)if(Prim(i) && !s.count(i)){
        int ok=1;
        for(int k=0; k<=20 && ok; k++){
            ll x=rand()%i;
            ll w=0, q=1;
            rep(j, 0, n+1){
                w+=a[j]*q%i;
                w%=i;
                q=q*x%i;
            }
            if(w){ok=0;break;}
        }
        if(ok)s.insert(i);
    }
    for(auto &x:s)printf("%lld\n",x);
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (void)
{
  char c;
  string s;
  int i,j,n;
  cin>>n>>s;
  j=s.size();
  for(i=0;i<j;i++)
  {
    if(s[i]+n<='Z'){c=s[i]+n;}
    else{c=s[i]+n+'A'-'Z'-1;}
    cout<<c;
  }
}

Measured memory_bytes: 3632
#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;

int main() {
  int A, B;
  cin >> A >> B;
  if(A >= 1 && A <= 9 && B >= 1 && B <= 9) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

int n,x;
int a[610000];

int main(){
    scanf("%d",&n);
    int h=300000,t=299999;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(i&1)a[++t]=x;
        else a[--h]=x;
    }if(n&1){
        for(int i=t;i>=h;i--){
            printf("%d ",a[i]);
        }
    }else{
        for(int i=h;i<=t;i++){
            printf("%d ",a[i]);
        }
    }return 0;
}

Measured memory_bytes: 2944
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	string s,t;
	int n=0;
	cin>>s>>t;
	rep(i,sz(s)){
		if(s[i]!=t[i])n++;
	}
	cout<<n;
	return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;
 
 
 
int main(){
	int N,K;
	cin>>N>>K;
	string S;
	cin>>S;
	vi ct0={0};
	vi ct1={0};
	
	int now=0;
	int ct=0;
	rep(i,N){
		if(now==0){
			if(S[i]=='0')ct++;
			if(S[i]=='1'){
				ct0.push_back(ct);
				now=1;
				ct=1;
			}
		}
		else{
			if(S[i]=='1')ct++;
			if(S[i]=='0'){
				ct1.push_back(ct);
				now=0;
				ct=1;
			}
		}
	}
	if(now==0)ct0.push_back(ct);
	if(now==1){
		ct1.push_back(ct);
		ct0.push_back(0);
	}
	int l=sz(ct1);
	ct1.push_back(0);
//	rep(i,l)cout<<ct0[i]<<ct1[i];
//	cout<<ct0[l];
 
	if(l<=K){
		cout<<N<<endl;
		return 0;
	}
	
	vi sum0(l+1,0);
	vi sum1(l+1,0);
	rep1(i,l)sum0[i]=sum0[i-1]+ct0[i];
	rep1(i,l)sum1[i]=sum1[i-1]+ct1[i];

//   	rep(i,l+1)cout<<sum0[i]<<" ";
// 	cout<<endl;
// 	rep(i,l+1)cout<<sum1[i]<<" ";
//  	cout<<endl;
  
	int ans=0;
	for(int i=K;i<=l;i++){
		int m;
		if(i!=K)m=sum0[i]-sum0[i-K]+sum1[i]-sum1[i-K-1];
		else m=sum0[i]-sum0[i-K]+sum1[i];
//      	cout<<m<<" ";
		ans=max(ans,m);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int price = sc.nextInt();
		int unlikeNum = sc.nextInt();
		int pay = price;
	    int[] array = new int[unlikeNum];
	    for(int i = 0; i<unlikeNum; i++){
	        array[i] = sc.nextInt();
	    }
	    while(!(jadgeUnlikeNum(pay, unlikeNum, array))){
	    	pay++;
	    }
	    System.out.println(pay);
	}

	public static boolean jadgeUnlikeNum(int pay, int unlikeNum, int[] array) {
		boolean ans = true;
		String payStr = String.valueOf(pay);
		String payNum[] = new String[payStr.length()];
		String arrayStr[] = new String[unlikeNum];

		for(int i = 0; i <payStr.length(); i++) {
			payNum[i] = payStr.substring(i, i+1);
		}

		for(int i = 0; i <array.length; i++) {
			arrayStr[i] = String.valueOf(array[i]);
		}

		for(int i = 0; i <payNum.length; i++) {
			for(int j = 0; j <arrayStr.length; j++) {
				if(payNum[i].equals(arrayStr[j])) {
					ans = false;
					break;
				}
			}
		}
		return ans;
	}
}


Measured memory_bytes: 55316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
struct poit
{
    ll v;
    ll n;
}a[10];
ll cmp(const poit a,const poit b)
{
    double a1=a.n*1.0/a.v;
    double a2=b.n*1.0/b.v;

    return a1>a2;
}
int main()
{

    while(cin>>a[1].v>>a[2].v>>a[3].v>>a[4].v)
    {
        a[1].n=25,a[2].n=50,a[3].n=100,a[4].n=200;
        double n1;
        cin>>n1;
        ll n=n1*100;
       sort(a+1,a+5,cmp);
       /*for(ll i=1;i<=4;i++)
        cout<<a[i].n/a[i].v<<' '<<a[i].n<<endl;*/


        ll ans=0;
        //cout<<"1111="<<a[1].n<<endl;
        while(n)
        {       //cout<<"每次的n"<<n<<endl;
            ll i;
            for(i=1;i<=5;i++)
            {
                if(n>=a[i].n)
                    break;
            }
            //cout<<"选的多少钱"<<a[i].v<<"给多少糖"<<a[i].n<<endl;

            ll b=n%a[i].n;
            ans+=n/a[i].n*a[i].v;
            n=b;
        }
        cout<<ans<<endl;

    }

    return 0;
}


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(long long n, std::vector<long long> a) {
  ll r1 = 0, r2 = 0, r1s = 0, r2s = 0;
  rep(i, n) {
    r1s += a[i];
    r2s += a[i];
    if (i % 2 == 0) {
      if (r1s <= 0) {
        r1 += abs(r1s - (1));
        r1s = 1;
      }
      if (r2s >= 0) {
        r2 += abs(r2s - (-1));
        r2s = -1;
      }
    } else {
      if (r2s <= 0) {
        r2 += abs(r2s - (1));
        r2s = 1;
      }
      if (r1s >= 0) {
        r1 += abs(r1s - (-1));
        r1s = -1;
      }
    }
  }
  cout << min(r1, r2) << endl;
}

int main() {
  long long n;
  scanf("%lld", &n);
  std::vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  solve(n, std::move(a));
}


Measured memory_bytes: 4072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n, tmp;
	cin >> n;
	map<int, int> odd, even;
	rep(i, n) {
		cin >> tmp;
		if (i % 2 == 0)	even[tmp]++;
		else odd[tmp]++;
	}
	P oddMax, evenMax;
	oddMax = make_pair(-1, -1);
	evenMax = make_pair(-1, -1);
	int oddOthers, evenOthers;
	oddOthers = evenOthers = 0;
	for (auto a : odd) {
		if (oddMax.second < a.second)	oddMax = a;
	}
	for (auto a : even) {
		if (evenMax.second < a.second)	evenMax = a;
	}

	int ans = iINF;
	if (oddMax.first == evenMax.first) {
		int tmpAns = 0;
		int tmpOdd, tmpEven;
		tmpOdd = tmpEven = 0;
		for (auto a : odd) {
			if (a.first == oddMax.first) continue;
			tmpOdd += a.second;
		}
		for (auto a : even) {
			if (a.first == evenMax.first) continue;
			tmpEven += a.second;
		}


		tmpAns = tmpOdd;
		P tmpEvenMax = make_pair(-1, -1);
		for (auto a : even) {
			if (a.first == evenMax.first) continue;
			if (tmpEvenMax.second < a.second)	tmpEvenMax = a;
		}
		int tmptmpEven = 0;
		for (auto a : even) {
			if (a.first == tmpEvenMax.first) continue;
			tmptmpEven += a.second;
		}
		tmpAns += tmptmpEven;
		ans = min(ans, tmpAns);

		tmpAns = tmpEven;
		P tmpOddMax = make_pair(-1, -1);
		for (auto a : odd) {
			if (a.first == oddMax.first) continue;
			if (tmpOddMax.second < a.second)	tmpOddMax = a;
		}
		int tmptmpOdd = 0;
		for (auto a : odd) {
			if (a.first == tmpOddMax.first) continue;
			tmptmpOdd += a.second;
		}
		tmpAns += tmptmpOdd;
		ans = min(ans, tmpAns);
	}
	else {
		ans = 0;
		for (auto a : odd) {
			if (a.first == oddMax.first) continue;
			ans += a.second;
		}
		for (auto a : even) {
			if (a.first == evenMax.first) continue;
			ans += a.second;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8112
N = int(input())
H = [int(h) for h in input().split()]

DHA = []
for n in range(N-1):
  if H[n] >= H[n+1]:
    DHA.append(True)
  else:
    DHA.append(False)
DHA.append(False)

cnt = 0
mx_cnt = 0
for T_or_F in DHA:
  if T_or_F:
    cnt += 1
  else:
    if mx_cnt < cnt:
      mx_cnt = cnt
    cnt = 0

print(mx_cnt)

Measured memory_bytes: 14252
n,k=map(int,input().split())
s=input()
if s[k-1]=="A":
    print(s[:k-1]+"a"+s[k:])

if s[k-1]=="B":
    print(s[:k-1]+"b"+s[k:])

if s[k-1]=="C":
    print(s[:k-1]+"c"+s[k:])


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
    cin >> a.at(i);

  long long sum = 0;
  long long u = 0;
  for (int i = n - 1; i > 0; i--) {
    u += a.at(i);
    u = u % 1000000007;
    sum += u * a.at(i - 1);
    sum = sum % 1000000007;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 4052
n = gets.to_i
coord = n.times.map{gets.chomp.split(" ").map(&:to_i)}.sort_by{|i,j|i}
edge = Array.new
mori = Array.new(n){|i|i}
morimori = Hash.new
ans = 0
n.times do |i|
  morimori[i] = [i]
end
n.times do |i|
  coord[i] << i
end
(n-1).times do |i|
  edge << [coord[i+1][0]-coord[i][0],coord[i+1][2],coord[i][2]]
end
coord = coord.sort_by{|i,j,k|j}
(n-1).times do |i|
  edge << [coord[i+1][1]-coord[i][1],coord[i+1][2],coord[i][2]]
end
edge.sort_by{|i,j,k|i}.each do |i,p,q|
  if morimori[mori[p]].size > morimori[mori[q]].size
    j,k = p,q
  else
    j,k = q,p
  end
  if mori[j] != mori[k]
    morimori[mori[k]].each do |l|
      mori[l] = mori[j]
      morimori[mori[j]] << l
    end
    ans += i
  end
end
p ans


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

int main()
{
	vector<string> S;
	S.resize(3);
	cin >> S[0] >> S[1] >> S[2];
	int n = 0;
	while (1) {
		if (S[n].empty()) break;
		char c;
		c = S[n][0];
		S[n].erase(S[n].begin());

		n = c - 'a';
	}

	if (n == 0)cout << "A" << endl;
	else if (n == 1)cout << "B" << endl;
	else if (n == 2)cout << "C" << endl;

	return 0;
}


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

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> c(2*m);
    vector<bool> done(m, false);
    for(int i=0; i<m; i++) {
        int ai, bi;
        cin >> ai >> bi;
        c[2*i] = make_pair(ai, i+1);
        c[2*i+1] = make_pair(bi, -(i+1));
    }
    sort(c.begin(), c.end());
    int sol = 0;
    stack<int> S;
    for(int i=0; i<2*m; i++){
        if (c[i].second > 0){
            int pos = c[i].second-1;
            S.push(pos);
        }
        else{
            int pos = -c[i].second-1;
            if (!S.empty() && !done[pos]) {
                sol++;
                while(!S.empty()){
                    int s = S.top(); S.pop();
                    done[s] = true;
                }
            }
        }
    }
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 1920
n,t,s,i,j,k[999][25];
main() {
	for(;scanf("%d",&n)*n;){
		memset(k,0,99900);
		for(i=0;i<n;i++){
			scanf("%d%d",&t,&s);
			k[s][i]=t;
		}
		n=0;t=0;
		for(i=0;i<999;i++){
			for(j=0;j<25;j++){
				t+=k[i][j];
				n|=t>i;
			}
		}
		puts(n?"No":"Yes");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if (abs(A-B) <= (V-W)*T) {
        puts("YES");
    }
    else {
        puts("NO");
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t = 1;
    cin >> t;
    while(t--){
       solve();
    }*/
    cout << setprecision(16) << fixed;
    ll w,h,x,y;cin>>w>>h>>x>>y;
    ll ans=0;
    if(x+x == w && y+y == h) ans=1;
    double s=double(w)*double(h)/2;
    cout << s << " " << ans;
}

Measured memory_bytes: 256
N=int(input())
ls=[int(s) for s in input().split()]
ls.append(0)
sumls=[abs(ls[i-1]-ls[i]) for i in range(N+1)]
SUM=sum(sumls)
for i in range(N):
  print(SUM-sumls[i]-sumls[i+1]+abs(ls[i-1]-ls[i+1]))

Measured memory_bytes: 14168
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

vvi G;
vi color;

bool dfs(int v, int col = 0){
  color[v] = col;
  for(auto nv : G[v]){
    // 色確定
    if(color[nv] != -1){
      if(color[nv] == col) return false;
    }
    // 色未確定
    else{
      if(!dfs(nv, 1-col)) return false;
    }
  }
  return true;
}

int main(){
  ll n;
  int m;
  cin >> n >> m;
  G.resize(n);
  rep(i, m){
    int a,b; cin >> a >> b; a--; b--;
    G[a].pb(b); G[b].pb(a);
  }

  color.assign(n,-1);
  bool is_biparticle = dfs(0);
  ll ans;
  if(is_biparticle){
    ll W = 0;
    rep(i, n) W += color[i];
    ll B = n-W;
    ans = B*W - m;
  }
  else{
    ans = n*(n-1)/2 - m;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 6528
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
const int MAX = 300001;
ll MOD=998244353;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(){
	COMinit();
	ll N,A,B;
	ll K;
	scan(N);scan(A);scan(B);scan(K);
	ll sum=0;
	int red=0,blue=N;
	while(1){
		if(A*red+B*blue>K){
			if(blue==0) break;
			else blue--;
		}
		else if(A*red+B*blue<K){
			if(red==N) break;
			else red++;
		}
		else{
			sum+=(COM(N,red)*COM(N,blue))%MOD;
			sum%=MOD;
			if(red==N||blue==0) break;
			else red++;
		}
	}
	prin(sum);
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int k=0;k<n;k++){
    cin >> vec[k];
  }
  int ans = 0;
  int max1 = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      ans = abs(vec[i]-vec[j]);
      max1 = max(max1,ans);
    }
  }
  cout << max1 << endl;
}


Measured memory_bytes: 256
def dot(a, b):
	return a.real*b.real + a.imag*b.imag
	
def norm(a):
	return a.real**2 + a.imag**2
	
def project(line, p):
	base = line[1]-line[0]
	r = dot(p-line[0], base) / norm(base)
	return line[0] + base*r
	
def symmetric_Point(line, p):
	return p + 2*(project(line, p)-p)

while True:
	try: p = list(map(float, input().split(',')))
	except: break
	
	line = []
	line.append(complex(p[0], p[1]))
	line.append(complex(p[2], p[3]))
	pp = complex(p[4], p[5])
	qq = symmetric_Point(line, pp)
	print(qq.real, qq.imag)


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

namespace AGC029B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToList();

            A = A.OrderBy(x => x).ToList();

            var dic = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                if (dic.ContainsKey(A[i])) dic[A[i]]++;
                else dic[A[i]] = 1;
            }

            int[] twoPow = new int[32];
            for (int i = 0; i < 31; i++) twoPow[i] = 1 << i;

            int count = 0;
            for (int j = N - 1; j > 0; j--)
            {
                int last = A[j];

                int pair = -1;
                for (int i = 0; i < 31; i++)
                {
                    if (twoPow[i] > last)
                    {
                        pair = twoPow[i] - last;
                        break;
                    }
                }

                if (!dic.ContainsKey(pair)) continue;

                if (dic[pair] > 0 && dic[last] > 0)
                {
                    if (pair != last)
                    {
                        count++;
                        dic[last]--;
                        dic[pair]--;
                    }
                    else
                    {
                        if (dic[last] >= 2)
                        {
                            count++;
                            dic[last] -= 2;
                        }
                    }
                }
            }

            Console.WriteLine(count);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 44704
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    cout<<v[n/2]-v[n/2-1]<<endl;
    return 0;
}

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

using namespace std;
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define in(x, a, b) a <= x && x < b
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p <<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



const int MAXN = 1000010;



vl fact(MAXN);
vl rfact(MAXN);
ll mod_pow(ll x, ll p, ll M = MOD) {
	ll a = 1;
	while (p) {
		if (p % 2)
			a = a*x%M;
		x = x*x%M;
		p /= 2;
	}
	return a;
}

ll mod_inverse(ll a, ll M = MOD) {
	return mod_pow(a, M - 2, M);
}

void set_fact(ll n, ll M = MOD) {
	fact[0] = fact[1] = rfact[0] = rfact[1] = 1;
	for (ll i = 2; i <= n; i++) {
		fact[i] = i * fact[i - 1] % M;
		rfact[i] = mod_inverse(fact[i], M);
	}
}

ll nCr(ll n, ll r, ll M = MOD) {
	ll ret = fact[n];
	ret = (ret*rfact[r]) % M;
	ret = (ret*rfact[n - r]) % M;
	return ret;
}


int main() {
  ll n;
  cin >> n;
  set_fact(n);
  vl num(n);
  rep1(k, n - 1) {
    if (k - 1 < n - 1 - k) {
      continue;
    }
    num[k] = nCr(k - 1, n - 1 - k);
  }
  vl num2(n);
  rep1(k, n - 1) {
    num2[k] = (num[k]) % MOD * fact[k] % MOD * fact[n - 1 - k] % MOD;
  }
     
  //DEBUG_VEC(num2);
  ll ans = 0;
  rep1(k, n - 1) {
    ans += (num2[k] - num2[k - 1]) % MOD * k % MOD;
    ans %= MOD;
  }
  while (ans < 0) {
    ans += MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 31488
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		int n = Integer.parseInt(br.readLine());
		String[] array = br.readLine().split(" ");
		
		String[] bubbleArray = array.clone();
		bubbleSort(bubbleArray);
		show(array, bubbleArray);
		
		String[] sellectionArray = array.clone();
		selectionSort(sellectionArray);
		show(array, sellectionArray);
		
		
	}
	
	public static void bubbleSort(String[] array){
		int n = array.length;
		for(int i = 0; i < n; i++){
			for(int j = n - 1; i + 1 <= j; j--){
				int jv1 = Integer.valueOf(array[j].charAt(1));
				int jv2 = Integer.valueOf(array[j-1].charAt(1));
				if(jv1 < jv2){
					String v = array[j];
					array[j] = array[j-1];
					array[j-1] = v;
				}
			}
		}
	}
	
	public static void selectionSort(String[] array){
		int n = array.length;
		for(int i = 0; i < n; i++){
			int minj = i;
			int minv = Integer.valueOf(array[minj].charAt(1));
			
			for(int j = i; j < n; j++){
				int jv = Integer.valueOf(array[j].charAt(1));
				
				if(jv < minv){
					minj = j;
					minv = jv;
				}
			}
			
			String v = array[i];
			array[i] = array[minj];
			array[minj] = v;
			
		}
	}

	
	public static boolean isStable(String[] inputArray, String[] sortedArray){
		Map<String, Integer> map = new HashMap<>();
		for(int i = 0; i < inputArray.length; i++){
			map.put(inputArray[i], i);
		}
		String oldStr = null;
		for(String str: sortedArray){
			if(oldStr != null){
				int oldv = Integer.valueOf(oldStr.charAt(1));
				int nowv = Integer.valueOf(str.charAt(1));
				
				if(oldv == nowv && !(map.get(oldStr) < map.get(str))){
					return false;
				}
			}
			
			oldStr = str;
		}
		
		return true;
	}
	
	public static void show(String[] inputArray, String[] sortedArray){
		StringJoiner sj = new StringJoiner(" ");
		Arrays.stream(sortedArray).forEach(v -> sj.add(String.valueOf(v)));
		System.out.println(sj);
		
		if(isStable(inputArray, sortedArray)){
			System.out.println("Stable");
		}else{
			System.out.println("Not stable");
		}
	}
}



Measured memory_bytes: 30780
n = int(input())
a = list(map(int, input().split()))

#単調増加か単調減少かを表す、1で増加、0でどちらでもない、-1で減少
flag = 0
ans = 1
for i in range(n-1):
  #print(a[i+1] - a[i], flag)
  #これまで増加でも減少でもない場合
  if flag == 0:
    if a[i+1] - a[i] > 0:
      #増加
      flag = 1
    elif a[i+1] - a[i] == 0:
      continue
    elif a[i+1] - a[i] < 0:
      # 減少
      flag = -1
  elif flag == 1:
    # これまで非減少だった場合
    if a[i+1] - a[i] >= 0:
      continue
    else:
      ans += 1
      flag = 0
  elif flag == -1:
    #これまで非増加
    if a[i+1] - a[i] <= 0:
      continue
    else:
      ans += 1
      flag = 0
  
print(ans)

Measured memory_bytes: 14436
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();

		// 計算
		String result = "No";
		String[] c = s.split("");
		Arrays.sort(c);
		if(c[0].equals(c[1]) && !c[1].equals(c[2]) && c[2].equals(c[3])) result = "Yes";

		// 出力
		System.out.println(result);
		
	}
}


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

int main() {
    long long x;
    cin >> x;
    long long y = x % 11;
    long long z = (x / 11) * 2;
    if (y == 0) {
        // nop
    } else if (y < 7) {
        z += 1;
    } else {
        z += 2;
    }
    cout << z << endl;
}


Measured memory_bytes: 256
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    a,b,m = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ans = min(a) + min(b)
    for i in range(m):
        x,y,c = map(int,input().split())
        res = a[x-1] + b[y-1] - c
        ans = min(ans,res)
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 18736