akhauriyash/Code-Regression huggingface dataset:
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main(){
int N;
cin>>N;
ll A,B;
cin>>A>>B;
ll ans=0;
ll pre;
cin>>pre;
rep(i,N-1){
    ll X;
    cin>>X;
    ans+=min((X-pre)*A,B);
    pre=X;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3524
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in(), a = in(), b = in(), x = in();
	ll ans = 0;
	REP(i, n - 1) {
		ll nextx = in();
		ans += min(a * (nextx - x), b);
		x = nextx;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
ll n, m, ans, A[101010];
string s;
int main() {
	cin >> s;
	rep(i, 4)
		if (s[i] == '-')
			ans--;
		else
			ans++;
	cout<<ans << endl;
	return 0;
}

Measured memory_bytes: 764
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N, K = list(map(int, input().split()))
    d = {}
    result = {i: False for i in range(N)}
    for k in range(K):
        d = int(input())
        A = list(map(int, (input().split())))
        for a in A:
            result[a-1] = True
    count = 0
    for n in range(N):
        if result[n] == False:
            count += 1
    print(count)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int out=0;
	rep(i,n-1){
		vi a(26),b=a;
		rep(j,n)if(j<=i)a[s[j]-'a']++;
		else b[s[j]-'a']++;
		int c=0;
		rep(j,26)if(a[j]&&b[j])c++;
		out=max(out,c);
	}
	
	cout<<out<<endl;
}










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

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

  std::vector<int> C(N-1), S(N-1), F(N-1);
  for (int i=0; i<N-1; ++i) {
    scanf("%d %d %d", &C[i], &S[i], &F[i]);
  }

  for (int i=0; i<N-1; ++i) {
    int time=0;
    for (int j=i; j<N-1; ++j) {
      if (time <= S[j]) {
        time = S[j];
      } else {
        time = (time+F[j]-1)/F[j]*F[j];
      }

      time += C[j];
    }

    printf("%d\n", time);
  }

  puts("0");
}


Measured memory_bytes: 256
# C XYZ Triplets

n = int(input())

ans = {}
for x in range(1, 99):
  for y in range(1, 99):
    for z in range(1, 99):
      k = (x+y)**2+(y+z)**2+(z+x)**2
      if k > 20000:
        break
      if k % 2 == 0:
        if not k//2 in ans:
          ans[k//2] = 1
        else:
          ans[k//2] += 1

for i in range(1, n+1):
  if i in ans:
    print(ans[i])
  else:
    print(0)


Measured memory_bytes: 9624
#include<iostream>
#include<stdio.h>
using namespace std;

int n;
double rent = 100000;

int main()
	{
		cin>>n;
		for(int i=0;i<n;i++)
		{
		 rent = rent * 1.05 ;
		 if( (int)rent % 1000 >0)
		 	{
		 	rent = rent/1000;
		 	rent = (int)rent;
		 	rent *= 1000;
		 rent = rent + 1000;
		     }

		}
		printf("%.0lf\n",rent);
		return 0;
	}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#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 pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N;
	cin>>N;
	bool isodd = 0;
	rep(i,N){
		int x;
		cin>>x;
		if(x%2==1) isodd = 1;
	}
	if(isodd) puts("first");
	else puts("second");
}

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

int main(void) {
    ll K;
    cin >> K;

    ll ans = 0;
    bool flg = true;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                int tmp = __gcd(i, j);
                ans += __gcd(tmp, k);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    a,b,c,d = MI()
    ans = max(a*c, a*d, b*c, b*d)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 67964
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int_;
inline int readint() {
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0' or c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c and c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}
void writeint(int_ x){
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) writeint(x/10);
	putchar((x%10)^48);
}
# define MB template < typename T >
MB void getMax(T &a,const T &b){ if(a < b) a = b; }
MB void getMin(T &a,const T &b){ if(b < a) a = b; }
# define FOR(i,n) for(int i=0; i<(n); ++i)

int ans, x[11], n, m, q;
int a[51], b[51], c[51], d[51];
void check(){
	int now = 0;
	for(int i=1; i<=q; ++i)
		if(x[b[i]]-x[a[i]] == c[i])
			now += d[i];
	getMax(ans,now);
}
void dfs(int t){
	if(t > n) return check();
	for(int i=x[t-1]; i<=m; ++i)
		x[t] = i, dfs(t+1);
}

int main(){
	n = readint(), m = readint(), q = readint();
	for(int i=1; i<=q; ++i){
		a[i] = readint();
		b[i] = readint();
		c[i] = readint();
		d[i] = readint();
	}
	x[0] = 1, dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct V {
    bool operator<(const V &v) const {
        return i < v.i;
    }
    int i, d, l;
};
vector<vector<V>> et;
int et_i;
vector<int> v2et;

struct Graph {
    struct Vertex { int n, d, l; };
    struct Edge { int i, n, c, l; };
    Graph(int n, int m) : v(n, { -1, 0, 0 }), e(m), n(n), m(0), l(1) {
        while (n > 1 << l) l++;
    }
    void add_edge(int i, int j, int c, int d) {
        e[m] = { j, v[i].n, c, d };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p, int d, int l) {
        v[i].d = d;
        v[i].l = l;
        par[0][i] = p;
        v2et[i] = et_i - 1;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            auto v0 = et[o.c].back();
            et[o.c].push_back({ et_i++, v0.d + 1, v0.l + o.l });
            dfs(o.i, i, d + 1, l + o.l);
            et[o.c].push_back({ et_i++, v0.d, v0.l });
        }
    }
    void doubling() {
        par = vector<vector<int>>(l, vector<int>(n));
        dfs(0, 0, 0, 0);
        for (int k = 0; k < l - 1; k++) {
            for (int i = 0; i < n; i++) {
                par[k + 1][i] = par[k][par[k][i]];
            }
        }
        //par[k][i]はiの2^k個上のノード
    }
    int lca(int i, int j) {
        int d = v[i].d - v[j].d;
        if (d < 0) d *= -1, swap(i, j);
        if (d) {
            for (int k = l - 1; k >= 0; k--) {
                if (d & 1 << k) i = par[k][i];
            }
        }
        if (i == j) return i;
        for (int k = l - 1; k >= 0; k--) {
            if (par[k][i] == par[k][j]) continue;
            i = par[k][i];
            j = par[k][j];
        }
        return par[0][i];
    }
    int query(int x, int y, int i, int j) {
        int k = lca(i, j);
        int l = v[i].l + v[j].l - 2 * v[k].l;
        auto vi = upper_bound(et[x].begin(), et[x].end(), V{ v2et[i], 0, 0 })[-1];
        auto vj = upper_bound(et[x].begin(), et[x].end(), V{ v2et[j], 0, 0 })[-1];
        auto vk = upper_bound(et[x].begin(), et[x].end(), V{ v2et[k], 0, 0 })[-1];
        l -= vi.l + vj.l - 2 * vk.l;
        l += (vi.d + vj.d - 2 * vk.d) * y;
        return l;
    }
    vector<Vertex> v;
    vector<Edge> e;
    vector<vector<int>> par;
    int n, m, l;
};

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

    int n, q;
    cin >> n >> q;

    et = vector<vector<V>>(n - 1, vector<V>(1, { 0, 0, 0 }));
    et_i = 1;
    v2et = vector<int>(n);

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        c--;

        g.add_edge(a, b, c, d);
        g.add_edge(b, a, c, d);
    }
    g.doubling();

    for (int h = 0; h < q; h++) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        u--; v--;
        x--;

        cout << g.query(x, y, u, v) << '\n';
    }

    return 0;
}

Measured memory_bytes: 24692
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif

int main()
{
    vector<int> A(3);
    for (auto &a : A)
        cin >> a;
    Dumps(A);

    auto cost = [&]() -> int
    {
        int c = 0;
        for (int i = 1; i < A.size(); ++i)
            c += abs(A[i] - A[i - 1]);
        return c;
    };

    vector<int> C;
    do
    {
        C.push_back(cost());
    }
    while (next_permutation(A.begin(), A.end()));

    Dumps(C);
    cout << (*min_element(C.begin(), C.end())) << endl;
}


Measured memory_bytes: 256
/**
 *    Created By:  PeekyBlinders
 **/
#include <bits/stdc++.h>

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

const int mod = (int) 1e9 + 7;

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

signed main() {
    fio;
    int n; cin >> n;
    map<int , int> max_cnt;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        int cur = a[i];
        for(int p = 2; p * p <= a[i]; p++) {
            if(cur % p == 0) {
                int cc = 0;
                while(cur % p == 0) {
                    cur /= p;
                    cc++;
                }
                max_cnt[p] = max(max_cnt[p] , cc);
            }
        }
        if(cur > 1) {
            max_cnt[cur] = max(max_cnt[cur] , 1LL);
        }
    }
    
    int answer = 0 , L = 1;
    for(pair<int , int> it : max_cnt) {
        L = mul(L , binpow(it.first , it.second));
    }
    for(auto it : a) answer = add(answer , mul(L , inv(it)));
    
    cout << answer << endl;
    
 
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;
    import java.math.BigDecimal;
     
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String a = sc.next();
            String b = sc.next();
            BigDecimal b1 = new BigDecimal(a);
            BigDecimal b2  = new BigDecimal(b);
             BigDecimal c = b1.multiply(b2);
             BigDecimal d = c.setScale(0,BigDecimal.ROUND_DOWN);
            System.out.println(d);
        }
    }

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

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(int argc, const char * argv[]) {
    ll A,B;
    cin >> A >> B;
    cout << A*B<< endl;
}




Measured memory_bytes: 3568
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	int A[3], K;
	cin >> A[0] >> A[1] >> A[2] >> K;
	sort(A, A + 3);
	cout << A[0] + A[1] + A[2] * pow(2, K) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<string> ss;
    int n;
    cin>>n;
    string s[n];
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        cin>>a[i];
        ss.insert(s[i]);
    }
    int maxi,maxs=0,pp=0;
    set <string> :: iterator itr;
    for(itr=ss.begin();itr!=ss.end();++itr)
    {
        for(int j=0;j<n;j++)
        {
            maxs=0;
            pp=0;
            for(int i=0;i<n;i++)
            {
                if(s[i]==*itr)
                {
                    if(maxs<=a[i])
                    {
                        pp=1;
                        maxs=a[i];
                        maxi=i;
                    }
                }
            }
            s[maxi]="123";
            if(pp==1)
            {
                cout<<maxi+1<<endl;
                pp=0;
            }

        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+9;
int n,x,d;
ll sum[N];
#define P pair<ll,ll>
map<int,vector<P> >mp;
int main(){
  for(int i=1;i<N;i++)sum[i]=sum[i-1]+i;
  cin>>n>>x>>d;
  if(d==0){
    if(x==0)cout<<1<<endl;
    else cout<<n+1<<endl;
    return 0;
  }
  if(d<0)x=-x,d=-d;
  for(int i=0;i<=n;i++){
    ll l=sum[i-1],r=sum[n-1]-sum[max(n-i-1,0)];
    ll t=1ll*i*x;
    l+=t/d,r+=t/d;t%=d;
    if(t<0)t+=d,l--,r--;
    mp[t].push_back(P(l,r));
  }
  ll ans=0;
  for(auto u:mp){
    sort(u.second.begin(),u.second.end());
    ll l=u.second[0].first,r=u.second[0].second;
    for(auto v:u.second){
      if(v.first<=r)r=max(r,v.second);
      else ans+=(r-l+1),l=v.first,r=v.second;
    }
    ans+=(r-l+1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 23808
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> as = vector<int>(A + 1, 0);
  vector<int> bs = vector<int>(B + 1, 0);

  ll minA = INF;
  for (int i = 1; i <= A; i++) {
    int a;
    cin >> a;
    chmin(minA, a);
    as[i] = a;
  }

  ll minB = INF;
  for (int i = 1; i <= B; i++) {
    int b;
    cin >> b;
    chmin(minB, b);
    bs[i] = b;
  }

  ll min = INF;
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    ll sum = as[x] + bs[y] - c;
    chmin(min, sum);
  }

  chmin(min, (minA + minB));

  cout << min << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
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<int> c(n+1, 0);

  for(int i = 2; i <= n; i++) {
    int k = i;
    for(int j = 2; j <= i; j++) {
      while(k % j == 0) {
        c[j]++;
        k /= j;
      }
    }
  }

  int ans = 0;
  int k_2 = 0, k_4 = 0, k_14 = 0, k_24 = 0, k_74 = 0;
  for(int i : c) {
    if(i >= 2) k_2++;
    if(i >= 4) k_4++;
    if(i >= 14) k_14++;
    if(i >= 24) k_24++;
    if(i >= 74) k_74++;
  }
  ans += k_4*(k_4-1)*(k_2-2)/2;
  ans += k_24*(k_2-1);
  ans += k_14*(k_4-1);
  ans += k_74;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A_l = []
for i in range(N):
    A_l.append(int(input()))
    
A_max = max(A_l)
A_tmp = A_l.copy()
A_tmp.remove(A_max)
A_second = max(A_tmp)
for j in range(N):
    if A_l[j] != A_max:
        print(A_max)
    else:
        print(A_second)

Measured memory_bytes: 14080
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
int dist2(int x,int y){
  return x*x + y*y;
}
int main(){
  int N, M;
  int R;
  while(cin>>N>>M>>R && N){
    R *= 4;
    vector<int> combat[10000];
    REP(i, N){
      int x, y; scanf("%d %d", &x, &y);
      combat[x].push_back(y);
    }
    REP(i, 10000)sort(combat[i].begin(), combat[i].end());
    int ans = 0;
    REP(i, M){
      int x, y; scanf("%d %d", &x, &y);
      for(int xx = max(x-R, 0); xx <= min(x + R, 9999); xx++){
        int dx = xx - x;
        vector<int>::iterator b = lower_bound(combat[xx].begin(), combat[xx].end(), y - sqrt(R*R - dx*dx) - 1);
        vector<int>::iterator e = upper_bound(combat[xx].begin(), combat[xx].end(), y + sqrt(R*R - dx*dx)  + 1);
        while(b != e){
          int yy = *b;
          if(dist2(x-xx, y-yy) <= R * R) ans++;
          b++;
        }
      }
    }
    cout<< ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 200010;
const int INF = INT_MAX/2;
const int mod = 1e9 + 7;

int n, k;
int A[maxn];

void mul(int &a, int b) {
	a *= b;
	if (a < 0) a += mod;
	a %= mod;
}

int32_t main(){
	FAST
	//ifstream cin("random_max01.txt");
	cin >> n >> k;
	
	for (int i =0;i<n;i++) {
		cin >> A[i];
	}

	sort(A,A+n);
	int ans = 1;

	if (A[n-1] <= 0 and k % 2 == 1) {
		for (int i =n-1; i > n-1-k; i--) {
			mul(ans,A[i]);
		}
		//ans = (ans + mod) % mod;
		cout << ans;
		return 0;
	}
	
	int l = 0, r = n-1;
	
	if (k % 2 == 1) {
		mul(ans,A[r]);
		r--;
		k--;
	}
	
	for (int x = 0; x < k / 2; x++) {
		int lowest = A[l] * A[l+1], highest = A[r] * A[r-1];
		if (lowest > highest) {
			mul(ans,lowest%mod);
			l += 2;
		} else {
			mul(ans,highest%mod);
			r -= 2;
		}
		ans = (ans + mod) % mod;
	}

	cout << ans%mod;
	
}









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

int n;
std::vector<std::pair<std::string,int>> p;
std::unordered_map<int,int> um;

void input(){
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::string a;
        int b;
        std::cin>>a>>b;
        p.push_back(std::make_pair(a,-b));
        um[-b] = i+1;
    }
}


int main()
{
    input();
    std::sort(p.begin(),p.end());
    for(auto i : p){
        std::cout<<um[i.second]<<std::endl;
    }

}

Measured memory_bytes: 384
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n - 2):
    for j in range(n):
        if i + j*2 < n:
            if s[i] != s[i + j]:
                if s[i] != s[i + j*2]:
                    if s[i + j] != s[i + j*2]:
                        ans -= 1
        else:
            break

print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
const int mod = 1000000007;
const int N = 1e5+5, M = N;
//=========================================

int h[N];
int dp[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> h[i];

    memset(dp, 0, sizeof(dp));

    dp[2] = abs(h[2] - h[1]);

    for(int i = 3; i <= n; ++i){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for (int i=0;i<s.size();i++){
    if (s[i]=='1') s[i]='9';
    else if (s[i]=='9') s[i]='1';
  }
  cout << s << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  100012101;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
 


int main(){
ll ans=0;
ll N,K;
cin>>N>>K;
rep4(i,K,N+1){
    ans+=N*(N+1)/2-(N-i+1)*(N-i)/2-i*(i-1)/2+1;
    ans%=(ll)powl(10,9)+7;
}
cout<<ans<<endl;
return 0;
}

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

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

int main(){
  
 long long int a,b,c[100010],d;
  cin >>a >>b;
  d = 1e9;
 for(int i=0;i<a;i++)
  cin >> c[i];
  d =c[0]-b;
  for(int i=0;i<a;i++){
    d = gcd(d,abs(c[i]-b));
  }
  
  cout << d << endl;
   
   return 0;
 }
 



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vll a(n), b(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
    cin >> b[i];
  vll c;
  ll sum = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      c.push_back(a[i] - b[i]);
    } else if (a[i] < b[i]) {
      ans++;
      sum += b[i] - a[i];
    }
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  int id = 0;
  while (sum > 0 && id < c.size()) {
    sum = max(0ll, sum - c[id]);
    id++;
    ans++;
  }
  if (sum > 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2428
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for (int i = 0; i < n; ++i) {
			int count = 1;
			int y = s.nextInt(), m = s.nextInt(), d = s.nextInt();
			count += ((y % 3 < 1 || m % 2 > 0) ? 20 : 19) - d;

			count += 20 * ((10 - m) / 2);
			count += (y % 3 < 1 ? 20 : 19) * ((10 - m + 1)/ 2);

			for (++y; y < 1000; ++y) {
				count += (y % 3 < 1) ? 200 : 195;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 20792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;

#define sz(a) ((int)a.size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i : (a))
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vl> vvvl;
typedef double T;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int, int> tiiii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9+7; // 998244353;
const ll INF = 1e16+1;

void solve_test() {
  int n, w;
  cin >> n >> w;
  vector<int> values(n), weights(n);
  int max_value = 0;
  for (int i = 0; i < n; ++i) {
    cin >> weights[i] >> values[i];
    max_value += values[i];
  }

  vector<vector<int>> min_weight(n+1, vector<int>(max_value + 1, w+1));
  min_weight[0][0] = 0;

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = max_value; j >= 0; --j) {
      min_weight[i+1][j] = min_weight[i][j];
      if (j < max_value) {
        min_weight[i+1][j] = min(min_weight[i+1][j], min_weight[i+1][j+1]);
      }
      if (j >= values[i]) {
        min_weight[i+1][j] = min(min_weight[i+1][j], min_weight[i][j-values[i]] + weights[i]);
      }
      if (min_weight[i+1][j] <= w) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans << endl;
}

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

  int t = 1;
  // cin >> t;
  for (int i = 1; i <= t; ++i) {
    solve_test();
  }
}


Measured memory_bytes: 40192
from itertools import accumulate

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

A=[0]+list(accumulate(A))
ans=A[N]
for j in range(2,N-1):
    S=A[j]-A[0]
    start=1
    end=j-1
    while end-start>1:
        t=(end+start)//2
        if S>=2*A[t]:
            start=t
        else:
            end=t
    i1=start
    i2=end

    T=A[N]-A[j]
    start=j+1
    end=N-1
    while end-start>1:
        t=(end+start)//2
        if T>=2*(A[t]-A[j]):
            start=t
        else:
            end=t

    k1=start
    k2=end

    data=[A[N]-A[k1],A[k1]-A[j],A[j]-A[i1],A[i1]-A[0]]
    test1=max(data)-min(data)

    data=[A[N]-A[k2],A[k2]-A[j],A[j]-A[i1],A[i1]-A[0]]
    test2=max(data)-min(data)

    data=[A[N]-A[k1],A[k1]-A[j],A[j]-A[i2],A[i2]-A[0]]
    test3=max(data)-min(data)

    data=[A[N]-A[k2],A[k2]-A[j],A[j]-A[i2],A[i2]-A[0]]
    test4=max(data)-min(data)

    ans=min(ans,test1,test2,test3,test4)

print(ans)

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

int main() {
  int n;
  while(cin >> n) {
    int num = 0;
    for(int a = 0; a <= 9; ++a) {
      for(int b = 0; b <= 9; ++b) {
	for(int c = 0; c <= 9; ++c) {
	  for(int d = 0; d <= 9; ++d) {
	    if(a+b+c+d == n) ++num;
	  }
	}
      }
    }
    cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.ComponentModel;
using System.Windows.Markup;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            while (true)
            {
                string ff = Console.ReadLine();
                string[] gg = ff.Split(new char[] { ' ' });
                int a = int.Parse(gg[0]);
                int b = int.Parse(gg[2]);
                char op = Convert.ToChar(gg[1]);
                if (op == '?')
                {
                    break;
                }
                else if (op == '+')
                {
                    int c = a + b;
                    Console.WriteLine("{0}", c);
                }
                else if (op == '-')
                {
                    int c = a - b;
                    Console.WriteLine("{0}", c);
                }
                else if (op == '*')
                {
                    int c = a * b;
                    Console.WriteLine("{0}", c);
                }
                else if (op == '/')
                {
                    int c = a / b;
                    Console.WriteLine("{0}", c);
                }
                i++;
            }
        }
    }
}


Measured memory_bytes: 18024
// 2014/05/20 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	while(true){
		char r[5], a[5];
		cin >> r >> a;

		if(strcmp(r, "0")==0 && strcmp(a, "0")==0)
			break;

		int h = 0, b = 0;

		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(r[i]==a[j]){
					if(i==j){
						h++;
					}
					else{
						b++;
					}
				}
			}
		}

		cout << h << ' ' << b << '\n';
	}

	return 0;
}

Measured memory_bytes: 1144
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		var w = ss.Next<int>();
		var h = ss.Next<int>();
		var x = ss.Next<int>();
		var y = ss.Next<int>();
		var r = ss.Next<int>();
		if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}



public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9908
#include <iostream>
#include <algorithm>

int main()
{
    using namespace std;
        int max = 0;
        int second = 0;
        int third = 0;
    
    int n[10];
    
    for(int i = 0; i < 10; i++) cin >> n[i];
    sort(n,n+10,greater<int>());
    max = n[0];
    second = n[1];
    third  = n[2];
    cout << max << "\n" << second << "\n" << third << "\n";
    return 0;
}

Measured memory_bytes: 1180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

#define int long long

const int mod = 1e9 + 7;

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

#define int long long

const int N = 2e5 + 5;
ll d1[N], d2[N];
ll pre_d1[N], pre_d2[N];

void solve() {
	int L, n;
	cin >> L >> n;
	for(int i = 1; i <= n; i++) {
		cin >> d1[i];
		d2[i] = L - d1[i];
	}
	reverse(d2 + 1, d2 + n + 1);
	for(int i = 1; i <= n; i++) {
		pre_d1[i] = pre_d1[i - 1] + d1[i];
	}
	for(int i = 1; i <= n; i++) {
		pre_d2[i] = pre_d2[i - 1] + d2[i];
	}
	ll ans = 0;
	for(int c1 = 0; c1 <= n; c1++) {
		int c2 = n - c1;
		if(c1 == 0 || c1 == n) {
			ans = max(ans, d1[c1] + d2[c2]);
			continue;
		}
		for(int i = 0; i < 2; i++) {
			int cc1 = c1, cc2 = n - c1;
			ll val = 0;
			if(i == 0 && !cc1) continue;
			if(i == 1 && !cc2) continue;
			if(i == 0) val += d1[cc1--];
			else val += d2[cc2--];
			int cnt1 = 0, cnt2 = 0;
			if(cc1 == cc2) {
				cnt1 = cc1, cnt2 = cc2;
			}
			else if(i == 0) {
				if(cc1 < cc2) {
					cnt1 = cc1, cnt2 = cc1 + 1;
				}
				else {
					cnt1 = cc2, cnt2 = cc2;
				}
			}
			else {
				if(cc1 < cc2) {
					cnt1 = cc1, cnt2 = cc1;
				}
				else {
					cnt1 = cc2 + 1, cnt2 = cc2;
				}
			}
			val += 2 * (pre_d1[cc1] - pre_d1[cc1 - cnt1] + pre_d2[cc2] - pre_d2[cc2 - cnt2]);
			ans = max(ans, val);
		}
	}
	// print(pre_d1 + 1, pre_d1 + n + 1);
	// print(pre_d2 + 1, pre_d2 + n + 1);
	cout << ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6528
A, B, C = [int(i) for i in input().split()]

count = 0
pA, pB, pC = 0, 0, 0
while all(d % 2 == 0 for d in [A, B, C]):
    A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2

    if set([pA, pB, pC]) == set([A, B, C]):
        print(-1)
        quit()

    pA, pB, pC = A, B, C
    count += 1
print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;

void solve(){
    int n;
    cin >> n;
    vector <ll> a(n);
    for(ll & x : a)
        cin >> x;
    
    sort(all(a));
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            for(int k = j + 1; k < n; ++k) {
                set <ll> s;
                s.ins(a[i]);
                s.ins(a[j]);
                s.ins(a[k]);
                if(a[k] < a[i] + a[j] && s.size() == 3) {
                    ++ans;
                }
                
            }
        }
    }
    cout << ans << '\n';
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	if(s == "SUN") cout << "7\n";
	else if(s == "MON") cout << "6\n";
	else if(s == "TUE") cout << "5\n";
	else if(s == "WED") cout << "4\n";
	else if(s == "THU") cout << "3\n";
	else if(s == "FRI") cout << "2\n";
	else if(s == "SAT") cout << "1\n";

	return 0;
}

Measured memory_bytes: 256
def fib(n):
    a = 1
    b = 0
    i = 0
    while i < n:
        i += 1
        c = a + b
        yield c
        a = b
        b = c


def main():
    h, w, k = map(int, input().split())
    mod = 10 ** 9 + 7
    
    dp = [[0] * (w + 2) for _ in range(h + 1)]
    dp[0][1] = 1
    c = [i for i in fib(w + 1)]

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            x = c[j - 1] * c[w - j]
            y = c[j - 1] * c[w - j - 1]
            z = c[j - 2] * c[w - j]

            dp[i][j] = (x * dp[i - 1][j] + y * dp[i - 1][j + 1] + z * dp[i - 1][j - 1]) % mod

    print(dp[h][k])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<bool> prime_table(int n) {
    vector<bool> prime(n + 1, true);
    if (n >= 0) prime[0] = false;
    if (n >= 1) prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i]) continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

void solve() {
    int x;
    cin >> x;
    auto P = prime_table(202020);
    while(1) {
        if (P[x]) {
            cout << x << endl;
            return;
        } else {
            x++;
        }
    }
}

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


Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
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());
		Deque<Integer> deque = new ArrayDeque<>();
		
		for(int i = 0; i < n; i++){
			String[] strs = br.readLine().split(" ");
			String command = strs[0];
			int num = 0;
			if(strs.length == 2){
				num = Integer.parseInt(strs[1]);
			}
			
			switch (command) {
			case "insert":
				deque.offerFirst(num);
				break;
			case "delete":
				deque.remove(num);
				break;
			case "deleteFirst":
				deque.removeFirst();
				break;
			case "deleteLast":
				deque.removeLast();
				break;
			}
		}
		
		StringJoiner sj = new StringJoiner(" ");
		deque.forEach(s -> sj.add(String.valueOf(s)));
		System.out.println(sj);
	}
}



Measured memory_bytes: 191376
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = int(readline())
print(sum(len(str(x)) % 2 == 1 for x in range(1, S + 1)))



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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int A, B, C;
    cin >> A >> B >> C;

    string ans;

    if(A+B+C>=22){
        ans = "bust";
    }
    else{
        ans = "win";
    }

    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int N;
int main() {
	cin >> N;
	vector<string>key(N);
	for (int i = 0; i < N; ++i) {
		string a; cin >> a;
		key[i] = a;
	}
	for (int i = 0; i < N; ++i)sort(key[i].begin(), key[i].end());
	map<string, int>ma;
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		if (ma[key[i]] > 0) {
			ans += ma[key[i]];
		}
		ma[key[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	string s;
	cin>>s;
	int count=0;
	for(int i=0;i<s.size();i++)
	 {
	 	 if(s[i]=='2')
	 	   {
			++count;	 	   	
	 	   }
	 }
	 cout<<count<<'\n';
	// your code goes here
	return 0;
}

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

using namespace std;

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

int main() {
    ll n, m, i, j, k, sum = 0;
    cin >> n;
    vector<ll> v(n + 2), t(n + 2);
    t[0] = 0;
    for(i = 1; i <= n; i++) {
        cin >> t[i];
        t[i] *= 2;
        sum += t[i];
		t[i]=sum;
    }
    v[0] = 0;
    for(i = 1; i <= n; i++) {
        cin >> v[i];
        v[i] *= 2;
    }
    double train[200100]; // train[time]
    for(i = 0; i <= sum; i++)
        train[i] = 1000.0;
    for(i = 1; i <= n; i++) {
        for(j = 0; j <= sum; j++) {
            double f;
            if(j < t[i - 1])
                f = v[i] + t[i - 1] - j;
            else if(j <= t[i])
                f = v[i];
            else
                f = v[i] + j - t[i];
            train[j] = min(train[j], f);
        }
    }
    for(j = 0; j <= sum; j++) {
        train[j] = min(train[j], (double)j);
        train[j] = min(train[j], (double)sum - j);
    }

    double ret = 0;
    for(i = 1; i <= sum; i++) {
        ret += (train[i] + train[i - 1]) / 8;
    }
	printf("%.13f\n",ret);
    /*
	cout << ret << endl;
    
	for(i = 0; i <= sum; i++) {
        cout << train[i] << " ";
    }
    cout << endl;
	cout << sum << endl;
	*/
    return 0;
}

Measured memory_bytes: 512