akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
struct HeavyLightDecomposition {
  const int n;
  VV<> g;
  V<> sz, par, in, out, anc;
  HeavyLightDecomposition(VV<>& g, int r = 0) : n(g.size()), g(g), sz(n), par(n), in(n), out(n), anc(n) {
    dfs_sz(r, -1);
    anc[r] = r;
    dfs_hl(r);
  }
  void dfs_sz(int v, int p) {
    par[v] = p;
    for (auto&& w : g[v]) if (w == p) {
      swap(w, g[v].back());
      g[v].pop_back();
      break;
    }
    sz[v] = 1;
    for (auto&& w : g[v]) {
      dfs_sz(w, v);
      sz[v] += sz[w];
      if (sz[w] > sz[g[v][0]]) swap(w, g[v][0]);
    }
  }
  void dfs_hl(int v) {
    static int t = 0;
    in[v] = t++;
    for (int w : g[v]) {
      anc[w] = w == g[v][0] ? anc[v] : w;
      dfs_hl(w);
    }
    out[v] = t;
  }
  int lca(int u, int v) {
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (anc[u] == anc[v]) return u;
      v = par[anc[v]];
    }
  }
};
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  for (int v = 0; v < n; ++v) {
    int k; cin >> k;
    while (k--) {
      int c; cin >> c;
      g[v].push_back(c);
      g[c].push_back(v);
    }
  }
  HeavyLightDecomposition hld(g);
  int q; cin >> q;
  while (q--) {
    int u, v; cin >> u >> v;
    cout << hld.lca(u, v) << '\n';
  }
}


Measured memory_bytes: 19812
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];

 
ll n,m,num=1,ans=0;
int i,j;
char s[100005];
ll a,b,c;

int main(){
	cin>>a>>b>>c;
	ll sum= (a+b+c);
	for(i=0;i<=100000;i++){
		if(a%2!=0 || b%2!=0 || c%2!=0)break;
		a=(sum-a)/2;
		b=(sum-b)/2;
		c=(sum-c)/2;
	}
	if(i==100001)cout<<-1;
	else cout<<i;
	cout<<endl;
	return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int min = n,max = 0;
    int l,r;
    for (int i=0;i<m;i++){
        cin >> l >> r;
        if (r<min){min=r;}
        if (l>max){max=l;}
    }
    int answer = min-max +1;
    //cout << max<<endl<<min;
    if (answer>0){cout << answer;}else{cout<<0;}
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#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 int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 1e5 + 5;

int n,m,q,a[55],b[55],c[55],d[55],score=0;
vi ans;

void dfs(int level,int val){
    if(level==n){
        int temp=0;
        for(int i=1;i<=q;++i){
            if(ans[b[i]-1]-ans[a[i]-1]==c[i]){
                temp+=d[i];
            }
        }
        score=max(score,temp);
        return;
    }
    for(int i=val;i<=m;++i){
        ans.pb(i);
        dfs(level+1,i);
        ans.pop_back();
    }
}

void solve(){
    cin>>n>>m>>q;
    for(int i=1;i<=q;++i){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(0,1);
    cout<<score;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

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

const int N = 200010;
typedef long long ll;

char s[N];
int cnt[N];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 0; i < n; ++ i){
		++ cnt[s[i]];
	}
	ll ans = 1ll * n * (n + 1) / 2 + 1;
	for (int i = 0; i < N; ++ i){
		ans -= 1ll * cnt[i] * (cnt[i] + 1) >> 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){


    int n;
    cin>>n;
    vector<pair<ll,ll>> v;
    vector<ll> xy;
    vector<ll> yx;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        v.push_back({x,y});
        xy.push_back(x+y);
        yx.push_back(x-y);
    }
    sort(xy.rbegin(),xy.rend());
    sort(yx.rbegin(),yx.rend());

    ll l1 = xy[0]-xy[n-1];
    ll l2 = yx[0]-yx[n-1];
    cout<<max(l1,l2)<<endl;







    
return 0;
}


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

using namespace std;
int main() {
	string s, t;

	cin >> s >> t;

	sort(s.begin(), s.end());

	sort(t.rbegin(), t.rend());


	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a = 0;

        int count = 0;

        for(int i = 1;i <= N;i++){
            a = sc.nextInt();
            if(!(i % 2 == 0) && !(a % 2 == 0)){
                count++;
            }
        }

        System.out.println(count);

    }
}


Measured memory_bytes: 27068
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
using namespace std;

char a[10], b[10], c[10];

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

	cin >> a >> b >> c;
	a[0] = a[0] - ('a' - 'A');
	b[0] = b[0] - ('a' - 'A');
	c[0] = c[0] - ('a' - 'A');

	cout << a[0] << b[0] << c[0]<< "\n";
	return 0;
}

Measured memory_bytes: 256
import itertools as it
import numpy as np

N,M,Q = map(int,input().split())
a = []
for i in range(Q):
    a.append(list(map(int,input().split())))

arange =  np.arange(1,M+1)
As = list(it.combinations_with_replacement(arange,N))

m = 0
for A in As:
    tmp = 0
    for q in a:
        if A[q[1]-1] - A[q[0]-1] == q[2]:
            tmp += q[3]
    if m < tmp:
        m = tmp

print(m)

Measured memory_bytes: 39420
#include <bits/stdc++.h>
#define lsb(x)
#define ll long long

using namespace std;

const int MAXN = (int) 2e5;

int fr[MAXN + 1];

int main(){
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, k, x;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        cin >> x;
        fr[x]++;
    }
    sort(fr + 1, fr + MAXN + 1, greater<int>());
    int cnt = 0;
    for(i = 1; i <= MAXN; i++)
        cnt += (fr[i] > 0);
    int ans = 0;
    if(cnt >= k) {
        for(i = k + 1; i <= cnt; i++)
            ans += fr[i];
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        int sum = 0;
        if (a >= k) {
            sum = k;
        } else if ((a + b) >= k) {
            sum = a;
        } else {
            sum = a - (k - a - b);
        }

        System.out.println(sum);

        return;
    }
}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  vector<int> v(3);
  REP(i, 3){
    cin >> v[i];
  }
  sort(ALL(v));
  int ans = v[2] - v[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int gcdr,tmp,x,y;
  scanf("%d %d",&x,&y);
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  gcdr=x%y;
  while(gcdr!=0){
    x=y;
    y=gcdr;
    gcdr=x%y;
  }
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 592
s = list(input())

cnt = 0
cnA = 0
i = 0
while i < len(s) - 1:
    #print(i, cnA)
    if s[i:i + 2] == ["B", "C"]:
        cnt += cnA
        i += 1
    elif s[i] == "A":
        cnA += 1
    else:
        cnA = 0
    i += 1

print(cnt)


Measured memory_bytes: 61936
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    n = int(s)

    fx = 0
    for i in s:
        fx += int(i)
    
    if n%fx == 0:
        print('Yes')
    else:
        print('No')


solve()


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

from math import ceil
import heapq

def main():
    n, d, a = map(int, input().split())
    q = []
    for i in range(n):
        x, h = map(int, input().split())
        heapq.heappush(q, (x, -ceil(h / a)))
    bomb = 0
    res = 0
    while q:
        x, h = heapq.heappop(q)
        if h < 0:
            h *= -1
            if h > bomb:
                heapq.heappush(q, (x + 2 * d, h - bomb))
                res += h - bomb
                bomb = h
        else:
            bomb -= h
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 34100
while true
  m,f,r = gets.chomp.split.map(&:to_i)
  if m == -1 && f == -1 && r == -1
  break
  elsif    m == -1 || f == -1
    puts "F"
  elsif m + f >= 80
    puts "A"
  elsif m + f >= 65
    puts "B"
  elsif m + f >= 50
    puts "C"
  elsif m + f >= 30
    if r < 50
     puts "D"
    else
     puts "C"
    end
  elsif m + f < 30
    puts "F"

  end
end

Measured memory_bytes: 8564
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  string s;
  char right[11] = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'}; 

  while(1) {
    cin >> s;
    if(s[0] == '#') break;

    bool b = false;
    REP(i, 11) {
      if(s[0] == right[i]) {
	b = true;
	break;
      }
    }
    int cnt = 0;
    FOR(i, 1, s.size()) {
      bool judge = false;
      REP(j, 11) {
	if(s[i] == right[j]) judge = true;
      }
      if((b && !judge) || (!b && judge)) {
	b = judge;
	cnt++;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    cout << n*(n-1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
	

typedef tree<
   pair<int,int>, 
   null_type,
   less< pair<int,int> >,
   rb_tree_tag, 
   tree_order_statistics_node_update
>ordered_set; 

int32_t main(){
	int n,q;
	cin>>n>>q;
	array<int,3> a[n];
	for(int i=0;i<n;i++)
		cin>>a[i][1]>>a[i][2]>>a[i][0];
	sort(a,a+n);

	set<pair<int,int>>s;
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		s.insert({x,i});
	}

	int ans[q];
	memset(ans,-1,sizeof ans);
	for(int i=0;i<n;i++){
		int t1 = a[i][1] - a[i][0];
		int t2 = a[i][2] - a[i][0];

		auto l = s.lower_bound({t1,0ll});
		auto r = s.lower_bound({t2,0ll});
		/*cout<<l->ff<<" "<<l->ss<<endl;
		cout<<r->ff<<" "<<r->ss<<endl;
		cout<<t2<<" "<<t1<<endl<<endl;
		*/vector<pi>v;
		for(auto it=l;it!=r;it++){
			pi x = *it;
			//cout<<x.ff<<" "<<x.ss<<endl;
			ans[x.ss] = a[i][0];
			v.push_back(x); 
		}

		//print(v);
		for(auto &p :v)
			s.erase(p);
	}

	for(int i=0;i<q;i++)
		cout<<ans[i]<<endl;
}



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

int main(void){
    
    int N;
    string S;
    cin >> N >> S;
    
    int ans = 0;
    for(int i = 0; i <= 999; i++){
        
        string check_str;
        if(i <= 9){
            check_str += "00" + to_string(i);
        }
        else if(i <= 99){
            check_str += "0" + to_string(i);
        }
        else{
            check_str += to_string(i);
        }
        
        int count = 0;
        
        for(int i = 0; i < N; i++){
            if(S[i] == check_str[count]){
                count++;
            }
            if(count == 3){
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  double k = accumulate(a.begin(),a.end(),0) * 1.0 / (4 * m);
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(a[i] * 1.0 >= k) cnt++;
  }
  cout << (cnt >= m ? "Yes" : "No") << endl;

  return 0;
}


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

/*ll a[100],n;

ll rec(ll k,ll len){
  cout<<k<<" "<<len<<"\n";
  if(k==0) return len%2;
  ll res=-1;
  for(int i=0;i<n;i++){
    if(k>=a[i]){
      res=rec(k-a[i],len+1);
      if(res==1) break;       
    }
  }
  return res;
}*/

int main() {
  ll n,k;
  cin>>n>>k;
  ll a[n];
  bool dp[k+1];
  for(int i=0;i<=k;i++) dp[i]=false;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=1;i<=k;i++){
    for(int j=0;j<n;j++){
      if(i-a[j]<0) break;
      if(dp[i-a[j]]==false){
          dp[i]=true;
          break;
      }
    }
  }
  if(dp[k]==true) cout<<"First\n";
  else cout<<"Second\n"<<"\n";
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define loop(i, n)      for(int i = 0 ; i < n ; ++i)
#define rloop(i, n)     for(int i = int(n)-1 ; i >= 0 ; --i)
#define loopOne(i, n)   for(int i = 1 ; i <= n; ++i)
#define range(i, a, b)  for(int i = int(a) ; i <= int(b) ; ++i)
#define sz(x)   int(x.size())

void GO(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
const ll N = 1e5+100, OO = 1e9;
int mx = -OO, mn = OO;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

ll w[N], v[N], n, W, memo[150][N];
ll Solve(int idx, int Total){
    if(idx == n)    return 0;
    if(memo[idx][Total] != -1)  return memo[idx][Total];
    ll op1 = w[idx] <= Total ? v[idx] + Solve(idx+1, Total-w[idx]) : 0;
    ll op2 = Solve(idx+1, Total);
    return memo[idx][Total] = max(op1, op2);
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    GO();
    scanf("%lld %lld", &n, &W);
    for(int i = 0; i < n; ++i){
        scanf("%lld %lld", w+i, v+i);
    }
    memset(memo, -1, sizeof(memo));
    printf("%lld", Solve(0, W));
    return 0;
}

Measured memory_bytes: 121108
#include <iostream>

using namespace std;

int main() {
  long long n;
  cin >> n;
  string c;
  while (n > 0) {
    int r = n % 26;
    n /= 26;
    if (r > 0) c+='a'+ r - 1;
    else {
      c += 'z';
      n--;
    }
  }
  for (int i = c.size() - 1; i >= 0; i--) {
    cout << c[i];
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=1e6+10;
typedef long long ll;
const ll mod=1e9+7;
#define per(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
#define qwq puts("QWQ");
#define qaq puts("QAQ");
#define mem(a,b) memset(a,b,sizeof(a))
#define mid ((l+r)>>1)
#define l(x) x<<1
#define r(x) x<<1|1
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
void read(int &x)
{
	int f=1;x=0;
	char s=getchar();
	while(s<'0'||s>'9')
    {
    	if(s=='-')f=-1;
    	s=getchar();
	}
	while(s>='0'&&s<='9')x=x*10+s-'0',s=getchar();
	x*=f;
}
int n,a[maxn];
int main()
{
	int sum=0;
	read(n);
	per(i,0,n)read(a[i]);
	per(i,0,n-1)per(j,i+1,n)sum+=a[i]*a[j];
	printf("%d\n",sum);
}

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

int main() {
  int N;
  string S;
  cin >>N;
  cin>>S;
  int m=0;
  for(int i=1;i<=N-1;i++){
    string s1 = S.substr(0,i);
    string s2 = S.substr(i,N-i);
    //cout<< s2<<endl;
    map<char, int> card1;
    map<char, int> card2;
    for(int j=0;j<i;j++){
      if(card1.count(s1[j])){
        card1[s1[j]] =1;
      }
      else{
        card1[s1[j]] =1;
      }
    }

    for(int j=0;j<N-i;j++){
      if(card2.count(s2[j])){
        card2[s2[j]] =1;
      }
      else{
        card2[s2[j]] =1;
      }
    }
    int c=0;
    for(auto p: card1){
      auto v1 = p.first;
      for(auto q: card2){
        auto v2 = q.first;
        if( v1==v2 ) c++;
      }
    }
    m =max(m,c);

  }
cout<<m<<endl;

}


Measured memory_bytes: 256
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=1




def solve():
    
    

    # for _ in range(ii()):

        n= ii()
        a = li()
        ans=0
        for i in range(n):
            for j in range(i+1,n):
                for k in range(j+1,n):
                    if a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]:
                        s = a[i]+a[j]+a[k]
                        mx = max(a[i],max(a[j],a[k]))
                        if s > 2*mx:
                            ans+=1

        print(ans)













        
if __name__ =="__main__":

    if(file):

        if path.exists('input.txt'):
            sys.stdin=open('input.txt', 'r')
            sys.stdout=open('output.txt','w')
        else:
            input=sys.stdin.readline
    solve()


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

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

    vector<pair<int,int>> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i].first;
        p[i].second = i;
    }
    sort(p.begin(), p.end());

    int ans = n;// MAX
    int count = 1;
    for(int i=0; i<n; i++){
        if(i == n-1 || p[i].second > p[i+1].second){
            ans = min(ans, n - count);
            count = 1;
        }
        else count += 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i,n){
    if(s[i] != s[i-1]) ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include <cstdlib>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main()
{
    int n, m, q;
    std::cin >> n >> m >> q;
    vector< vector<int> > arr;
    vector< vector<int> > sum;
    arr.resize(n);	
    sum.resize(n);
    for (int i=0; i<n; ++i){
        arr[i].resize(n);	
        for (int j=0; j<n; ++j){
            arr[i][j] = 0;
        }
    }
    int a, b;
    for (int i=0; i<m; ++i){
        std::cin >> a >> b;
        arr[a-1][b-1] += 1;
    }
    int s = 0;
    // 累積和作成
    for (int i=0; i<n; ++i){
        sum[i].resize(n);
        s = 0;
        for (int j=0; j<n; ++j){
            s += arr[i][j];
            sum[i][j] += s;
            //std::cout << "sum " << i << "*" << j << ": is " << sum[i][j] << endl;
        }
    }
    int tmp1, tmp2;
    long ans = 0;
    for (int i=0; i<q; ++i){
        ans = 0;
        std::cin >> tmp1 >> tmp2;
        //std::cout << tmp1 << "$" << tmp2 << endl;
        for (int c=tmp1-1; c<tmp2; c++){
            if(tmp1 != tmp2 && tmp1 != 1){
                ans += (sum[c][tmp2-1] - sum[c][tmp1-2]);
                //std::cout << "hoge " << (tmp2-1) << ":" << (tmp1-1) << endl;
            }
            else if(tmp1 == tmp2){
                ans += arr[c][tmp2-1];
                //std::cout << "fuga " << (tmp2-1) << ":" << (tmp1-1) << endl;
            }
            else if(tmp1 == 1){
                ans += sum[c][tmp2-1];
                //std::cout << "piyo " << (tmp2-1) << ":" << (tmp1-1) << endl;
            }
        }
        std::cout << ans << endl;
    }
}



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

using namespace std;

vector <int> adj[100001];
int visited[100001];
int Prev[100001];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,a,b;

	cin >> n >> m;

	for(int i=0;i<m;i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(Prev,-1,sizeof(Prev));
	memset(visited,-1,sizeof(visited));
	queue <int> que;
	que.push(1);
	visited[1] = 0;

	while(!que.empty())
	{
		int now = que.front();
		que.pop();

		for(auto next : adj[now])
		{
			if(visited[next]==-1)
			{
				Prev[next] = now;
				visited[next] = visited[now] + 1;
				que.push(next);
			}
		}
	}

	for(int i=2;i<=n;i++)
	{
		if(Prev[i]==-1)
		{
			cout << "No" << '\n';
			return 0;
		}
	}

	cout << "Yes" << '\n';
	for(int i=2;i<=n;i++)
	{
		cout << Prev[i] << '\n';
	}

	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[MAXN];

void solve(){
	int a, b, n, aa, bb;
	scanf("%d%d%d%s", &n, &a, &b, &s[0]);
	aa = bb = 0;
	REP(i, 0, n){
		if (s[i] == 'a' && aa + bb < a + b){
			printf("Yes\n");
			aa++;
		} else if (s[i] == 'b' && aa + bb < a + b && bb < b){
			printf("Yes\n");
			bb++;
		} else {
			printf("No\n");
		}
	}
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

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

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

 for(int e=0;e<3;e++){
 if(a>b){d=a;a=b;b=d;}
 if(b>c){d=b;b=c;c=d;}
 }

 cout <<a<<" "<<b<<" "<<c<<endl; 
}

Measured memory_bytes: 3076
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
array_1 = list(map(int, input().split()))
array_2 = list(map(int, input().split()))
# 全探索する
# N回移動できる
# どのタイミングで下に移動するかがキーポイント
# 下に移動するタイミングはN通りある
max_candy = 0
for n in range(N):
    # n列目で下に移動したときのキャンディの個数をチェック
    total = sum(array_1[: n + 1]) + sum(array_2[n:])
    # 記録更新なら上書き
    if max_candy < total:
        max_candy = total
print(max_candy)


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

int main() {
  int N,M; cin >> N >> M; int a[N],b[N],c[M],d[M]; 
  rep(i,0,N) cin >> a[i] >> b[i];
  rep(i,0,M) cin >> c[i] >> d[i];
  
  rep(i,0,N) {
    int ans = abs(a[i]-c[0])+abs(b[i]-d[0]), point =1;
    rep(j,0,M) {
      int tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if (ans > tmp) {
        ans = tmp; point = j+1;
      }
    }
    cout << point << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long ans = 0;

    bool flag;
    if (x >= y)
    {
        flag = true;
    }
    else
    {
        flag = false;
    }

    if (a + b >= 2 * c)
    {
        ans += 2 * c * min(x, y);
    }
    else
    {
        ans += (a + b) * min(x, y);
    }

    if ((a >= 2 * c) && flag)
    {
        ans += 2 * c * (x - y);
    }
    else if (flag)
    {
        ans += a * (x - y);
    }

    if ((b >= 2 * c) && !flag)
    {
        ans += 2 * c * (y - x);
    }
    else if (!flag)
    {
        ans += b * (y - x);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> dp(K + 1);
    dp[0] = 1;
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        for(unsigned long j{K}; j > a; --j)dp[j] += dp[j] > dp[j - a - 1] ? -dp[j - a - 1] : MOD - dp[j - a - 1];
    }
    for(unsigned long i{0}; i < N; ++i)partial_sum(dp.begin(), dp.end(), dp.begin(), [](auto i, auto j){return (i + j) % MOD;});
    cout << dp.back() << endl;
    return 0;
}

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

string s, t;
int ans;

int main() {
	
	cin >> s >> t;
	
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
	
}

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

int main() {
    string n; cin >> n;
    bool check = false;
    rep(i, n.size()){
        if(n[i]=='7') check = true;
    }
    cout << (check? "Yes": "No") << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
typedef long double ld;

int H, W, T, C[15][15], cnt[15], A[205][205];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> H >> W;
	for (int i = 0; i <= 9; i++)
		for (int j = 0; j <= 9; j++)
			cin >> C[i][j];
	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++) {
			cin >> A[i][j];
			if (A[i][j] != -1) cnt[A[i][j]]++;
		}
	for (int k = 0; k <= 9; k++)
		for (int i = 0; i <= 9; i++)
			for (int j = 0; j <= 9; j++)
				C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
	for (int i = 0; i <= 9; i++)
		T += cnt[i] * C[i][1];
	cout << T << '\n';
}


Measured memory_bytes: 640
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;

template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a,T  b) { return a<b?(a=b,true):false; }
#define forn(i,x,y) for(int i=(x);i<(int)(y);i++)
#define rep(i,y) for(int i=0;i<(int)(y);i++)
#define repb(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)

template<class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << " ";
    os << *it;
  }
  return os;
}

int d,t,s;
int main() {
  cin >> d >> t >> s;
  if (d / s < t || s * t == d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

void solve() {
  long long int n, k;
  cin >> n >> k;
  map<long long int, long long int> mp;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  long long int sum = 0;
  for (auto p : mp) {
    sum += p.second;
    if (sum >= k) {
      cout << p.first;
      return;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}



Measured memory_bytes: 7512
/*input
10 3
1
5
4
3
8
6
9
7
2
4
*/
#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;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const int maxn=3e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
struct segt{
    ll seg[4*maxn];
    ll lazy[4*maxn];
    int n;
    void resize(int _n){
        n=_n;
    } 
    void pushdown(int idx,int l,int r){
        if(!lazy[idx]) return;
        seg[idx]=lazy[idx];
        if(l==r){
            lazy[idx]=0;
            return;
        }
        lazy[idx*2]=lazy[idx];
        lazy[idx*2+1]=lazy[idx];
        lazy[idx]=0;
    }
    void mdf(int idx,int l,int r,int ql,int qr,int x){
        pushdown(idx,l,r);
        if(l>qr or r<ql) return;
        if(ql<=l and r<=qr){
            lazy[idx]=x;
            pushdown(idx,l,r);
            return;
        }
        int mid=(l+r)/2;
        mdf(idx*2,l,mid,ql,qr,x);
        mdf(idx*2+1,mid+1,r,ql,qr,x);
        seg[idx]=max(seg[idx*2],seg[idx*2+1]);
    }
    int query(int idx,int l,int r,int ql,int qr){
        if(l>qr or r<ql) return 0;
        pushdown(idx,l,r);
        if(ql<=l and r<=qr) return seg[idx];
        int mid=(l+r)/2;
        return max(query(idx*2,l,mid,ql,qr),query(idx*2+1,mid+1,r,ql,qr));
    }
    int query(int l,int r){
        return query(1,0,n-1,l,r);
    }
    void mdf(int l,int r,int x){
        mdf(1,0,n-1,l,r,x);
    }
}seg;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,k;
    cin>>n>>k;
    seg.resize(maxn);
    REP(i,n){
        int x;
        cin>>x;
        int mx=seg.query(max(x-k,0),min(x+k,maxn-1));
        seg.mdf(x,x,mx+1);
    }
    cout<<seg.query(0,maxn-1);
}


Measured memory_bytes: 18056
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  long ans=0;
  up(i,1,N-1)ans+=i;
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;

int solve(vector<int>a)
{
    int n=a.size();
    int odd=0;
    for(int i=0;i<n;i++)
    {
        int ev=0;
        if(((n-1)&i)!=i||a[i]%2==0) ev=1;
        if(ev) continue;
        odd^=1;
    }
    if(odd) return 1;
    for(int i=0;i<n;i++) if(a[i]==1) return 0;
    bool kt=false;
    for(int i=0;i<n;i++) if(a[i]!=a[0]) kt=true;
    if(kt)
    {
        for(int i=0;i<n;i++) a[i]/=2;
        return 2*solve(a);
    }
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        char c;
        cin>>c;
        a[i]=c-'1';
    }
    cout<<solve(a);
}


Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A1=scan.nextInt();
		int A2=scan.nextInt();
		int A3=scan.nextInt();
		int sum=0;
		sum=A1+A2+A3;
		if(sum>=22)
		{
			System.out.println("bust");
		}
		else
		{
			System.out.println("win");
		}

	}

}


Measured memory_bytes: 35808
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const long long INFL = __LONG_LONG_MAX__ / 10;
const int INFI = __INT_MAX__ / 10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

uint64_t popcnt(uint64_t n)
{
    uint64_t c = 0;
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333);
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f);
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff);
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff);
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff);
    return (c);
}

int N;
const int LimitN = 50;
int D[LimitN];

int main()
{
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i, N)
    {
        cin >> D[i];
    }

    LL ans = 0;

    REP(i, N)
    {
        FOR(j, 0, i)
        {
            ans += (D[i] * D[j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n, y;
    std::cin >> n >> y;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            int z = n - i - j;

            if (i + j * 5 + z * 10 == y / 1000) {
                std::cout << z << " " << j << " " << i << std::endl;
                return 0;
            }
        }
    }

    std::cout << "-1 -1 -1" << std::endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; ++i)
            v[i] = scanner.nextInt();
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            c[i] = scanner.nextInt();
            if (v[i] > c[i])
                ans += v[i] - c[i];
        }
        writer.println(ans);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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

Measured memory_bytes: 21076
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/



/*ここからmain関数*/

int main()
{
	char b;
	cin >> b;

	if (b == 'A')
		cout << "T";
	else if (b == 'T')
		cout << "A";
	else if (b == 'G')
		cout << "C";
	else if (b == 'C')
		cout << "G";

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

Measured memory_bytes: 256