akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int n;
    cin >> n >> s;
    int sol = 0;
    for (int i = 1; i < n; ++i)
    {
        vi a(30), b(30);
        for (int j = 0; j < i; ++j)
            a[s[j] - 'a'] = 1;
        for (int j = i; j < n; ++j)
            b[s[j] - 'a'] = 1;
        int sum = 0;
        for (int i = 0; i < 30; ++i)
            if (a[i] && b[i])
                sum++;
        sol = max(sol, sum);
    }
    cout << sol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 1010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define elif else if
#define lld long double
#define r0 return 0
#define EPS 1e-7
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
const ll mods[2] = {1000000009ll, 1000000007ll};
const ll p[2] = {31, 53};
 
using namespace std;
using namespace __gnu_pbds;

int main()
{
	barnarnar
	string s;
	cin >> s;
	int ans = 0, cur = 0;
	forn(i, s.si)
	{
		if(s[i] == 'R')	cur++;
		else
		{
			ans = max(ans, cur);
			cur = 0;
		}
	}
	cout << max(ans, cur);
}	
// # pog-unlimitation

/*
Merami isn't so great?
Are you kidding me?
When was the last time you saw a player with such aim ability and movement with a tablet?
Merami puts the game in another level, and we will be blessed if we ever see a player with his skill and passion for the game again.
Whitecat breaks records.
Vaxei breaks records.
Merami breaks the rules.
You can keep your statistics.
I prefer the magic.
*/

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

using namespace std;

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

    int k, n;

    cin >> k >> n;

    int itv_max = 0, a0, a = 0, b;

    cin >> a0;
    a = a0;
    for(int i = 1; i < n; ++i) {
        cin >> b;
        itv_max = max(itv_max, b - a);
        a = b;
    }
    itv_max = max(itv_max, k + a0 - a);

    printf("%d\n", k - itv_max);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    string s;
    cin>>s;
    int len=s.length();
    int count=0;
    for(int i=0;i<len/2;i++){
        if(s[i]!=s[len-i-1]) count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

const ll mod=1e9+7;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),sa(n,0);
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(i==0) sa[n-1-i]=a[n-1-i];
        else sa[n-1-i]=(sa[n-i]+a[n-1-i])%mod;
    }
    ll ans=0;
    rep(i,n-1) ans+=a[i]*sa[i+1],ans%=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
int n=100001;
int a[100001],b[100001],c[100001];
int ca[100001],cb[100001],cc[100001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];
	for(int i=1;i<=n;i++){
		ca[i]=max(cb[i-1],cc[i-1])+a[i];
		cb[i]=max(ca[i-1],cc[i-1])+b[i];
		cc[i]=max(cb[i-1],ca[i-1])+c[i];
	}
	cout<<max(max(ca[n],cb[n]),cc[n]);
	return 0;
}

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

int main() {

    int n;

    cin >> n;

    vector<int> a;

    for(int i=0; i<n; i++){
        int input;
        cin >> input;
        a.push_back(input);
    }
    a.push_back(0);

    sort(a.begin(),a.end(),greater<int>());

    int Alice=0,Bob=0;

    for(int i=0; i<n; i+=2){
        Alice += a[i];
        Bob += a[i+1];
    }

    cout << Alice - Bob << endl;

    return 0;
}

Measured memory_bytes: 256
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define findnot find_first_not_of
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD funcions*/
int main()
{
    kira;
    lli c=0;
    string s;
    cin>>s;
    lli n=s.si;
    forz(i,n/2)
    {
        if(s[i]!=s[n-1-i])c++;
    }
    p0(c);
    return 0;
}

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

using namespace std;
int mod = 1e9+7;
int fac[200005];
int ifac[200005];

int power(int x,int y)
{
    if(y==0)
        return 1;
    int tmp = power(x,y/2);
    if(y&1)
        return ((tmp*tmp)%mod * x)%mod;
    else
        return (tmp*tmp)%mod;
}

int C(int k,int n)
{
    int ans = fac[n];
    ans *= ifac[k];
    ans %= mod;
    ans *= ifac[n-k];
    ans %= mod;

    return ans;
}

signed main()
{
    int h,w,a,b;
    cin>>h>>w>>a>>b;

    fac[0] = 1;
    for(int i=1;i<=200000;i++)
        fac[i] = (fac[i-1] * i) % mod;

    ifac[200000] = power(fac[200000],mod-2);
    for(int i = 200000 - 1;i>=0;i--)
        ifac[i] = (ifac[i+1] * (i+1)) % mod;


    int ans = 0;
    for(int i=b+1;i<=w;i++)
    {
        ans += (C(i-1,i+h-a-2) * C(a-1,w+a-i-1))%mod;
        ans %= mod;
    }

    cout<<ans;

}


Measured memory_bytes: 3328
from copy import copy

def make_divisors(n):
    """約数を全列挙する
    """
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


N0 = int(input())
cand = set(make_divisors(N0) + make_divisors(N0-1))

ans = 0
for K in cand:
    if K == 1:
        continue
    N = copy(N0)
    while N%K == 0:
        N //= K
    N %= K
    if N == 1:
        ans += 1

print(ans)


Measured memory_bytes: 4424
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, l, s = 0, m = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &l);
        s += l;
        m = max(m, l);
    }
    printf("%s\n", (m < s - m ? "Yes" : "No"));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
const int MOD=1e9+7; 
int main(){

	long long int n,s; 
	cin>>n>>s; 

	long long int count=0; 

	if(n>s/2) count=s/2; 
	else{
		
		s=s-2*n; 
		count=n; 
		count+=s/4; 

	}

	cout<<count<<endl;
	return 0; 
}

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

int main() {
	int Min[26], n;
	string s;
	cin >> n;
	for (int i = 0; i < 26; i++) {
		Min[i] = 50;
	}
	for (int i = 0; i < n; i++) {
		cin >> s;
		int sum[26] = {};
		for (int j = 0; j < s.size(); j++) {
			int x = s[j] - 97;
			sum[x]++;
		}
		for (int j = 0; j < 26; j++) {
			Min[j] = min(Min[j], sum[j]);
		}
	}
	for (int i = 0; i < 26; i++) {
		char c = i + 97;
		for (int j = 0; j < Min[i]; j++) {
			cout << c;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	string n;
	cin>>n;
	if(n[0]==n[sz(n)-1]) cout<<"Yes";
	else cout<<"No";
	re 0;
}

Measured memory_bytes: 3656
n=int(input())
A=[int(i) for i in input().split()]

A1=A[0]
A2=A[1]

c=0
for ele in A[2:]:
    c^=ele

d=A1+A2-c
if d%2==1:
    print(-1)
else:
    d=d//2
    #print(bin(c),bin(d))
    flgs=[]
    
    for i in range(41):
        fand= d & (1<<i)
        fxor= c & (1<<i)
        
        if fand & fxor:
            print(-1)
            break
        elif fand:
            flgs.append(1)
        elif fxor:
            flgs.append(2)
        else:
            flgs.append(0)
    else:
        flgs=flgs[::-1]
        #print(flgs)
        ans=0
        for i in range(len(flgs)):
            if flgs[i]==1:
                ans+=2**(41-i-1)
        
        if ans>A1:
            print(-1)
        else:
            
            for i in range(len(flgs)):
                if flgs[i]==2:
                    if ans + 2**(41-i-1) <= A1:
                        ans+=2**(41-i-1)
            
            #print(ans)
            
            if ans==0:
                print(-1)
            else:
                print(A1-ans)
            
                    
                    
            
        
        

Measured memory_bytes: 9112
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import math
#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	H,W=map(int,input().split())
	ans=[]
	target=H*W/3
	
	if (H%3)*(W%3)==0:
		ans.append(0)
	else:
		ans.append(H)
		ans.append(W)
		
		a1=math.floor(H/3)*W
		a2=(W//2)*(H-math.floor(H/3))
		a3=H*W-a1-a2
		ans.append(max(a1,a2,a3)-min(a1,a2,a3))
		
		a1=math.ceil(H/3)*W
		a2=(W//2)*(H-math.ceil(H/3))
		a3=H*W-a1-a2
		ans.append(max(a1,a2,a3)-min(a1,a2,a3))
		
		H,W=W,H
		
		a1 = math.floor(H / 3) * W
		a2 = (W // 2) * (H - math.floor(H / 3))
		a3 = H * W - a1 - a2
		ans.append(max(a1, a2, a3) - min(a1, a2, a3))
		
		a1 = math.ceil(H / 3) * W
		a2 = (W // 2) * (H - math.ceil(H / 3))
		a3 = H * W - a1 - a2
		ans.append(max(a1, a2, a3) - min(a1, a2, a3))
		
	print(min(ans))


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
//uses crt;
var str:string;
    cnta,cntb,i,cnt :longint;
    cha,chb:char;
begin
//clrscr;
readln(str);
cha:=str[1];
cnta:=1;
if str[2]<>str[1] then begin
                       chb:=str[2];
                       cntb:=1;
                       if str[3]=cha then inc(cnta)
                       else if str[3]=chb then inc(cntb);
                       if str[4]=cha then inc(cnta)
                       else if str[4]=chb then inc(cntb);
                       end
else begin
     if (str[3]=str[4]) and (str[3]<>cha) then begin
                                               cnta:=2;
                                               cntb:=2;
                                               end;
     end;
if (cnta=cntb) and (cnta=2) then Writeln('Yes') else Writeln('No');
end.



Measured memory_bytes: 128
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll cnt=0;
	string t="";
	for(ll i=0;i<n;i++)
	{
		if(s[i]==')' && cnt==0)
			t='('+t;
		else if(s[i]==')') 
			cnt--;
		else	
			cnt++;
		t+=s[i];
	}
	while(cnt>0)
	{
		t+=')';
		cnt--;
	}
	cout<<t;
	return;
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
#define pb push_back
#define mp make_pair
bool used[7568791];
int main(){
	while(1){
		int m,n; cin >> m >> n;
		if(m==0) return 0;
		memset(used,0,sizeof(used));
		int cnt = n;
		for(int i=m;i<=7468791;i++){
			if(used[i])continue;
			if(cnt==0){ printf("%d\n",i); break; }
			cnt--;
			for(int j=i;j<=7468791;j+=i) used[j] = 1;
		}
	}
}

Measured memory_bytes: 10588
import numpy as np
import random

rand = False
if rand:
    N = 10 ** 5
    A = random.choices(range(1, 10**6), k=N)
else:
    N = int(input())
    A = list(map(int, input().split()))

A.sort()
MX = max(A)
ret = np.zeros(MX+1, dtype=np.bool)
A = np.array(A, dtype=np.int32)
ret[ A ] = True

for i in range(N-1):
    m = A[i] * 2
    if A[i] == A[i+1]: m = A[i]
    ret[ np.arange(m, MX+1, A[i]) ] = False

print(np.sum(ret))

    




Measured memory_bytes: 51416
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()

print(N ** 3)


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

int main() {
  int N, K, sum;
  cin >> N >> K;
  sum = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    if (x < K - x){
      sum += x;
  	}
  	else {
      sum += K - x;
  	}
  }
  
  cout << sum * 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	int s[100]={};
	int ans=0;
	for(int i=0;i<n;i++){
		cin >> s[i];
		ans+=s[i];
	}
	sort(s,s+n);
	int i;
	for(i=0;i<n;i++){
		if(ans%10!=0) break;
		else if(i!=0) ans+=s[i-1];
		ans-=s[i];
	}
	if(i==n) cout << 0 << endl;
	else cout << ans << endl;

}


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

void solve() 
{
 int n,m;cin>>n>>m;
 cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

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

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a%2 != b%2) cout << "IMPOSSIBLE" << endl;
    else cout << (a + b)/2 << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int max = 0;
        int min = 1000;
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            max = Math.max(max, a);
            min = Math.min(min, a);
        }
        System.out.println(max - min);
    }
}


Measured memory_bytes: 23892
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

#define int long long

int32_t main() {
    fio
    int k;cin >> k;
    string s;
    cin >> s;
    if(sz(s) <=k) {cout << s << endl;}
    else{
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "..." ;
    }

}






Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n;

    bool resx,resy;

    resx = (n/100>=1&&n/100<=12);
    resy = (n%100>=1&&n%100<=12);

    if(resx&&resy)cout<<"AMBIGUOUS\n";
    else if(resx)cout<<"MMYY\n";
    else if(resy)cout<<"YYMM\n";
    else cout<<"NA\n";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define LL long long
#define RG register
using namespace std;
const int N=1e5+10;
int n; LL a[N];
inline LL read(){
	char ch=getchar(); LL x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n);
	if(n%2==0)
	{
		LL tt=-a[n/2];
		for(int i=1;i<=n/2;i++) tt+=2*a[i];
		tt=-tt;
		for(int i=n/2+1;i<=n;i++) tt+=2*a[i];
		tt-=a[n/2+1];
		printf("%lld\n",tt);  
	}
	else {
		LL tt1=0,tt2=0;
		for(int i=1;i<=n/2;i++) tt1+=2*a[i];
		tt1=-tt1;
		for(int i=n/2+1;i<=n;i++) tt1+=2*a[i];
		tt1-=a[n/2+1]; tt1-=a[n/2+2];
		
		for(int i=1;i<=n/2+1;i++) tt2+=2*a[i];
		tt2-=a[n/2+1]; tt2-=a[n/2];
		tt2=-tt2;
		for(int i=n/2+2;i<=n;i++) tt2+=2*a[i];
		printf("%lld\n",max(tt1,tt2));
	}
//	fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int dp[1010][1010];

int main() {
    int q;  cin >> q;
    int *ans = new int[q];
    string s, t;
    int ls, lt, i, j;
    for (int k = 0; k < q; k++) {
        cin >> s >> t;
        ls = s.size(), lt = t.size();

        for (i = 0; i <= ls; i++) {
            for (j = 0; j <= lt; j++)
                dp[i][j] = 0;
        }

        for (i = 0; i < ls; i++) {
            for (j = 0; j <= lt; j++) {
                if (s[i] == t[j])
                    dp[i+1][j+1] = max(dp[i][j]+1, max(dp[i+1][j], dp[i][j+1]));
                else
                    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }   
        ans[k] = dp[ls][lt];
    }
    for (int k = 0; k < q; k++)
        cout << ans[k] << endl;
    return 0;
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if (regex_match(S, regex("A?(KIH)A?(B)A?(R)A?"))) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e5;
const long inf=1e9;
int main(){
	string s; cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<vector<long long>> d(N, vector<long long>(N, 0));

  rep(i, N) rep(j, N)
  {
    cin >> d[i][j];
  }
  long long ans = 0;
  bool is_ok = true;
  for (int s = 0; s < N; s++)
  {
    for (int e = s + 1; e < N; e++)
    {
      long long min_cost = d[s][e];
      bool is_updated = false;
      for (int u = 0; u < N; u++)
      {
        if (u == s || u == e)
          continue;
        long long cost = d[s][u] + d[u][e];
        if (cost <= min_cost)
        {
          min_cost = cost;
          is_updated = true;
        }
      }
      if (min_cost != d[s][e])
        is_ok = false;
      else if (!is_updated)
        ans += d[s][e];
    }
  }

  if (!is_ok)
    ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    int fact[n+1];
    fact[0] = 1;
    for(int i=1;i<=n;i++)
    {
        fact[i] = fact[i-1]*i;
    }
    int X[n],Y[n];
    for(int i=0;i<n;i++)
    {
        cin>>X[i]>>Y[i];
    }
    int fac = fact[n-1]*2;
    double ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans += sqrt((X[j]-X[i])*(X[j]-X[i]) + (Y[j]-Y[i])*(Y[j]-Y[i]));
        }
    }

    ans = ans*fac;
    ans /= fact[n];
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#include<string>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
#define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lcm(a,b) (a*b)/__gcd(a,b)
#define set_bit_count(x) __builtin_popcount(x)
#define leading_zero_count(x) __builtin_clz(x)
#define tailing_zero_count(x) __builtin_ctz(x)
#define str_rev(str) reverse(str.begin(),str.end())
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
using namespace std;
vector<vector<ll> > vec2d;
vector<pair<ll, ll> > vec_pair;
// unordered_map<ll, ll> ump;
multiset<ll> node[200003];
map<ll, ll> omp;
ll pown(ll a, ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	return pown(a,b/2)*pown(a,b-b/2);
}
int main()
{
	ll n,a,b;
	cin>>n;
	ll minm=100000000000000;
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(abs(i-n/i)<minm)
			{
				minm=abs(i-n/i);
				a=i;
				b=n/i;
			}
		}
	}
	cout << a+b-2 << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=2010;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
template<typename T>
struct Segtree{
    using F=function<T(T,T)>;
    int siz;
    vector<T> dat;
    const F f;
    const T t1;
    Segtree(int n,const F f,const T &t1):f(f),t1(t1){
        siz=1;
        while(siz<n)siz<<=1;
        dat.assign(2*siz,t1);
    }
    void set(int k,const T &tt){
        dat[k+siz]=tt;
    }
    void build(){
        for(int k=siz-1;k>0;k--){
            dat[k]=f(dat[2*k+0],dat[2*k+1]);
        }
    }
    void update(int k,const T &tt){
        k+=siz;
        dat[k]=tt;
        while(k>>=1){
            dat[k]=f(dat[2*k],dat[2*k+1]);
        }
    }
    T query(int a,int b){
        T l1=t1;T r1=t1;
        for(a+=siz,b+=siz;a<b;a>>=1,b>>=1){
            if(a&1){
                l1=f(l1,dat[a++]);
            }
            if(b&1){
                r1=f(dat[--b],r1);
            }
        }
        return f(l1,r1);
    }
    T operator[](const int &k) const{
        return dat[k+siz];
    }
};
int main(){
    auto s=[](int a,int b){return a+b;};
    int n,q;cin>>n>>q;
    Segtree<int> seg(n,s,0);
    while(q--){
        int com,x,y;cin>>com>>x>>y;
        if(com){
            cout<<seg.query(x,y+1)<<endl;
        }else{
            seg.update(x,seg[x]+y);
        }
    }
	return 0;
}


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

int main(){
  int N;
  vector<int> a;
  cin >> N;
  int b;
  for(int i=0;i<N;i++){
    cin >> b;
    a.push_back(b);
  }
  int count =0;
  for(int i=0;i<N;i++){
    if(i+1==a[i]){
      i++;
      count++;
    }
  }
  cout<<count << endl;
}


Measured memory_bytes: 892
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int n = scanner.nextInt();
        int min = Math.min((n + h-1)/h, (n + w -1)/w);
        out.println(min);
        out.flush();
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int judge(string s, int n)
{	
	int tmp = 0;
	REP(i, n){
		if((s[i] == 'A') || (s[i] == 'C') || (s[i] == 'G') || (s[i] == 'T')) tmp++;
		else break;
	}
	return tmp;
}

int main()
{
	string s;
	cin >> s;
	size_t size = s.length();
	vector<int> count(size);

	REP(i, size) count[i] = judge(s.substr(i), size);
	int max = *max_element(count.begin(), count.end());
	cout << max << endl;
}

Measured memory_bytes: 256
n = int(input())
prime = [2,3,5,7,11,13]
dist_list = list((0,0,0,0,0,0))
ans_count = 0
count_origin = 1
prime_count = 0
while count_origin<= n:
  if count_origin % 2 == 0:
    count_origin += 1
    continue
  count = count_origin 
  while prime_count < 6:
    while count % prime[prime_count] == 0:
      count /= prime[prime_count]
      dist_list[prime_count] += 1
    prime_count += 1
  prime_count = 0
  result = 1
  for number in dist_list:
    result *= (number+1)
  if result == 8:
    ans_count += 1
  dist_list = list((0,0,0,0,0,0))
  count_origin += 1
print(ans_count)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
//????????????????????蔵?????????????????????????????属???????????則??????
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][] cards = new int[4][13];
		for(int i=0; i<n; i++){
			String m = scan.next();
			int k=-1;
			if(m.equals("S")) k=0;
			if(m.equals("H")) k=1;
			if(m.equals("C")) k=2;
			if(m.equals("D")) k=3;
			cards[k][scan.nextInt()-1]++;
		}
		for(int i=0; i<4; i++){
			for(int j=0; j<13; j++){
				if(cards[i][j]==0){
					switch(i){
					case 0: System.out.print("S "); break;
					case 1: System.out.print("H "); break;
					case 2: System.out.print("C "); break;
					case 3: System.out.print("D "); break;
					}
					System.out.println(j+1);
				}
			}
		}
		
		

	}

}

Measured memory_bytes: 18296
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll ans = 0;
  ll num;
  for(int i=1;i<=N;++i) {
    num = N/i;
    ans += i*num*(num+1)/2;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3612
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n; cin>>n;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin>>x[i];

    ll ans = INF;
    for(int i=1; i<=100; i++){
        ll sum = 0;
        for(int j=0; j<n; j++){
            sum += (x[j] - i) * (x[j] - i);
        }
        chmin(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
const ll mod = 1000000000 + 7;

int a[maxn], n, k, pre[maxn];
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        pre[i] = pre[i - 1] + a[i];
    }
    int mx = 0;
    for (int i = k; i <= n; i++) {
        mx = max(mx, pre[i] - pre[i - k]);
    }

    double ans = 0.5 * (mx + k);

    printf("%.8f\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define s(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int a,b,c,y=0,x=0;
	cin >> a >> b >> c;
	vector<int> str(b);
	rep(i, b) {
		cin >> str[i];
		if (str[i] < c)x++;
		if (str[i] > c)y++;
	}
	int ans = min(x, y);
	cout << ans << endl;

	return 0;
}



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

int main(){
    int A,B,M;
    cin >> A >> B >> M;
    int a[A];
    int b[B];
    int mina = 1<<30;
    int minb = 1<<30;
    for(int i =0; i < A; i++){
        cin >> a[i];
        if(a[i]< mina) mina = a[i];
    }
    for(int i =0; i < B; i++){
        cin >> b[i];
        if(b[i]<minb) minb = b[i];
    }
    int min = mina+minb;
    for(int i =0; i < M; i++){
        int x, y, c;
        cin >> x >> y >>c;
        int price =a[x-1]+ b[y-1]-c;
        if( price < min) min = price;
    }
    cout << min << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main(){
	IOS();
	vector<int>ans;
	while(1){
		int N;
		cin>>N;
		if(!N)break;
		int a[N][N]={};
		rep(i,0,N){
			int t;
			cin>>t;
			rep(j,0,t){
				int tt;
				cin>>tt;
				tt--;
				a[i][tt]=1;
			}
		}
		int K;
		cin>>K;
		vector<int>l(K);
		rep(i,0,K){
			cin>>l[i];
			l[i]--;
		}
		int flg = -2;
		rep(i,0,N){
			int ok = 1;
			rep(j,0,K){
				if(!a[i][l[j]]){
					ok=0;
				}
			}
			if(ok){
				if(flg==-2)flg = i;
				else{
					flg = -2;
					break;
				}
			}
		}
		ans.push_back(flg);
	}
	for(auto e:ans){
		cout<<e+1<<endl;
	}
}


Measured memory_bytes: 3300
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int hist[10] = {0};
		rep(i, n){
			int a;
			scanf("%d", &a);
			hist[a]++;
		}
		rep(i, 10){
			if(hist[i] == 0)
				puts("-");
			else
				puts(string(hist[i], '*').c_str());
		}
	}
	return 0;
}

Measured memory_bytes: 1028
import itertools
n = int(input())
ans = 0
cnt = { "M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(n):
    s = input()
    if s[0] in cnt:
        cnt[s[0]] += 1
c = itertools.combinations("MARCH", 3)
for i, j, k in c:
    ans += cnt[i] * cnt[j] * cnt[k]
print(ans)

Measured memory_bytes: 3064
H,W,K = map(int,input().split())
S = [input() for i in range(H)]

ans = H+W
for b in range(1<<(H-1)):
    tmp = bin(b).count('1')
    ks = [0]*H
    valid = True
    for col in zip(*S):
        j = 0
        for i,c in enumerate(col):
            if c=='1':
                ks[j] += 1
            if b&(1<<i):
                j = i+1
        if any(k > K for k in ks):
            tmp += 1
            ks = [0]*H
            j = 0
            for i,c in enumerate(col):
                if c=='1':
                    ks[j] += 1
                if b&(1<<i):
                    j = i+1
            if any(k > K for k in ks):
                valid = False
                break
    if valid:
        ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 48988
#include <iostream>

int main() {
    unsigned long long X;
    unsigned long long depositThisYear;

    std::cin >> X;
    depositThisYear = 100;
    for (int i = 1;; i++) {
        depositThisYear = static_cast<unsigned long long>(depositThisYear * 1.01);
        if (depositThisYear >= X) {
            std::cout << i << std::endl;
            break;
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
    vector<unsigned long long>d(6,0);
    int k;
    string s;
    cin>>k;
    for(int i=0;i<k;i++)
    {
        cin>>s;
        if(s[0]=='M')
            d[0]++;
        else if(s[0]=='A')
            d[1]++;
        else if(s[0]=='R')
            d[2]++;
        else if(s[0]=='C')
            d[3]++;
        else if(s[0]=='H')
            d[4]++;
    }
    //cout<<d[0]<<d[1]<<d[2]<<d[3]<<d[4];
    
   
    
   


    unsigned long long n1=d[0]*d[1]*d[2];
    unsigned long long n2=d[0]*d[1]*d[3];
    unsigned long long n3=d[0]*d[1]*d[4];
    unsigned long long n4=d[0]*d[2]*d[3];
    unsigned long long n5=d[0]*d[2]*d[4];
    unsigned long long n6=d[0]*d[3]*d[4];
    unsigned long long n7=d[1]*d[2]*d[3];
    unsigned long long n8=d[1]*d[2]*d[4];
    unsigned long long n9=d[1]*d[3]*d[4];
    unsigned long long n10=d[2]*d[3]*d[4];

   
   cout <<n1+n2+n3+n4+n5+n6+n7+n8+n9+n10;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        char[] alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
        int[] count = new int[27];
 
        while (scan.hasNext()) {
            String str = scan.next();
            char[] schar = str.toCharArray();
            for (char c : schar) {
                if (Character.isUpperCase(c))
                    c = Character.toLowerCase(c);
                for (int i = 0; i < alphabet.length; i++)
                    if (c == alphabet[i]) count[i] += 1;
            }
        }
        for (int i = 0; i < count.length - 1; i++)
            System.out.printf("%c : %d\n", alphabet[i], count[i]);
    }
    public static void main(String[] args) {
        new Main().run();
    }
}



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

int main() {
  string str;
  
  getline(cin,str);
  
  for(int i = 0; i < str.size(); i++) {
    if('a'<=str[i] && str[i]<='z') str[i]=str[i]-'a'+'A';
    cout << str[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    scanf("%d", &N);
    
    vector<int> A1, A2;
    for(int i=0; i<N; i++){
        int tmp;
        scanf("%d", &tmp);
        A1.push_back(tmp);
    }
    for(int i=0; i<N; i++){
        int tmp;
        scanf("%d", &tmp);
        A2.push_back(tmp);
    }
    
    //calc
    int ans = 0;
    for(int i=0; i<N; i++){
        int sum = 0;
        for(int j=0; j<=i; j++){
            sum += A1.at(j);
        }
        for(int j=i; j<N; j++){
            sum += A2.at(j);
        }
        if(ans < sum)ans = sum;
    }
    
    cout << ans << endl;
}


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

using namespace std;

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

    int arr[5]={};

    for(int i=0;i<5;i++){
        cin>>arr[i];
        if(arr[i]==0){
            cout<<i+1<<"\n";
        }
    }


    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,W;
  cin>>n>>W;
  constexpr int INF = 1e9+1;
  vecint dp(100001, INF);
  dp[0] = 0;
  for(auto&& i:irange(0,n)) {
    int w,v;
    cin>>w>>v;
    vecint tmp = dp;
    for(auto&& j:irange(0,100001)) {
      if (j+v > 100000) break;
      tmp[j+v] = min(tmp[j+v], dp[j] + w);
    }
    swap(tmp, dp);
  }
  int ans = 0;
  for(auto&& i:irange(0,100001)) {
    if(dp[i] <= W) {
      ans = i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

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

int main(){
    scanf("%s", s);
    int n = strlen(s);
    for(int i = 0 ; i + 1 < n ; ++i)
        if(s[i] == s[i + 1])
            return printf("%d %d", i + 1, i + 2), 0;
        else if(i + 2 < n && s[i] == s[i + 2])
            return printf("%d %d", i + 1, i + 3), 0;
    puts("-1 -1");
}

Measured memory_bytes: 384
x, k, d = [int(x) for x in input().split()]
x = abs(x)

if x - k*d >= 0:
    print(x - k*d)
else:
    m = x//d
    a = x - d*m
    b = d - a

    if (k-m) % 2:
        print(b)
    else:
        print(a)


Measured memory_bytes: 9192
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(mut aa: Vec<i32>) -> Vec<(usize, usize)> {
    let aa2 = aa.clone();
    aa.sort();
    let n = aa.len();

    if aa[0] >= 0 {
        (1..n).map(|i| (i, i+1)).collect::<Vec<_>>()
    } else if aa[n-1] <= 0 {
        (2..(n+1)).rev().map(|i| (i, i-1)).collect::<Vec<_>>()
    } else {
        if aa[0].abs() <= aa[n-1].abs() {
            let max_pos = aa2.iter().position(|&x| x == aa[n-1]).unwrap();
            let mut ret = (1..(n+1)).map(|i| (max_pos+1, i)).collect::<Vec<_>>();
            ret.extend((1..n).map(|i| (i, i+1)).collect::<Vec<_>>());
            ret

        } else {
            let min_pos = aa2.iter().position(|&x| x == aa[0]).unwrap();
            let mut ret = (1..(n+1)).map(|i| (min_pos+1, i)).collect::<Vec<_>>();
            ret.extend((2..n+1).rev().map(|i| (i, i-1)).collect::<Vec<_>>());
            ret
        }
    }
}

fn main() {
    read_line!();

    let aa = parse_vec!(i32);

    let ans = solve(aa);
    println!("{}", ans.len());

    for (x,y) in ans {
        println!("{} {}", x, y);
    }
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![-2,5,-1]), vec![(2,1),(2,2),(2,3),(1,2),(2,3)]);
    assert_eq!(solve(vec![-1,-3]), vec![(2,1)]);
    assert_eq!(solve(vec![0,0,0,0,0]), vec![(1,2),(2,3),(3,4),(4,5)]);
}


Measured memory_bytes: 4352
n = int(input())
l = sorted(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] !=  l[j] != l[k]:
                if l[i] + l[j] > l[k]:
                    count+=1
print(count)

Measured memory_bytes: 9084