akhauriyash/Code-Regression huggingface dataset:
/*input
2 2 1
3 5
3 5
2 2 2
*/
/**
    Author: Kristopher Paul
    Date Created: 06-03-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

//Uncomment for File I/O
/*
ifstream fin("cave.in");
ofstream fout("cave.out");
*/
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int a,b,m;
    cin >> a >> b >> m;
    int v1[a],v2[b];
    int l = 1e18;
    int r = 1e18;
    FOR(i,0,a){
        cin >> v1[i];
        remin(l,v1[i]);
    }
    FOR(i,0,b){
        cin >> v2[i];
        remin(r,v2[i]);
    }
    int mini = l+r;
    FOR(i,0,m){
        int x,y,c;
        cin >> x >> y >> c;
        remin(mini,v1[x-1]+v2[y-1]-c);
    }
    cout << mini << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int N; cin >> N;
    int res=0;
    for(int i=1;i<=N;i+=2){
        int num_div = 0;
        for(int j=1; j<=i; j++){
            if(i%j==0) num_div++;
        }
        if(num_div==8) res++;
    }
    pr(res);
 
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	unsigned long long i,n, m;
	scanf("%llu",&n);
	m = 1;
	if(n >=1&&n <= 20)
	{
		for(i=n;i>0;i--)
		{
			m *=i;
		}
	}
	printf("%llu\n",m);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N, vector<int>(M, -1));
  vector<set<int>> sports(M);
  REP(i, N) REP(j, M) {
    cin >> A[i][j];
    A[i][j]--;
  }
  vector<int> index(N, 0);
  REP(i, N) {
    sports[A[i][0]].insert(i);
    index[i]++;
  }

  priority_queue<tuple<int, int>> pq;
  REP(i, M) {
    int n = sports[i].size();
    pq.emplace(n, i);
  }
  int ans = N;
  vector<bool> removed(M);
  while (pq.size()) {
    // REP(i, M) {
    //   cerr << "sport " << i << ": ";
    //   for (auto j : sports[i]) {
    //     cerr << j << " ";
    //   }
    //   cerr << endl;
    // }

    auto [n, sport] = pq.top();
    pq.pop();
    if (n != int(sports[sport].size())) {
      assert(removed[sport]);
      continue;
    }
    if (removed[sport]) continue;
    removed[sport] = true;
    ans = min(ans, n);
    DEBUG(n, sport, ans);

    map<int, vector<int>> updates;
    bool finish = false;
    for (auto person : sports[sport]) {
      int j;
      do {
        j = index[person]++;
      } while (j < M && removed[A[person][j]]);
      if (j >= M) {
        finish = true;
        break;
      }
      updates[A[person][j]].push_back(person);
      DEBUG(person, sport, A[person][j]);
    }
    if (finish) break;
    sports[sport].clear();
    for (auto it = updates.begin(); it != updates.end(); ++it) {
      int sp = it->first;
      sports[sp].insert(it->second.begin(), it->second.end());
      pq.emplace(int(sports[sp].size()), sp);
      DEBUG(sp, sports[sp].size());
    }
  }
  cout << ans << endl;
}


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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << "\t|";
  __f(comma + 1, args...);
}
 

#define print(x) for(auto it : x) cout<< it << " "; cout << endl;
typedef long long ll;
typedef unsigned long long ull;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    for (int i = 1000; i <= 10000; i += 1000) {
        if (n <= i) {
            cout << i - n << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define f first
#define se second
#define int long long
#define pll pair<ll, ll>
#define pii pair<int, int>


using namespace std;

const int N = 2e5 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int p = 1e9 + 7;


int n, pw[50];
string s;
unordered_map<int, int> mp;


int hashh(string t) {
	int ans = 0;
	for (int i = 0; i < t.size(); i++) {
		int t1 = i + 1, t2 = t[i] - 'a';
		ans += t2 * pw[t1];
	}
	return ans;
}


void precalc() {
	pw[0] = 1;
	for (int i = 1; i <= 40; i++)
		pw[i] = pw[i - 1] * p;
}


main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
	//freopen("input.txt", "r", stdin);	
	precalc();
	cin >> n;
	cin >> s;
	string s1, s2, s3, s4;
	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		s3 = ""; s4 = "";
		for (int j = 0; j < n; j++)
			if (1 & (mask>>j))
				s3 += s[j + n];
		for (int j = n - 1; j >= 0; j--)
			if (!(1 & (mask>>j)))
				s4 += s[j + n];
		int val = hashh(s4 + "#" + s3);
		if (mp.count(val))
			mp[val]++;
		else
			mp[val] = 1;
	}
	for (int mask = 0; mask < (1 << n); mask++) {
		s1 = ""; s2 = "";
		for (int j = 0; j < n; j++)
			if (1 & (mask>>j))
				s1 += s[j];
		for (int j = n - 1; j >= 0; j--)
			if (!(1 & (mask>>j)))
				s2 += s[j];
		int val = hashh(s1 + "#" + s2);
		if (mp.count(val)) {
//			cout << s1 << " " << s2 << " " << mp[val] << endl;
			ans += mp[val];
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 14280
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a[n]={};
ll b[n]={};
for(ll i=0; i<n; i++){
cin>>a[i]>>b[i];}
ll ca=0;
ll cb=10000000000;
for(ll i=0; i<n; i++){
ca=max(ca,a[i]);
cb=min(cb,a[i]);}
ll ba=0;
ll bi=0;
ll bb=0;
ll bn=0;
for(ll i=0; i<n; i++){
if(a[i]==ca){
ba=b[i];
bb=i;}
if(cb==a[i]){
bi=b[i];
bn=i;}}
cout << ca+ba << endl;}


Measured memory_bytes: 5184
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && x+r <=w && y+r<= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {

            double r = double.Parse(Console.ReadLine());
            double S = r * r * Math.PI;
            double Z = 2 * r * Math.PI;
            Console.WriteLine(S.ToString("0.00000")+" "+Z.ToString("0.00000"));

        }
    }
}

Measured memory_bytes: 9284
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    string ans = "No";
    if(n == m) ans = "Yes";
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define inf 100000000000000000
#define rep(i,a) for(ll i=0; i<a; ++i)
#define pb push_back

ll n;
ll a[100005];
ll cnt[40];
ll x=0;

ll getLastOneIndex(ll p) {
  if (p%2==1) {
    return 0;
  } else {
    return 1+getLastOneIndex(p/2);
  }
}

vector<ll> reversedBitVector(ll p) {
  vector<ll> ret;
  for (ll i=0; i<40; ++i) {
    ret.pb(p&1);
    p = p>>1;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  rep(i,n) {
    cin>>a[i];
  }
  rep(i,n) {
    ll lastOneIndex = getLastOneIndex(a[i]);
    x ^= (a[i]-(1<<lastOneIndex));
    cnt[lastOneIndex]++;
  }

  ll ans=0;
  vector<ll> revBit = reversedBitVector(x);
  for (ll i=revBit.size()-1; i>=0; --i) {
    if (revBit[i]==1) {
      if (cnt[i]==0) {
        cout<<-1<<endl;
        return 0;
      }
      if (cnt[i]%2==0) {
        ans++;
        for (ll j=i-1; j>=0; --j) {
          revBit[j] = 1-revBit[j];
        }
      }
    } else {
      if (cnt[i]%2==1) {
        ans++;
        for (ll j=i-1; j>=0; --j) {
          revBit[j] = 1-revBit[j];
        }
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(void) {
    double N;
    cin >> N;
    N /= 2;
    cout << (int)(N+0.5) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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 (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
	vector<ll> par;

	UnionFind(ll n) : par(n, -1) { }
	void init(ll n) { par.assign(n, -1); }

	int root(ll x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	bool merge(ll x, ll y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(ll x) {
		return -par[root(x)];
	}
};

 
int main(){
    ll N,M;
  	cin >> N >> M;
  	vector<ll> A(M), B(M);
  	rep(i,M){
      cin >> A[i] >> B[i];
      A[i]--;
      B[i]--;
    }
  
  	vector<ll> ans(M);
  	ans[M-1] = N * (N - 1) / 2;
  
  	UnionFind Uni(N);
  
  	repprev(i, 1, M){
      //繋がってなかったのが繋がった時
      	if(Uni.root(A[i]) != Uni.root(B[i])){
          ans[i - 1] = ans[i] - Uni.size(A[i]) * Uni.size(B[i]);
          Uni.merge(A[i],B[i]);
        }
      else ans[i - 1] = ans[i]; 
    }
  
  rep(i,M){
    cout << ans[i] << endl;
  }
  	
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
const int INFTY = 1e9+7;

int main() {
  int N, Q;
  cin >> N >> Q;
  priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> closed;
  rep(i,N) {
    int S, T, X;
    cin >> S >> T >> X;
    closed.push({S-X, T-X, X});
  }
  vector<int> D(Q);
  rep(i,Q) cin >> D[i];

  priority_queue<P, vector<P>, greater<P>> end;  // P(endtime, position)
  set<int> pos;
  vector<int> ans(Q, -1);

  rep(i,Q) {
    while (!end.empty() && end.top().first <= D[i]) {  // construction finished
      pos.erase(end.top().second);
      end.pop();
    }
    while (!closed.empty() && closed.top()[0] <= D[i]) {  // construction started
      auto v = closed.top();
      closed.pop();
      if (v[1] > D[i]) {  // construction not finished
        end.push(P(v[1], v[2]));
        pos.insert(v[2]);
      }
    }
    if (!pos.empty()) ans[i] = *begin(pos);
  }

  rep(i,Q) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 22316
import java.util.*;

class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int i;
		int x = 0;
		
		for(i=a;i<=b;i++){
			if(c % i==0){
				x++;
			}
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 26188
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int SIZE = 404;
const int INF = 1e18 + 3000;

int dp[SIZE][SIZE];
int tab[SIZE];
int pre[SIZE];
int n, p = 0;

    void input(){
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> tab[i];
            p += tab[i];
            pre[i] = p;
        }
    }

    void infinity(){
        for(int i = 0; i < SIZE; i++)
            for(int k = 0; k < SIZE; k++)
                dp[i][k] = INF;
    }

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    input();
    infinity();
    

    for(int i = n - 1; i >= 0; i--){
        for(int k = i; k < n; k++){
            if(i == k) dp[i][k] = 0;
            else
                for(int j = i; j < k; j++)
                    dp[i][k] = min(dp[i][k], dp[i][j] + dp[j + 1][k] + pre[k] - pre[i - 1]);           
        }
    }

    cout << dp[0][n-1];
    return 0;
}

Measured memory_bytes: 1536
S=input()
T=input()
S2=[0]*len(S)
T2=[0]*len(T)
SD={}
TD={}

c=0
for i in range(len(S)):
    if(SD.get(S[i],None)==None):
        c+=1
        SD[S[i]]=c
        S2[i]=c
    else:
        S2[i]=SD.get(S[i],None)
c=0
for i in range(len(T)):
    if(TD.get(T[i],None)==None):
        c+=1
        TD[T[i]]=c
        T2[i]=c
    else:
        T2[i]=TD.get(T[i],None)
if(S2==T2):
    print("Yes")
else:
    print("No")




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

l = sorted(a)
flag = False
for i in range(n):
    x -= l[i]
    if x < 0:
        flag = True
        break
if flag:
    print(i)
elif x == 0:
    print(n)
elif x > 0:
    print(n - 1)


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

const int N = 1e5+7;

typedef pair<int, int> PII;
PII v[N];

PII pre[N], suf[N];

PII intersect(PII a, PII b) {
    return PII(max(a.first, b.first), min(a.second, b.second));
}

int len(PII pr) {
    return max(0, pr.second - pr.first+1);
}

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

    int n;
    cin>>n;

    for (int i=1; i<=n; i++)     cin>>v[i].first>>v[i].second;

    int id = 1;
    for (int i=1; i<=n; i++)
        if (v[i].second < v[id].second)
            id = i;

    swap(v[id], v[1]);
    sort(v+2, v+n+1);

    pre[0] = PII(0, 1e9+7);
    for (int i=1; i<=n; i++)
        pre[i] = intersect(pre[i-1], v[i]);

    suf[n+1] = PII(0, 1e9+7);
    for (int i=n; i>0; i--)
        suf[i] = intersect(suf[i+1], v[i]);

//    for (int i=1; i<=n; i++)    cout<<i<<" "<<v[i].first<<" "<<v[i].second<<endl;
//    for (int i=1; i<=n; i++)    cout<<i<<" "<<pre[i].first<<" "<<pre[i].second<<endl;
//    for (int i=1; i<=n; i++)    cout<<i<<" "<<suf[i].first<<" "<<suf[i].second<<endl;

    int ans = 0;
    for (int i=1; i<n; i++) {
        PII ra = pre[i], rb = suf[i+1];
        int cur = len(ra) + len(rb);
        ans = max(ans, cur);

        ra = v[i];
        rb = intersect(pre[i-1], suf[i+1]);
        cur = len(ra) + len(rb);
        ans = max(ans, cur);

//        cout<<i<<" "<<cur<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
  // cin >> TT;
  while (TT--) {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (auto& aa : A) cin >> aa;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if ((i&1) && (A[i-1]&1)) ++ans;
    }
    cout << ans << endl;
  }
}


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


int main(){
	int n;
	
	map<string, int> bag;
	
	string str;
	string labels[] = {"AC", "WA", "TLE", "RE"};
	
	cin >> n;
	while(n--){
		cin >> str;
		bag[str]++;
	}
	
	for(int i=0; i < 4; i++){
		string key = labels[i];
		cout << key << " x " << bag[key] << endl;
	}
}


Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

void Yn(bool f)
{
  cout << (f ? "Yes" : "No") << endl;
}

void yn(bool f)
{
  cout << (f ? "yes" : "no") << endl;
}

void YN(bool f)
{
  cout << (f ? "YES" : "NO") << endl;
}

int n, c[20], v[20], s[20];

int main()
{
  cin >> n;
  REP(i, n){
    cin >> v[i];
  }

  int ans = 0;
  REP(i, n)
  {
    cin >> c[i];
    s[i] = v[i] - c[i];
    if(s[i]>0)
      ans += s[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll x,y;cin >> x >> y;
    rep(i,x+1){
        if(i*2+(x-i)*4==y){
            cout <<"Yes" <<endl;
            return 0;
        }
    }
    cout <<"No" <<endl;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define N 3000010
typedef long long LL;
int a[N], tot, n, m;
LL sum;

int main() {
    //freopen("sample.in", "r", stdin);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        int tmp; scanf("%d", &tmp);
        sum += tmp;
        while (tmp) {
            a[++tot] = tmp - tmp / 2, tmp /= 2;
        }
    }
    if (m >= tot) return cout << 0 << endl, 0;
    nth_element(a + 1, a + tot - m + 1, a + tot + 1);
    //for(int i = 1; i <= tot; i++) cout << a[i] << endl;
    int kth = a[tot - m + 1], num = 0;
    for(int i = 1; i <= tot; i++)
        if (a[i] > kth) sum -= a[i], num++;
    sum = sum - (LL)kth * (m - num);
    cout << sum << endl;
}

Measured memory_bytes: 11904
import java.util.*;class Main{public static void main(String[]$){Scanner s=new Scanner(System.in);char[] c=s.next().toCharArray();int k=c.length;for(int i=0,w=0;i<c.length;++i)if(c[i++]!=w)w=c[--i];else{w=0;--k;}System.out.println(k);}}

Measured memory_bytes: 28428
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll A, ll B) {
	if(A + B >= 10) printf("error");
	else printf("%d", A + B);
}

int main() {
	ll B;
	ll A;
	scanf("%lld", &A);
	scanf("%lld", &B);
	solve(A, B);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n, a, b, c, d;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	a--; b--; c--; d--;

	char s[200001];
	scanf("%s", s);

	int ans;
	if (d > c) {
		ans = 1;
		FOR(i, a + 1, c - 1) {
			if (s[i] == '#'&&s[i + 1] == '#'){
				ans = 0;
			}
		}
		FOR(i, b + 1, d - 1) {
			if (s[i] == '#'&&s[i + 1] == '#') {
				ans = 0;
			}
		}
	}
	else {
		ans = 0;
		FOR(i, b - 1, d) {
			if (s[i] == '.'&&s[i + 1] == '.'&&s[i + 2] == '.') {
				ans = 1;
			}
		}
		FOR(i, a + 1, c - 1) {
			if (s[i] == '#'&&s[i + 1] == '#') {
				ans = 0;
			}
		}
	}

	if (ans) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-9;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    const Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    const Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    const Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y-p.y, 2.0) + pow(x-p.x, 2.0));
    }
    double dist2(const Point& p) const{
        return pow(y-p.y, 2.0) + pow(x-p.x, 2.0);
    }
};

int solve(vector<Point>& vp)
{
    int n = vp.size();
    int ret = 1;

    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            double dist = vp[i].dist(vp[j]);
            if(dist > 2.0)
                continue;

            for(int k=0; k<2; ++k){
                Point p = vp[j] - vp[i];
                Point p1(p.x, p.y);
                if(k == 0)
                    p1.x *= -1;
                else
                    p1.y *= -1;
                p = vp[i] + p * 0.5 + p1 * (sqrt(pow(dist, -2) - 0.25));
                int num = 0;
                for(int l=0; l<n; ++l){
                    if(p.dist2(vp[l]) < 1.0 + EPS)
                        ++ num;
                }
                ret = max(ret, num);
            }
        }
    }

    return ret;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;

        vector<Point> p(n);
        for(int i=0; i<n; ++i)
            cin >> p[i].x >> p[i].y;
        cout << solve(p) << endl;
    }
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
#define int long long
vector<int>a(N);
int32_t main() 
{
    int n,k; cin>>n>>k; a.resize(n);
    for(int i=0;i<n;i++)  cin>>a[i];
    sort(a.begin(),a.end());
    
    int l=-1e18+1,r=1e18+1;
    while(r-l>1)
    {
        int mid=(l+r)>>1;  int ans=0;
        for(int i=0;i<n;i++)
        {
          if(a[i]<0)
         {
            int lx=-1,rn=n;
            while(rn-lx>1)
            {
                int curr=(rn+lx)>>1;
                if(a[curr]*a[i]<mid) rn=curr;
                else lx=curr; 
            }
             ans+=(n-rn);
         }
        
        else
        {
            int lx=-1,rn=n;
            while(rn-lx>1)
            {
                int curr=(rn+lx)>>1;
                if(a[curr]*a[i]<mid) lx=curr;
                else rn=curr;
            }
          ans+=rn;
        }
         if(a[i]*a[i]<mid) ans--;
    }
       ans/=2;
       if(ans<k) l=mid;
       else r=mid; 
    }
    cout<<l; return 0;
}

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

using namespace std;
#define BUF (105)
#define ll long long 

int n;
int a[BUF];
int main(void){
	cin >> n;
	int ans = 0;
	int cnt = 0;
	a[0] = -1;
	for ( int i=1;i<=n;i++){
		cin >> a[i];
		if(a[i-1]==a[i]) cnt++;
		else {
			ans += (cnt+1)/2;
			cnt = 0;
		}
	}

	ans += (cnt+1)/2;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import heapq


n,m,s=map(int,input().split())
#隣接行列[金額,時間]
graph=[[] for i in range(n)]
#銀貨リスト
A=[]
for i in range(m):
    u,v,a,b=map(int,input().split())
    A.append(a)
    graph[u-1].append((v-1,a,b))
    graph[v-1].append((u-1,a,b))

change=[]
for i in range(n):
    c,d=map(int,input().split())
    change.append((c,d))

A_max=max(A)
max_money=(n-1)*A_max

s=min(s,max_money)

width=max_money+1
N=n*width
#新しい隣接リスト;(時間,行き先)
system=[[] for i in range(N)]
for index in range(N):
    #頂点
    city=index//width
    #持ち金
    money=index%width

    #頂点の移動
    for next in graph[city]:
        #移動可能か
        if money>=next[1]:
            next_index=next[0]*width+(money-next[1])
            system[index].append((next[2],next_index))

    #持ち金の移動(最大n*A_max回かかる)→1回分でよい
    if money+change[city][0]<max_money:
        system[index].append((change[city][1],index+change[city][0]))
    else:
        system[index].append((change[city][1],max_money))


def dijkstra_heap(s,n,edge):
    #頂点数のオーダーでscaleは変更せよ
    scale=10**6

    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*scale+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(scale)]:
            continue
        v = minedge%(scale)
        d[v] = minedge//(scale)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*scale+e[1])
    return d


D=dijkstra_heap(s,N,system)
for i in range(1,n):
    ans=float('inf')
    for index in range(i*width,(i+1)*width):
        ans=min(ans,D[index])

    print(ans)


Measured memory_bytes: 113356
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
      if(n == 1){
        System.out.println(1);
        return;
      }
		for(int i = 0 ; i < n ; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int length = h.length;
		boolean[] checked = new boolean[h[n - 1] + 1];
		Arrays.fill(checked, false);
		for(int i = 0 ;  i < h.length ; i++) {

			if(checked[h[i]])
				continue;

			for(int j = h[i] ; j <= h[n - 1] ; j += h[i]) {

				if(h[i] == j) {

					if(i == 0) {
						if(h[i] == h[i + 1])
							checked[j] = true;
					}
					else if(i == h.length - 1) {
						if(h[i] == h[i - 1])
							checked[j] = true;
					}else
						if(h[i] == h[i + 1] || h[i] == h[i - 1])
							checked[j] = true;
				}
              else
                checked[j] = true;
			}
		}
		int count = 0;
		for(int i = 0 ; i < h.length ; i++) {
			if(!checked[h[i]])
				count++;

		}

		System.out.println(count);

	}
}



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

int main(){
    int n;
    cin >> n;
    vector<vi> kani(9,vi(9,0));
    for(int i=1;i<=n;i++){
        int top,end;
        end=i%10;
        if(end==0) continue;
        int temp=i;
        while(temp>0){
            top=temp%10;
            temp/=10;
        }
        kani[top-1][end-1]++;
    }
    ll ans=0;
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            ans+=kani[i][j]*kani[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
// C - Skolem XOR Tree
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, k = 0;
	cin >> n;
	while ((1 << k) < n) k++;
	if ((1 << k) == n) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		for (int i = 1; i < 3; i++) cout << i << ' ' << i + 1 << endl;
		cout << 3 << ' ' << n + 1 << endl;
		for (int i = 1; i < 3; i++) cout << (i + n) << ' ' << i + 1 + n << endl;
		for (int i = 4; i + 1 <= n; i += 2) {
			cout << (n + 1) << ' ' << i + 1 << endl;
			cout << i + 1 << ' ' << i << endl;
			cout << (n + 1) << ' ' << i + n << endl;
			cout << i + n << ' ' << i + 1 + n << endl;
		}
		if (n % 2 == 0) {
			bool found = false;
			for (int i = 2; i < n && !found; i++)
				for (int j = i + 1; j < n && !found; j++)
					if ((i ^ j ^ 1) == n) {
						found = true;
						cout << (i % 2 ? i : i + n) << ' ' << n << endl;
						cout << (j % 2 ? j : j + n) << ' ' << n * 2 << endl;
					}
		}
	}

	return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {

  int n,a,b,c;
  scanf("%d %d %d %d", &n, &a, &b, &c);
  int l[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int min = -1;
  int mp;
  int generate[n];
  for (int i = 0; i < n; i++) {
    generate[i] = 0;
  }
  int forA,forB,forC;
  int length;
  for (int i = 0; i < pow(4,n)-1; i++) {
    generate[0]++;
    for (int j = 1; j < n; j++) {
      generate[j] += generate[j-1]/4;
      generate[j-1] %= 4;
    }
    mp = 0;
    forA = 0;
    length = 0;
    for (int j = 0; j < n; j++) {
      if (generate[j] == 1) {
        forA++;
        length += l[j];
      }
    }
    if (length == 0) {
      continue;
    }
    mp += (forA-1)*10+abs(a-length);
    forB = 0;
    length = 0;
    for (int j = 0; j < n; j++) {
      if (generate[j] == 2) {
        forB++;
        length += l[j];
      }
    }
    if (length == 0) {
      continue;
    }
    mp += (forB-1)*10+abs(b-length);
    forC = 0;
    length = 0;
    for (int j = 0; j < n; j++) {
      if (generate[j] == 3) {
        forC++;
        length += l[j];
      }
    }
    if (length == 0) {
      continue;
    }
    mp += (forC-1)*10+abs(c-length);
    if (min == -1 || mp < min) {
      min = mp;
    }
  }
  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

int n, m, a[1001], b[1001], point[1001];
int main()
{
  cin >> n >> m;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= m; i++) cin >> b[i];
  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      if(b[i] >= a[j]){
	point[j]++;
	break;
      }
    }
  }
  int mx = 1;
  for(int i = 2; i <= n; i++){
    if(point[i] > point[mx]) mx = i;
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

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;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y;
	cin >> x >> y;
	cout << x + y/2 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100
#define INF 1 << 30

int n, A[MAX][MAX], d[MAX];
bool vis[MAX];

void dijkstra(int s){
  for ( int i = 0; i < n; i++){
    d[i] = A[s][i];
    vis[i] = false;
  }
  d[s] = 0;
  vis[s] = true;

  while ( 1 ){
    int minCost = INF;
    for ( int i = 0; i < n; i++){
      if ( !vis[i] && minCost > d[i]){
        minCost = d[i];
        s = i;
      }
    }

    if ( minCost == INF ) break;
    vis[s] = true;

    for ( int i = 0; i < n; i++){
      if ( !vis[i] && d[i] > d[s] + A[s][i]){
        d[i] = d[s] + A[s][i];
      }
    }
  }
}

int main(){
  cin >> n;

  // init
  for ( int i = 0; i < n; i++){
    for ( int j = 0; j < n; j++ ){
      A[i][j] = INF;
    }
  }


  int u, k, v, c;
  for ( int i = 0; i < n; i++){
    cin >> u >> k;
    for ( int j = 0; j < k; j++){
      cin >> v >> c;
      A[u][v] = (c == -1) ? INF : c;
    }
  }

  dijkstra(0);

  for ( int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
int w,x,y,z,a,b,c,d;
int main(void){
    cin>>w>>x>>y>>z>>a>>b>>c>>d;
    int h=w*a+x*b+w/10*c+x/20*d;
    int k=y*a+z*b+y/10*c+z/20*d;
    if(h==k)cout<<"even\n";
    else if(h>k)cout<<"hiroshi\n";
    else cout<<"kenjiro\n";
}



Measured memory_bytes: 3096
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
 
   cin >> n;
  
   int ans = 0;
   for(int i = 1;i<10;i++){
     
     if(n%i==0&&n/i<10){
        
       
       ans = 1;
     }

   }
  
  if(ans==1){
    cout << "Yes" << endl;
  }else{
     cout << "No" << endl;
  }
  
  
   
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define read(type) readInt<type>() // Fast read
#define ll long long
#define nL "\n"
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))

int main()
{
    int n; cin >> n;
    int arr[n+1];
    int ans = 0;
    for(int i = 1; i <= n;i++) {
        cin >> arr[i];
        if(i % 2 == 1 and arr[i] % 2 == 1) {
            ans ++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{int c=0;
  int n;
  cin>>n;
  char s[n];
  int i;
  for(i=0;i<n;i++)
  {
    cin>>s[i];
  }
    for(i=0;i<n-2;i++)
 {
  if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
  {
    c++;
  }
 }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
  //  cin>>t;
    while(t--){
      int n,m;
      cin>>n>>m;
      int res= n*(n-1)/2 + (m*(m-1))/2;

      printf("%d\n", res);

        //printf("Case %d: ",++te);
    }
    return 0;
}




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

int main()
{
    std::string word;
    std::cin>> word;
    int64_t count = 1;
    int64_t size = static_cast< int >( word.size() );
    bool first = false;
    
    for( int64_t i = 1; i < size; i++ )
    {
        if( word[i-1] != word[i]
            || first )
        {
            count += 1;
            first = false;
        }
        else if( i != size - 1 )
        {
            count += 1;
            i += 1;
            first = true;
        }
    }

    std::cout<< count;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  ll sum = 0;
  vl d(n, 0);
  rep(i, n) {
    d[i] = a[i] / n;
    sum += d[i];
  }
  while(sum) {
    ans += sum;
    rep(i, n) {
      a[i] -= d[i] * n;
      a[i] += sum - d[i];
    }
    sum = 0;
    rep(i, n) {
      d[i] = a[i] / n;
      sum += d[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 
int main(){
    IOS;
   string s,t;
   cin>>s>>t;
   int m=s.length();
   int n=t.length();
   int dp[m+1][n+1];
   for(int i=0;i<=m;i++){
    for(int j=0;j<=n;j++){
      if(i==0||j==0)
        dp[i][j]=0;
      else{
        if(s[i-1]==t[j-1])
          dp[i][j]=dp[i-1][j-1]+1;
        else
          dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      }
    }
   }
       //cout<<dp[m][n]<<endl;
    string ans="";
    int i=m,j=n;

    while(i>0 && j>0){
      if(s[i-1]==t[j-1])
      {
        ans=s[i-1]+ans;
        i--,j--;
      }
      else{
        if(dp[i-1][j]>dp[i][j-1])
          i--;
        else
          j--;
      }
    }
    cout<<ans<<endl;
}
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
 
  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '1') {
      count++;
    }
  }
 
  cout << count << endl;
}

Measured memory_bytes: 256
from collections import deque

def updiv(a,b):
    if a % b == 0:
        return a // b
    else:
        return a // b + 1

H,W,K = map(int,input().split())

A = []

for i in range(H):

    a = list(input())
    A.append(a)

q = deque([])

#print (A)

for i in range(H):

    for j in range(W):

        if A[i][j] == "S":
            q.append([i,j])
            A[i][j] = 0

while len(q) > 0:

    now = q.popleft()
    ni = now[0]
    nj = now[1]

    if A[ni][nj] < K:
        if ni-1 >= 0 and A[ni-1][nj] != "#":
            if A[ni-1][nj] == "." or A[ni][nj]+1 < A[ni-1][nj]:
                A[ni-1][nj] = A[ni][nj] + 1
                q.append([ni-1,nj])

        if ni+1 < H and A[ni+1][nj] != "#":
            if A[ni+1][nj] == "." or A[ni][nj]+1 < A[ni+1][nj]:
                A[ni+1][nj] = A[ni][nj] + 1
                q.append([ni+1,nj])

        if nj-1 >= 0 and A[ni][nj-1] != "#":
            if A[ni][nj-1] == "." or A[ni][nj]+1 < A[ni][nj-1]:
                A[ni][nj-1] = A[ni][nj] + 1
                q.append([ni,nj-1])

        if nj+1 < W and A[ni][nj+1] != "#":
            if A[ni][nj+1] == "." or A[ni][nj]+1 < A[ni][nj+1]:
                A[ni][nj+1] = A[ni][nj] + 1
                q.append([ni,nj+1])

ans = float("inf")
#print (A)

for i in range(H):

    for j in range(W):

        if A[i][j] not in [".","#"]:
            ans = min(ans , 1 + updiv(i,K) , 1 + updiv(j,K) , 1 + updiv(H-i-1,K), 1 + updiv(W-j-1, K))

print (ans)


Measured memory_bytes: 142188
def rotateDice(direction: str, dice: list) -> list:
    s = {'N': "152304", 'W': "215043", 'E': "310542", 'S': "402351", 'R': "031425", 'L': "024135"}
    dice = [dice[int(i)] for i in s[direction]]
    return dice


dice1 = input().split()
dice2 = input().split()
all_dice_list = []
for i in range(4):
    dice1 = rotateDice('E', dice1)
    for j in range(4):
        dice1 = rotateDice('N', dice1)
        for k in range(4):
            dice1 = rotateDice('R', dice1)
            all_dice_list.append(dice1)

counter = 0
for _list in all_dice_list:
    if _list == dice2:
        print('Yes')
        counter += 1
        break

if counter == 0:
    print('No')



Measured memory_bytes: 5604
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

l = list(input())
# print(type(l))
for i in range(len(l)):
    if l[i]=='1':
        l[i] = '9'
    else:
        l[i] = '1'
ll = "".join(l)
print(ll)


Measured memory_bytes: 14244
N= eval(input())

x = []
u = []
for it in range(N):
    tmpx, tmpu = input().split()
    x.append(eval(tmpx))
    u.append(tmpu)

count = 0
for it in range(N):
	if u[it] == 'JPY':
		count += x[it]
	elif u[it] == 'BTC':
		count += x[it]*380000.0

print(count)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long sum = 0;
    
    for(int i = 1 ; i < n + 1 ; i++){
        if(i % 3== 0 && i % 5 == 0){

        }else if(i % 3 == 0){

        }else if(i % 5 == 0){

        }else{
            sum += i;
        }
    
    }
    
    System.out.println(sum);
}
}

Measured memory_bytes: 35820
#include <iostream>
#include <vector>
#include <algorithm>
int k, n;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> k;
    if (k == 1) {
        std::cout << 1 << "\n";
        std::cout << 1 << "\n";
        return 0;
    }
    int n = 2 * ((k + 3) / 4);
    std::cout << n << "\n";
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int c = (i + j) % n + (i % 2 == 0 ? 0 : n);
            if (c >= k)
                c -= n;
            std::cout << c + 1 << " \n"[j == n - 1];
        }
    }
    return 0;
}

Measured memory_bytes: 1280
import itertools
import math

n = int(input())
p = int("".join(input().split()))
q = int("".join(input().split()))

t = []
for i in range(1, n + 1):
  t.append(str(i))

l = itertools.permutations(t)
m = []
for a in l:
  m.append(int("".join(a)))

p_index = -1
q_index = -1
m.sort()
for i in range(len(m)):
  if m[i] == p:
    p_index = i
  if m[i] == q:
    q_index = i

print(abs(p_index - q_index))



Measured memory_bytes: 4784