akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll n;
  cin>>n;
  V<ll> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  ll c=n*(n+1)/2;
  if(sum%c!=0){
    cout<<"NO"<<"\n";
    return 0;
  }
  if(n==1){
      cout<<"YES"<<"\n";
      return 0;
  }
  ll cnt=0;
  for(int i=0;i<n;i++){
    if(a[(i+1)%n]-a[i]<0){
        cnt+=(abs(a[(i+1)%n]-a[i])+n-2)/(n-1);
    }
  }
  sum-=cnt*c;
  sum/=n;
  if(sum%c==0)cout<<"YES"<<"\n";
  else cout<<"NO"<<"\n"; 
}

Measured memory_bytes: 3984
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

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

    vector<vector<ll>> d(c, vector<ll>(c, 0));
    for(int i = 0; i < c; ++i){
        for(int j = 0; j < c; ++j){
            cin >> d.at(i).at(j);
        }
    }

    vector<vector<ll>> cost(3, vector<ll>(c, 0));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            const int m = (i + j + 2) % 3;
            ll cij;
            cin >> cij;
            for(int x = 0; x < c; ++x){
                cost.at(m).at(x) += d.at(cij - 1).at(x);
            }
        }
    }

    ll ans = 1000 * 500 * 500;
    for(int c1 = 0; c1 < c; ++c1){
        for(int c2 = 0; c2 < c; ++c2){
            if(c1 == c2){ continue; }
            for(int c3 = 0; c3 < c; ++c3){
                if(c1 == c3 || c2 == c3){ continue; }
                ll tmp = cost.at(0).at(c1) + cost.at(1).at(c2) + cost.at(2).at(c3);
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())

L_2 = 2
L_1 = 1

if N == 1:
    print(1)
    exit(0)

i = 1
while i < N:
    L = L_1 + L_2
    L_2 = L_1
    L_1 = L
    i += 1
print(L)

Measured memory_bytes: 2940
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                      
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, h[N], a[N], dp[N], t[N];

void inc (int pos, int x) {
	while (pos < N) {
		t[pos] = max(t[pos], x);
		pos |= pos + 1;
	}
}

int get (int r) {
	int res = 0;
	while (r >= 0) {
		res = max(res, t[r]);
		r = (r & (r + 1)) - 1;
	}
	return res;
}


main () {
	cin >> n;
	forn (i, 1, n)
		cin >> h[i];

	forn (i, 1, n)
		cin >> a[i];

	forn (i, 1, n) {
		dp[i] = get(h[i]) + a[i];
		inc(h[i], dp[i]);
	}

	cout << *max_element(dp + 1, dp + 1 + n);
}

    

Measured memory_bytes: 6528
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    H = list(map(int, input().split()))

    ans = 0
    now = 0
    for i in range(N):
        if i + 1 < N and H[i + 1] <= H[i]:
            now += 1
            ans = max(ans, now)
        else:
            now = 0

    print(ans)

sol()

Measured memory_bytes: 16424
import sys
sys.setrecursionlimit(10**9)


N, M = map(int, input().split())
to = [[] for _ in range(N)]
count = 0

for _ in range(M):
    A, B = map(lambda x:int(x) - 1, input().split())
    to[A].append(B)
    to[B].append(A)


def dfs(v, to, seen):
    global count
    seen[v] = True
    count += 1
    for nv in to[v]:
        if seen[nv]:
            continue
        dfs(nv, to, seen)


def main():
    global count
    ans = 0
    seen = [False] * N
    for i in range(N):
        if not seen[i]:
            dfs(i, to, seen)
            ans = max(ans, count)
            count = 0
    
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 221916
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

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

	int result = H * W + h * w - (H * w) - (h * W);
	cout << result << endl;

	return 0;
}

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

int main(void)
{
	int X, XXX;
	cin >> X;
	XXX = X;
	int fX = 0;
	while (true) {
		int XX = X;
		XX -= int(X / 10) * 10;
		fX += XX;
		X = int(X / 10);
		if (X == 0)	break;
	}

	if (XXX % fX == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

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

long long n, ans;

int main() {
  cin >> n;
  ans = (n+2)*(n+1)*(n)/6;
  for(int i = 0; i < n-1; ++i) {
    int u, v;
    cin >> u >> v;
    if(u > v) swap(u, v);
    ans -= u*(n+1-v);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3644
import heapq

N, M = map(int, input().split())
A = [int(i) * (-1) for i in input().split()]
heapq.heapify(A)
while M > 0:
    X = heapq.heappop(A) * (-1)
    X //= 2
    heapq.heappush(A, X * (-1))
    M -= 1
ans = sum(A) * (-1)
print(ans)


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(f, c, ...)                                           \
  (([&](decltype((c)) cccc) {                                    \
    return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); \
  })(c))
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int n, r;
  cin >> n >> r;
  cout << (10 <= n ? r : r + (100 * (10 - n))) << endl;
}

signed main() {
  solve();

  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 071_arc_b / Link: https://abc058.contest.atcoder.jp/tasks/arc071_b?lang=en  ----- */
/* ------問題------

2 次元平面上に x 軸と平行な直線が m 本と y 軸と平行な直線が n 本引いてあります。 x 軸と平行な直線のうち下から i 番目は y=yi で表せます。 y 軸と平行な直線のうち左から i 番目は x=xi で表せます。
この中に存在しているすべての長方形についてその面積を求め、 合計を 109+7 で割ったあまりを出力してください。

つまり、1≤i<j≤n と 1≤k<l≤m を満たすすべての組 (i,j,k,l) について、 直線 x=xi, x=xj, y=yk, y=yl で囲まれる 長方形の面積を求め、合計を 109+7 で割ったあまりを出力してください。

-----問題ここまで----- */
/* -----解説等-----

式を書くと2i-(N+1)回,a_iが呼ばれるので適当にやる

----解説ここまで---- */

LL H,W;

LL ans = 0LL;

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

	cin >> W >> H;
	VL x(W);
	FOR(i, 0, W) {
		cin >> x[i];
	}
	VL y(H);
	FOR(i, 0, H) {
		cin >> y[i];
	}

	LL xsum = 0, bef;
	FOR(i, 1, W) {
		(xsum += bef) %= MOD;
		(xsum += (x[i] - x[i - 1])*i % MOD) %= MOD;
		(bef += (x[i] - x[i - 1])*i % MOD) %= MOD;
	}
	bef = 0;
	LL ysum = 0;
	FOR(i, 1, H) {
		(ysum += bef) %= MOD;
		(ysum += (y[i] - y[i - 1])*i % MOD) %= MOD;
		(bef += (y[i] - y[i - 1])*i % MOD) %= MOD;
	}
	ans = (xsum*ysum) % MOD;

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1792
N = input()
A = map(int,raw_input().split())
print ' '.join(map(str,A))
for j in range(1,N):
    key = A[j]
    i = j - 1
    while i >= 0 and A[i] > key:
       A[i+1] = A[i]
       i -= 1
    A[i+1] = key
    print ' '.join(map(str,A))

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
    ll a, b, c, k;cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
    }
    if(a <  k&&k  <= a+b){
        cout << a  <<  endl;
    }
    if(a+b < k && k<= a + b +c){
        cout << a - (k-a-b) << endl;
    }
}


Measured memory_bytes: 3604
// 1_1_C
#include <stdio.h>
#include <math.h>

int is_prime(long);

int main(){
    int n, i, cnt = 0;
    long number;
    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%ld", &number);
        if(is_prime(number) == 0){
            cnt += 1;
        }
    }

    printf("%d\n", cnt);
    return 0;
}

int is_prime(long number){
    if(number == 2) return 0;
    if(number % 2 == 0) return 1;

    long divisor;
    for(divisor = 3; divisor <= sqrt(number); divisor += 2){
        if(number % divisor == 0) return 1;
    }
    return 0;
}

Measured memory_bytes: 596
N, *XY = map(int, open(0).read().split())
X, Y = XY[::2], XY[1::2]
XtoY = [0] * (N+1)
for x, y in zip(X,Y):
  XtoY[x] = y

ans = [0] * (N+1)
l = 1
min_y = N + 1
for x in range(1, N+1):
  min_y = min(min_y, XtoY[x])
  if x + min_y == N+1:
    for i in range(l, x+1):
      ans[i] = x - l + 1
    l, min_y = x+1, N+1

for x in X:
  print(ans[x])

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  vector<char> v;

  rep(i, s.length()) {
    if (s[i] == '0') v.push_back('0');
    if (s[i] == '1') v.push_back('1');
    if (s[i] == 'B' && v.size() > 0) v.erase(v.end() - 1);
  }

  for (int i = 0; i < v.size(); ++i) {
    cout << v[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

struct UnionFind {
  vector< int > data;

  UnionFind() = default;

  explicit UnionFind(size_t sz) : data(sz, -1) {}

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return data[k] = find(data[k]);
  }

  int size(int k) {
    return -data[find(k)];
  }

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


int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    UnionFind uf(N+1);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        uf.unite(A[i],B[i]);
    }
    ll ret=0;
    for (long long i = 1; i <= N; i++) {
        // debg(uf.size(i));
        chmax(ret, (ll)uf.size(i));
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 7228
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    a=int(input())
    s=input()
    if(a>=3200):
        print(s)
    else:
        print("red")
resolve()

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  vector<int> b(100);
  for(int i=0;i<100;i++){
    int k = i+1;
    for(int j=0;j<n;j++){
      b.at(i) += (k -a.at(j))*(k - a.at(j));
    }
  }
  sort(b.begin(),b.end());
  cout << b.at(0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 200020
#define ll long long
int i,j,k,m,n,x,y,t[N],a[N],sum[N];
inline ll ask(int x) {
    ll ans = 0;
    for (; x; x -= x & -x)ans += t[x];
    return ans;
}
inline void add(int x) {
    for (; x < N; x += x & -x)++t[x];
}
inline bool check(int x) {
    ll ans = 0;
    memset(t, 0, sizeof(t));
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; ++i)sum[i] = sum[i - 1] + ((a[i] <= x) ? 1 : -1);
    for (int i = 0; i <= n; ++i)sum[i] += n + 1;
    for (int i = 0; i <= n; ++i)ans += ask(sum[i] - 1), add(sum[i]);
    return ans >= 1ll * n * (n + 1) / 4 + 1;
}
int main() {
    for (scanf("%d", &n), i = 1; i <= n; ++i)scanf("%d", &a[i]);
    int l = 0, r = 1e9;
    while (l <= r) {
        int m = l + r >> 1;
        if (check(m))r = m - 1; else l = m + 1;
    }
    printf("%d\n", r + 1);
}

Measured memory_bytes: 2176
// "for if God is with them who can be against them."
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
int ans = 0;
int cnt[400004];
void solve() {
	ll n, ans = 0, x = 0;
	cin >> n;
	string s;
	while (n > 0) {
		s += ('a' + (n - 1) % 26);
		n = (n - 1) / 26;
	}
	reverse(all(s));
	cout << s;

}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	IOS;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}


#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define ll long long 
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
int X[MAXN+5], L, R, S; ll P[MAXN+5], Ans; bool f;
int main()
{
	R = read(), S = read(); for(rint i = L = 1; i <= R; X[i] = read(), P[i] = read(), i++);
	for(f = P[L]<P[R]; L <= R; Ans += ((P[L]>=P[R])^f)*(X[R]-X[L]), (f=P[L]>=P[R])?P[L]+=P[R],P[R--]=0:(P[R]+=P[L],P[L++]=0))
		if(X[L] > S){Ans += X[R]-S; break;} else if(X[R] < S){Ans += S-X[L]; break;} printf("%lld\n",Ans); return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

vector<vector<int>> to(100000);
vector<int> pa(100000, -1);
vector<int> d(100000, 0);
int dfs(int v, int dist = 0, int p = -1){
    pa[v] = p;
    int ret = dist;
    for(int t : to[v]){
        if(t == p)continue;
        ret = max(ret, dfs(t, dist+1, v));
    }
    d[v] = ret;
    return ret;
}

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--; v--;
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(v);
    int cnt = 0;
    int idx = pa[u];
    while(idx != v){
        idx = pa[idx];
        cnt++;
    }

    idx = u;
    rep(i, cnt / 2)idx = pa[idx];
    int ans = d[idx] - 1;
    cout << ans << endl;
}

Measured memory_bytes: 12928
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= i; j ++){
            for (int l = 1; l <= j; l ++){
                int temp = __algo_gcd(i,__algo_gcd(j,l));
                if(i != j && j != l)     ans += temp * 6;
                else if (i == j && j == l)  ans += temp;
                else    ans += temp * 3;
            }
        }
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 3196
#include <cstdio>

int n,m;
int d[100010];

int main(void)
{
    int i;
    int u,v;

    //freopen("x.in","r",stdin);

    scanf("%d %d",&n,&m);
    for(i = 1;i <= m;++i)
        scanf("%d %d",&u,&v),++d[u],++d[v];
    for(i = 1;i <= n;++i)
        if(d[i] & 1)
            return puts("NO"),0;
    puts("YES");

    return 0;
}

Measured memory_bytes: 512
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(int[]);
    const N = tmp[0], T = tmp[1];
    auto candidates = N.iota.map!(_ => readln.split.to!(int[])).array.filter!(t => t[1] <= T);
    writeln(candidates.empty ? "TLE" : candidates.map!(t => t[0]).reduce!min.to!string);
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long dp[22][(1<<21)];
int main()
{
    long long n;
    cin>>n;
    long long compatibility[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>compatibility[i][j];
        }
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(1<<21);j++)
        {
            if(dp[i][j]>0)
            {
                for(int k=0;k<n;k++)
                {
                    if(compatibility[i][k]==1)
                    {
                        if((j&(1<<k))==0)
                        {
                            dp[i+1][j+(1<<k)]=(dp[i+1][j+(1<<k)]+dp[i][j])%1000000007;
                        }
                    }
                }

            }
        }
    }
    cout<<dp[n][(1<<n)-1]<<endl;
}


Measured memory_bytes: 309504
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){
  int a, b;
  std::cin >> a >> b;

  if(a>b){
    int tmp = b;
    b = a;
    a = tmp;
  }

  for(int i=0; i<b; i++){
    std::cout << a;
  }
  std::cout << std::endl;

  
  return 0;
}


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

typedef long long int ll;
// priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

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

	int a,b;
	cin>>a>>b;

	cout<<max(a-2*b,0)<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    string a;
    int n,x;
    cin>>n;
    while(n--){
        cin>>a;
        sort(a.begin(),a.end());
        x=atoi(a.c_str());
        reverse(a.begin(),a.end());
        cout<<atoi(a.c_str())-x<<endl;
    }
        
    
    
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int64_t a,b,c;
  cin >> N;
  a=2;
  b=1;
  for(int i=0;i<(N-1);i++){
    c=a+b;
    a=b;
    b=c;
  }
  cout << b << endl;
}


Measured memory_bytes: 3580
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int[] c = new int[M];
        int[] d = new int[M];
        for (int i = 0; i < M; ++i) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
 
        for (int i = 0; i < N; ++i) {
            int minIdx = -1;
            long min = Long.MAX_VALUE;
            for (int j = 0; j < M; ++j) {
                long dist = mdist(a[i], b[i], c[j], d[j]);
                if (dist < min) {
                    min = dist;
                    minIdx = j;
                }
            }
            _out.println(minIdx + 1);
        }
    }
    private long mdist(int x1, int y1, int x2, int y2) {
        return Math.abs(x2 - x1) + Math.abs(y2 - y1);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[100005];

int32_t main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	a[n] = INF;
	int ans = 0, p = 0;
	for(int i=n-1;i>=0;i--) {
		if(a[i] >= a[i+1]) p++;
		else p = 0;
		ans = max(ans, p);
	}
	cout << ans << endl;
}



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

int main() {
    int n;
    cin >> n;
    vector<int64_t> v(n);
    int64_t vMin = 1000000000000;
    int64_t ans = 0;
    int numOfMinus = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        vMin = min(vMin, abs(v[i]));
        if (v[i] < 0) numOfMinus++;
        ans += abs(v[i]);
    }
    if (numOfMinus % 2 == 0) {
        cout << ans << endl;
    } else {
        cout << ans - 2 * vMin << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;
int n,m;
int a[N], b[N], c[N];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i ++ )cin>>a[i];
	for(int i = 1;i <= n; i ++ )cin>>b[i];
	reverse(b + 1, b + n + 1);
	int l, r, flag, num;
	l = r = flag = num = 0;
	for(int i = 1; i <= n; i ++ ){
	 if(a[i]==b[i]&&l==0)
	    {
	    	l=i,r=i,flag=a[i];
		}
		else  
		   if(a[i]==b[i]&&l)
		   {
		   	  r=i;
		   }
	}
	if(l){
		for(int i = 1; i <= n && num <= r - l; i ++ ){
			if(b[i] != flag && a[i] != flag){
				b[l + num] = b[i];
				b[i] = flag;
				num ++ ;
			}
		} 
	}
	if(l == 0 || num == r - l + 1){
		puts("Yes");
		for(int i = 1;i <= n; i ++ ){
			cout << b[i] << " ";
		}
		cout << endl;
	}
	else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int a,b; cin >> a >> b;
    if(a>0 || b<0 && (b-a)%2==1) cout << "Positive" << endl;
    else if(b<0 && (b-a)%2==0) cout << "Negative" << endl;
    else cout << "Zero" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int N, val1=0, val2=0;
  string str1, str2;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> str1 >> str2;
    if(str1 > str2){
      val1 += 3;
    }else if(str1 < str2){
      val2 += 3;
    }else{
      val1++;
      val2++;
    }
  }
  cout << val1 << " " << val2 << endl;
  return 0;
}

Measured memory_bytes: 1208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            if (64 <= n)
            {
                WriteLine(64);
            }
            else if (32 <= n)
            {
                WriteLine(32);
            }
            else if (16 <= n)
            {
                WriteLine(16);
            }
            else if (8 <= n)
            {
                WriteLine(8);
            }
            else if (4 <= n)
            {
                WriteLine(4);
            }
            else if (2 <= n)
            {
                WriteLine(2);
            }
            else if (1 <= n) 
            {
                WriteLine(1);
            }
            else
            {
                WriteLine(0);
            }
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int  parent(int k) {
  return (k / 2);
}
int left(int k) {
  return (2 * k);
}
int right(int k ) {
  return (2 * k + 1);
}

int main(){

  int a[266] = {};
  int h;
cin >> h;
  for(int i = 1;i <= h;i++) cin >> a[i];

  for(int i = 1;i <=h;i++){

    cout << "node " << i << ": " << "key = " << a[i] << ", ";
    if(parent(i) >= 1) cout << "parent key = " << a[parent(i)] << ", ";
    if(left(i) <= h) cout << "left key = " << a[left(i)] << ", ";
    if(right(i) <= h) cout << "right key = " << a[right(i)] << ", ";
    cout << endl;
  }
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define NUM 26

using namespace std;

bool cmp_pair(pair<int, pair<string, int>> a, pair<int, pair<string, int>> b){
    pair<string, int> a_ = a.second;
    pair<string, int> b_ = b.second;
    if(a_.first == b_.first){
        return a_.second > b_.second;
    }else{
        return a_.first < b_.first;
    }
}

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

    vector<pair<int, pair<string, int>>> V;
    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s;
        cin >> p;
        V.push_back(make_pair(i + 1, make_pair(s, p)));
    }

    sort(V.begin(), V.end(), cmp_pair);

    for(int i = 0; i < V.size(); i++){
        printf("%d\n", V[i].first);
    }
}


Measured memory_bytes: 888
/* ex5_3 melo */
#include <stdio.h>
int main(void){
    int row_N,col_N,i,j;//整数の箱を４つ用意する
    char arrayc[100][100];//100*100の文字配列を用意
    int row_TorF[100], col_TorF[100];//黒があるかないか判定する文字列を列と行分用意
    scanf("%d %d",&row_N,&col_N);//行と列を代入
    for(i=0;i<row_N;i++){//二次元の文字配列を代入
        for(j=0;j<col_N;j++){
            scanf(" %c",&arrayc[i][j]);
        }
    }
    for(i=0;i<row_N;i++){//初期化
        row_TorF[i]=0;
    }
    for(j=0;j<col_N;j++){//初期化
        col_TorF[j]=0;
    }
    for(i=0;i<row_N;i++){//黒がある行と列を探す
        for(j=0;j<col_N;j++){
            if(arrayc[i][j]=='#'){
                row_TorF[i]=1;//i列には黒がある
                col_TorF[j]=1;//i行には黒がある
            }
        }
    }
    for(i=0;i<row_N;i++){//白いマスのみからなる列または行以外（黒があった列または行）を表示する
        for(j=0;j<col_N;j++){
            if(row_TorF[i]==1&&col_TorF[j]==1){
                printf("%c",arrayc[i][j]);
            }
        }
        if(row_TorF[i]==1){
                printf("\n");//1列分表示されたら改行する
        }
    }
    return 0;//正常終了
}

Measured memory_bytes: 1616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,t;
    cin>>n>>t;
    ll ans=1;
    int a[n];
    rep(i,n)cin>>a[i];
    vector<int> cnt(200000);
    rep(i,n)cnt[a[i]]++;
    for(int i=199999;i>=0;--i){
        cnt[i]+=cnt[i+1];
    }
    sort(a,a+n);
    reverse(a,a+n);
    rep(i,n)ans = ans * (i+1-cnt[a[i]+t+1]) %mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[3]{};
  for (auto i = 0; i < N; ++i) {
    int x;
    cin >> x;
    ++A[x - 1];
  }
  static long double F[301][301];
  auto M = A[0] + A[1] * 2 + A[2] * 3;
  for (auto m = 1; m <= M; ++m)
     for (auto i = min(m / 3, A[2]); i >= max(0, m - N * 2 - 1); --i)
      for (auto j = min((m - i * 3) / 2, A[2] + A[1]); j >= max(0, m - N - i * 2); --j) {
        auto k = m - i * 3 - j * 2;
        auto n = i + j + k;
        auto f = (long double) N;
        if (i)
          f += F[i - 1][j + 1] * i;
        if (j)
          f += F[i][j - 1] * j;
        if (k)
          f += F[i][j] * k;
        F[i][j] = f / n;
      }
  cout << fixed << setprecision(12) << F[A[2]][A[1]] << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
using ll = long long int;

int n;
int p[20];

int main(void) {
	cin >> n;
	for (size_t i = 0; i < n; i++) {
		cin >> p[i];
	}
	int ret = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] > p[i] && p[i] > p[i+1])
			ret++;
		else if (p[i + 1] > p[i] && p[i] > p[i - 1])
			ret++;

	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(ll j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll pre[25],a[25];
int main(){FAST;
cin>>n;
for(ll i=0;i<n;i++){
	cin>>a[i];
	if(i){
		pre[i]=max(pre[i-1],a[i]);	
	}
	else{
		pre[i]=a[i];
	}
}
ll ans=1;
for(ll i=1;i<n;i++){
	if(pre[i-1]<=a[i]){
		ans++;
	}
}
cout<<ans;
return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
   

   int x,y;
   scanf("%d%d",&x,&y);
   string s;
  cin>>s;
   for(int i=0;i<x;i++)
     if(!isdigit(s[i]))
       {
          cout<<"No";
          return 0;
       } 
   for(int i=x+1;i<x+y+1;i++){
     if(!isdigit(s[i])){
        cout<<"No";
        return 0;
     }
   }   
   if(s[x]=='-'){
      cout<<"Yes";
   }
   else 
     cout<<"No";
  return 0;                  
} 


Measured memory_bytes: 256
import math


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # 答えは sum(lcm(A) / A)
    L = 1
    for a in A:
        L = L * a // math.gcd(L, a)
    ans = 0
    for a in A:
        ans += L * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10236
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    if k > (n - 1) * (n - 2) / 2 {
        println!("-1");
        return;
    }
    if k == 0 {
        println!("{}", n * (n - 1) / 2);
        for i in 0..n {
            for j in i + 1..n {
                println!("{} {}", i + 1, j + 1);
            }
        }
        return;
    }
    let mut edges = vec![];
    for i in 1..n {
        edges.push((0, i));
    }
    let mut count = (n - 1) * (n - 2) / 2;
    'outer: for i in 1..n {
        for j in i + 1..n {
            if count == k {
                break 'outer;
            }
            edges.push((i, j));
            count -= 1;
        }
    }
    println!("{}", edges.len());
    for (u, v) in edges {
        println!("{} {}", u + 1, v + 1);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2112
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
 
signed main(){
	int a,b,c,d,ans;
	cin >> a >> b >> c >> d;
	ans = min(b,d) - max(a,c);
	cout << max(ans,0ll) << endl;
	return 0;
}

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

struct edge {int from, to, cost; };
int n, m, p;
edge es[5000];
long long d[2500];

void dfs(int s, vector<vector<int> > &graph, vector<int> &possible, vector<int> &used) {
  used[s] = 1;
  possible[s] = 1;
  for (int i: graph[s]) {
    if (used[i] == 1) {
      continue;
    }
    dfs(i, graph, possible, used);
  }
}
bool find_negative_loop(vector<int> &possible) {
  memset(d, 0, sizeof(d));
  for (int i=0; i<2*n; i++) {
    for (int j=0; j<m; j++) {
      edge e = es[j];
      if (!possible[e.from]) {
        continue;
      }
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if (i >= n) {
          return true;
        }
      }
    }
  }
  return false;
}
void shortest_path(vector<int> &possible) {
  long long inf = 1e15;
  for (int i=0; i<n; i++) d[i] = inf;
  d[0] = 0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      edge e = es[j];
      if (!possible[e.from]) {
        continue;
      }
      if (d[e.from] != inf && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }
}
int main() {
  cin>>n>>m>>p;
  vector<vector<int> > graph(n);
  vector<vector<int> > rev_graph(n);
  for (int i=0; i<m; i++) {
    int a, b, c;
    cin>>a>>b>>c;
    --a; --b;
    c -= p;
    es[i] = edge { a, b, -c };
    graph[a].push_back(b);
    rev_graph[b].push_back(a);
  }
  vector<int> used(n), possible1(n), possible2(n);
  dfs(0, graph, possible1, used);
  for (int i=0; i<n; i++) {
    used[i] = 0;
  }
  dfs(n-1, rev_graph, possible2, used);
  for (int i=0; i<n; i++) {
    possible1[i] = possible1[i] & possible2[i];
  }

  if (find_negative_loop(possible1)) {
    cout<<-1<<endl;
    return 0;
  }
  shortest_path(possible1);
  cout<<max(-d[n-1], 0ll)<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
void solveA();
void solveB();
void solveC();
void solveD();
 
int main() {
  solveB();
}

void solveA(){
  int d;
  cin >> d ;
  string s = "Christmas";

  for(int i = 0; i<25-d; i++){
    s += " EVE";
  }
 
  cout << s <<  endl;
}

void solveB(){
  int n;
  cin >> n ;
  int a[n];

  for(int i = 0; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  a[n-1] = a[n-1]/2;
    
    int ans = 0;
  for(int i = 0; i<n; i++){
    ans += a[i];
  }
 
  cout << ans <<  endl;
}


Measured memory_bytes: 256
////////////////////////////////////////////////////
    //                                                //
    //  For her who keeps the fire kindling in me...  //
    //                                                //
    ////////////////////////////////////////////////////

    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    // import java.util.Scanner;
    // import java.util.Arrays;
    // import java.util.ArrayList;
    // import java.util.Collections; 
    // import java.util.StringTokenizer;
    import java.util.*;
    import java.lang.Math;
    import java.awt.Point;

    import java.awt.geom.*;

    class Main {

        public static void main(String args[]) {
            try {
                FastReader s = new FastReader();
                BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
                int i, j, k, v, t, key, n, size, poster, minglob, minloc, beg, end, begl, endr, ind, l, r;// doub, b;
                long ans, f, ansmin, count, maxcount, x, y, x1, y1, x2, y2, x3, y3, x4, y4, sum1x, sum2x, sum3x, sum4x, sum1y, sum2y, sum3y, sum4y, max;
                boolean flag;
                
                n = s.nextInt();

                // int arr[] = new int[n];

                // for(i=0; i<n; i++)
                //     arr[i] = s.nextInt();

                ans = n*n*n;

                w.write(ans+ "\n");
                w.close();

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    // ========================================### FAST IO ###=========================================//
    class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        Double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    // ====================================================================================================//

Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int a, b, c;
  cin >> a >> b >> c;
  if(a+b==c||b+c==a||c+a==b){
    cout << "Yes" << endl;
  }else{
    puts("No");
  }
}

Measured memory_bytes: 256
def resolve():
    import math
    n = int(input())
    res = math.ceil(n / 1.08)
    if str(res)[-2:] == '.0':
        print(int(res))
    elif str(res * 1.08).split('.')[0] == str(n):
        print(int(str(res).split('.')[0]))
    else:
        print(':(')

resolve()

Measured memory_bytes: 3064
// ITP1_7_A.cpp

#include <iostream>
using namespace std;

int main()
{
	int m, f, r;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		else if (m == -1 || f == -1) {
			cout << "F\n";
		}
		else if (m + f >= 80) {
			cout << "A\n";
		}
		else if (m + f >= 65 && m + f < 80) {
			cout << "B\n";
		}
		else if (m + f >= 50 && m + f < 65) {
			cout << "C\n";
		}
		else if (m + f >= 30 && m + f < 50) {
			if (r >= 50) {
				cout << "C\n";
			}
			else {
				cout << "D\n";
			}
		}
		else {
			cout << "F\n";
		}
	}
}



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

using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

int main() {
	int n;
	cin>>n;
	vector<pair<ld,string>> a(n);
	for(int i=0;i<n;i++){
	    cin>>a[i].first>>a[i].second;
	}
	ld ans=0;
    for(int i=0;i<n;i++){
        if(a[i].second=="JPY"){
            ans+=a[i].first;
        }
        if(a[i].second=="BTC"){
            ans+=(380000.0*a[i].first);
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256