akhauriyash/Code-Regression huggingface dataset:
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
#include <boost/sort/spreadsort/spreadsort.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;
 
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
 
#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 Fixed fixed << setprecision(12)
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
 
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
template <class Func>
 
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
 
template <typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
 
struct negrightshift {
    inline int operator() (const int &x, const unsigned offset) {
        return -(x >> offset);
    }
};
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	umap<string,int> mp;
	int sum = 0;
	rep(i,n){
		string s;
		cin >> s;
		sort(all(s));
		++mp[s];
		sum += mp[s]-1;
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 10340
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define Q int q; cin >> q; while (q--)
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    map<string, int> m;
    Q {
        int c;
        string k;
        cin >> c >> k;
        if (c == 0) {
            int y;
            cin >> y;
            m[k] = y;
        } else if (c == 1) {
            if (m.count(k)) cout << m[k] << endl;
            else cout << 0 << endl;
        } else if (c == 2) {
            m.erase(k);
        } else if (c == 3) {
            string y;
            cin >> y;
            auto st = m.lower_bound(k);
            auto ed = m.upper_bound(y);
            for (;st != ed; st++) cout << (*st).first << " " << (*st).second << endl;
        }
    }
}



Measured memory_bytes: 25884
#include <iostream>
#include <vector>
#include <algorithm>

#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

using namespace std;

struct Item
{
  int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

int solve()
{
  // 初期化
  for (int w = 0; w <= W; w++)
  {
    C[0][w] = 0;
    G[0][w] = DIAGONAL;
  }
  for (int i = 1; i <= N; i++)
  {
    C[i][0] = 0;
  }

  for (int i = 1; i <= N; i++)
  {
    for (int w = 1; w <= W; w++)
    {
      C[i][w] = C[i - 1][w];
      G[i][w] = TOP;
      // 今見ているアイテムの重量が、ナップザックより大きいならTOP
      if (items[i].weight > w)
      {
        continue;
      }
      // 今見ているアイテムで置き換えた場合の価値とひとつ前のアイテムで比較
      if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w])
      {
        C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
        G[i][w] = DIAGONAL; // 更新された
      }
    }
  }

  return C[N][W];
}

int main()
{
  cin >> N >> W;
  for (int i = 1; i <= N; i++)
  {
    cin >> items[i].value >> items[i].weight;
  }

  cout << solve() << endl;
}


Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K;
    cin >> K;
    if (K % 2 == 1){
        cout << K / 2 * (K + 1) / 2 << endl;
    }
    else {
        cout << K / 2 * K / 2 << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env ruby


n = gets.to_i
m = []
m << gets.split.map {|i| i.to_i}
m << gets.split.map {|i| i.to_i}


current_max = 0
(0..n-1).each do |i|
  score = m[0][0..i].inject(:+) + m[1][i..-1].inject(:+)
  current_max = [score, current_max].max
end

puts current_max


Measured memory_bytes: 1788
C = [list(map(int, input().split())) for _ in range(3)]

Flg = True

if not (C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]):
    Flg = False
if not (C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]):
    Flg = False
    
print("Yes" if Flg else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n; cin >> n;
    string s; cin >> s;
    s = '0' + s;


    // dp[i][j] :=　条件を満たすようにi番目(1-indexed)まで決めて,i番目の数より大きい数字がj個残ってるような場合の数
    // 一度でも条件を外したらあとで修復不可能なので、条件をもつ状態だけ管理していればいい
    vector<vector<ll>> dp(3030, vector<ll>(3030, 0));
    for(int i=0; i<n; ++i) dp[1][i]=1;
    for(int i=2; i<=n; ++i){
        vector<ll> cum(3030, 0);
        rep(j, 0, n) { cum[j] = dp[i-1][j] + (j==0? 0:cum[j-1]); chmod(cum[j]); }
        if(s[i-1]=='<'){
            for(int j=0; j<n-i+1; ++j){
                dp[i][j] = cum[n-i+1] - cum[j];
                chmod(dp[i][j]);
            }
        }
        else{
            for(int j=0; j<n-i+1; ++j){
                dp[i][j] = cum[j];
            } 
        }
    }
    cout << dp[n][0] << '\n';

	return 0;
}


Measured memory_bytes: 72192
N = int(input())
S = [input() for _ in range(N)]

D = []

S.sort()

re = S[0]
c = 1
for i in range(1, N):
  if re == S[i]:
    c += 1
  else:
    D.append([c, re])
    c = 1
    re = S[i]
D.append([c, re])

D.sort(reverse = True)
mi = D[0][0]
L = []
for i in range(len(D)):
  if D[i][0] == mi:
    L.append(D[i][1])
  else:
    break

L.sort()
for i in L:
  print(i)

Measured memory_bytes: 110636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanLines)
	for sc.Scan() {
		s := strings.Split(sc.Text(), " ")
		a, _ := strconv.ParseFloat(s[0], 64)
		b, _ := strconv.ParseFloat(s[1], 64)
		c, _ := strconv.ParseFloat(s[2], 64)
		d, _ := strconv.ParseFloat(s[3], 64)
		e, _ := strconv.ParseFloat(s[4], 64)
		f, _ := strconv.ParseFloat(s[5], 64)
		x := ((b * f) - (c * e)) / ((b * d) - (a * e))
		y := ((a * f) - (c * d)) / ((a * e) - (b * d))
		if x == 0 {
			fmt.Printf("0.000 %.3f\n", y)
		} else if y == 0 {
			fmt.Printf("%.3f 0.000\n", x)
		} else {
			fmt.Printf("%.3f %.3f\n", x, y)
		}
	}
}



Measured memory_bytes: 1104
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(int argc, char const *argv[])
{
	string s;

	while(1){
		getline(cin,s);
		if(s==".") break;

		stack<char> c;
		for(int i1=0;i1<s.size();i1++){
			if(s[i1]=='(') c.push('(');
			else if(s[i1]=='[') c.push('[');
			else if(s[i1]==')'){
				if(!c.empty() && c.top()=='(') c.pop();
				else c.push(')');
			} 
			else if(s[i1]==']'){
				if(!c.empty() && c.top()=='[') c.pop();
					else c.push(']');
			}
			else {}

		}
		if(c.empty()) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<long long> v(n);
    for (int i = 0; i < n; i++) cin >> v[n-i-1];
    long long mini = 2; long long maxi = 2;
    for (int i = 0; i < n; i++) {
        long long a = ((mini+(v[i]-1))/v[i]) * v[i];
        long long b = (maxi / v[i]) * v[i];
        if (a > maxi || mini > b) {
            cout << -1 << endl;
            return 0;
        }
        mini = a;
        maxi = b + (v[i] - 1);
    }
    cout << mini << " " << maxi << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

struct query { int v, d, c; };

int main() {
    int n, m, q;
    cin >> n >> m;
    vector<int> G[n];
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> q;
    vector<query> ques;
    for (int i=0; i<q; i++) {
        int v, d, c;
        cin >> v >> d >> c;
        ques.push_back({v-1, d, c});
    }
    reverse(ques.begin(), ques.end());
    int dist[n], color[n];
    fill(dist, dist+n, -1);
    fill(color, color+n, 0);
    queue<query> qq;
    for (auto que:ques) {
        qq.push(que);
        while (!qq.empty()) {
            query f = qq.front(); qq.pop();
            if (color[f.v] == 0) color[f.v] = f.c;
            for (auto g:G[f.v]) {
                if (f.d - 1 <= dist[g]) continue;
                dist[g] = f.d - 1;
                qq.push({g, f.d-1, f.c});
            }
        }
    }
    for (auto c:color) cout << c << '\n';
    return 0;
}

Measured memory_bytes: 9712
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

int main(){

	string s;
	cin>>s;

	if(s.size()>=4 && s[0]=='Y' && s[1]=='A'&&s[2]=='K' &&s[3]=='I') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,t,i,ii,ice[10] = {0};
	while(scanf("%d",&n) , n != 0){
		for (i = 0;i <= 9;i++){
			ice[i] = 0;
		}
		for (i = 1;i <= n;i++){
			scanf("%d",&t);
			ice[t] = ice[t] + 1;
		}
		for(i = 0;i <= 9;i++){
			if (ice[i] == 0){
				printf("-\n");
			}
			else{
				for (ii = 1;ii <= ice[i];ii++){
					printf("*");
				}
				printf("\n");
			}
		}
	}
	return 0;
}
//aoj 0219

Measured memory_bytes: 572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x,y,asi;
        x=scan.nextInt();
        y=scan.nextInt();
        
       for(int c=0; c<=x; c++){
           int t=x-c;
           asi =(c*2)+(4*t);
           if(asi==y){
               System.out.println("Yes");
               System.exit(0);
           }
       }
        System.out.println("No");
    }
}


Measured memory_bytes: 35948
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String w[] = s.split("", -1);
        int cnt = 0;
        for(int i = 0; i < 3; i++){
            if(w[i].equals("R")){
                cnt += 1;
            }
        }

        if(cnt == 3){
            System.out.println("3");
        }else if(cnt == 2 && w[1].equals("R")){
            System.out.println("2");
        }else if(cnt == 0){
            System.out.println("0");
        }else{
            System.out.println("1");
        }
    }
}

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

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    if (S.at(K - 1) == 'A') {
        S.at(K - 1) = 'a';
    }
    else if (S.at(K - 1) == 'B') {
        S.at(K - 1) = 'b';
    }
    else {
        S.at(K - 1) = 'c';
    }
     cout << S << endl;
} 

Measured memory_bytes: 256
using System;

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

            string[] S = Console.ReadLine().Split(' ');
            int N = int.Parse(S[0]);
            int K = int.Parse(S[1]);

            double Ans = 0;

            if (N >= K - 1)
            {
                Ans = ((double)N - (double)K + 1) / (double)N;

                for (int i = 1; i <= K-1; i++)
                {



                    double Log2_Ki = Math.Log((double)K / i, 2);

                    Log2_Ki = Math.Ceiling(Log2_Ki);

                    int A = (int)Log2_Ki;
                    double AS = 1;

                    for (int j = 0; j < A; j++)
                    {
                        AS = AS * 2;
                    }

                    //Console.WriteLine("{0},{1},{2}", i, A, AS);
                    Ans += (1 / AS) / N;

                    AS = 1;

                }

            }
            else
            {
                for (int i = 1; i <= N; i++)
                {


                    double Log2_Ki = Math.Log((double)K / i, 2);

                    Log2_Ki = Math.Ceiling(Log2_Ki);

                    int A = (int)Log2_Ki;
                    double AS = 1;

                    for (int j = 0; j < A; j++)
                    {
                        AS = AS * 2;
                    }

                    //Console.WriteLine("{0},{1},{2}", i, A, AS);
                    Ans += (1 / AS)/N;

                    AS = 1;



                }
            }

         
            Console.WriteLine(Ans);

        }

    }
}


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

const int N = (int)2e3;

char grid[N+5][N+5];
pair<int,int> range[N+5][N+5][5];

int main() {
    int n,m; scanf("%d %d", &n, &m);
    for (int i=1; i<=n; i++) scanf("%s", grid[i]+1);

    // left right
    for (int i=1; i<=n; i++) {
        int a = 1;
        for (int j=1; j<=m; j++) {
            range[i][j][0].first = a;
            if (grid[i][j] == '#') a = j+1;
        }

        int b = m;
        for (int j=m; j>=1; j--) {
            range[i][j][0].second = b;
            if (grid[i][j] == '#') b = j-1;
        }
    }

    // up down
    for (int j=1; j<=m; j++) {
        int a = 1;
        for (int i=1; i<=n; i++) {
            range[i][j][1].first = a;
            if (grid[i][j] == '#') a = i+1;
        }

        int b = n;
        for (int i=n; i>=1; i--) {
            range[i][j][1].second = b;
            if (grid[i][j] == '#') b = i-1;
        }
    }

    int res = 0;
    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
        if (grid[i][j] == '.') {
            res = max(res, (
                range[i][j][0].second - range[i][j][0].first + 1
                + range[i][j][1].second - range[i][j][1].first
            ));
        }
    }

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


Measured memory_bytes: 161152
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e9+7;

int main()
{
    ll h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll s=h1*60+m1;
    ll t=h2*60+m2;
    cout << t-s-k << endl;
    return 0;
} 

Measured memory_bytes: 3620
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())

if N-K+1 > K:
    p = K
    for i in range(1, p+1):
        a = cmb(N-K+1, i) * cmb(K-1, i-1)
        print(int(a%1000000007))
else:
    p = N-K+1
    for i in range(1, p+1):
        a = cmb(N-K+1, i) * cmb(K-1, i-1)
        print(int(a%1000000007))
            
    for i in range(N-K+2, K+1):
        print(0)


Measured memory_bytes: 3944
main = do
  s <- map (read . \x -> [x]) <$> getLine
  putStrLn . show $ solve s

solve :: [Int] -> Int
solve s = min (calc 0 s) (calc 1 s)

calc _ [] = 0
calc k (x:xs) =
  (if k == x then 0 else 1) + (calc ((k+1) `mod` 2) xs)


Measured memory_bytes: 11004
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;

	return 0;
}

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

using namespace std;

int f[110], g[110];

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

  f[a] = 1; f[b] = -1;
  g[c] = 1; g[d] = -1;

  for (int i = 1; i <= 100; i++) {
    f[i] += f[i - 1];
    g[i] += g[i - 1];
  }

  int ans = 0;
  for (int i = 0; i <= 100; i++) {
    if (f[i] && g[i]) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
s = input()[::-1]
L = set(["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]])
pos = 0
while pos < len(s):
    if s[pos] == "e" or s[pos] == "m":
        if s[pos: pos + 5] in L:
            pos += 5
        else:
            print("NO")
            exit()
    elif s[pos] == "r":
        if s[pos: pos + 6] in L:
            pos += 6
        elif s[pos: pos + 7] in L:
            pos += 7
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

print("YES")


Measured memory_bytes: 3188
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
d = readints()
x = (list(itertools.combinations(d, 2)))
ans = 0
for i in range(len(x)):
    ans += x[i][0]*x[i][1]
print(ans)


Measured memory_bytes: 62060
import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
  ans0 = 1
  for a in A:
    ans0 = ans0*a%MOD
  print(ans0)
  exit()

A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 = ans1*a%MOD
  print(ans1)
  exit()

A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]
 
ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

B1=A[0:K]
C1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]

if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
  
B1.remove(Bp[-1])
B1.append(min(B2[0],0))

ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD

C1.remove(Bm[-1])
C1.append(max(B2[-1],0))
 
ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD

BB1=[np.sign(i) for i in B1]
ansBB1 = BB1[0:K].count(-1)%2
BB2=[np.sign(i) for i in C1]
ansBB2 = BB2[0:K].count(-1)%2
if ansBB1==1:
  print(ansC)
  exit()
if ansBB2==1:
  print(ansB)
  exit()

if abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0])>=0:
  print(ansC)
else: print(ansB)

Measured memory_bytes: 65548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
const ll MOD = 1000000007;

ll dp[100005][15];
int main(){
	string s;
	cin >> s;
	int l = s.size();
	dp[0][0] = 1;
	rep(i,l){
		rep(j,13){
			if(s[i] == '?'){
				rep(x,10){
					dp[i+1][(10*j+x)%13] += dp[i][j];
					dp[i+1][(10*j+x)%13] %= MOD;
				}
			}else{
				int d = s[i] - '0';
				dp[i+1][(10*j+d)%13] += dp[i][j];
				dp[i+1][(10*j+d)%13] %= MOD;
			}
		}
	}
	
	cout << dp[l][5] << endl;
    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    string S;
    cin >> S;

    string divide[4] = {"dream", "dreamer", "erase", "eraser"};

    //Sを反転、それぞれの単語も反転
    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; ++i){
        reverse(divide[i].begin(), divide[i].end());
    }

    // 端から切っていく
    bool can = true;
    for(int i = 0; i < S.size();){
        bool can2 = false;
        for(int j = 0; j < 4; ++j){
            string d = divide[j];
            if(S.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }

    if(can){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    int res = 0;
    rep(i, 4) {
        if (s[i] == '+') res++;
        else res--;
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int n, k;
    cin >> n >> k;
    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }
    int V[110][110] = {0};
    for(int i = 2; i <= n; i++){
        V[1][i] = 1;
        V[i][1] = 1;
    }
    int m = (n-1) * (n-2) / 2 - k;
    int i = 1, j = 0;
    while(m){
        j++;
        if(j > n){
            i++; 
            j = 0;
            continue;
        }
        if(i==j || V[i][j]) continue;
        V[i][j] = V[j][i] = 1;
        m--;
    }
    cout << endl;
    int cnt = 0;
    for(int i = 0; i < 110; i++){
        for(int j = 0; j < 110; j++){
            if(V[i][j] == 1) cnt++;
        }
    }
    cnt /= 2;
    cout << cnt << endl;
    for(int i = 0; i < 110; i++){
        for(int j = 0; j < 110; j++){
            if(V[i][j] == 1){
                V[i][j] = V[j][i] = 0;
                cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int t[110];
int v[110];

double dp[20010][110];

double solve() {
    for (int i = 0; i < 20010; i++)
        for (int j = 0; j < 110; j++)
            dp[i][j] = -inf;
    dp[0][0] = 0;
    int t_cur = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t[i]; j++, t_cur++) {
            for (int k = 0; k <= v[i]; k++) {
                dp[t_cur+1][k] = max(dp[t_cur+1][k], dp[t_cur][k]+k);
                if (k < v[i]) {
                    dp[t_cur+1][k+1] = max(dp[t_cur+1][k+1], dp[t_cur][k]+k+0.5);
                    dp[t_cur+1][k] = max(dp[t_cur+1][k], dp[t_cur][k]+k+0.25);
                }
                if (k > 0) dp[t_cur+1][k-1] = max(dp[t_cur+1][k-1], dp[t_cur][k]+k-0.5);
            }
        }
    }
    return dp[t_cur][0];
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> t[i];
    for (int i = 0; i < n; i++) cin >> v[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 18040
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    using plli=pair<ll,int>;
    vector<plli> costidx[n];
    vll a(n-1),b(n-1);
    vll c(n-1);
    rep(i,0,n-1){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
        plli first=make_pair(c[i],a[i]);
        plli second=make_pair(c[i],b[i]);
        costidx[b[i]].push_back(first);
        costidx[a[i]].push_back(second);
    }
    int Q,k;
    cin>>Q>>k;
    k--;
    vll dist(n,INF);
    vi color(n,0);
    priority_queue<plli,vector<plli>,greater<plli>> q;
    plli iniv=make_pair(0,k);
    q.push(iniv);
    while(!q.empty()){
        plli t=q.top();
        q.pop();
        ll cost=t.first;
        int idx=t.second;
        chmin(dist[idx],cost);
        color[idx]=2;
        for(auto e:costidx[idx]){
            if(color[e.second]==2)continue;
            q.emplace(e.first+cost,e.second);
            color[e.second]=1;
        }
    }
    rep(i,0,Q){
        int x,y;
        cin>>x>>y;
        x--,y--;
        cout<<dist[x]+dist[y]<<endl;
    }
    return 0;
}




Measured memory_bytes: 13808
#include <stdio.h>
int main(void) {
        int r,c;
        int i,j;
        int rc[110][110];
        int SUM;
        scanf("%d %d",&r,&c);
        for(i=0;i<r;i++){
            SUM=0;
            for(j=0;j<c;j++){
                scanf("%d",&rc[i][j]);
                SUM+=rc[i][j];
            }
            rc[i][c]=SUM;
        }
        for(i=0;i<c+1;i++){
            SUM=0;
            for(j=0;j<r;j++){
                SUM+=rc[j][i];
            }
            rc[r][i]=SUM;
        }
        for(i=0;i<r+1;i++){
            for(j=0;j<c+1;j++){
                if(j!=0) printf(" ");
                printf("%d",rc[i][j]);
            }
            puts("");
        }
return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
int n,m,x,a[13][13],s[13],r=1200001;
void bkt(int c)
{ if(c==n+1)
  { for(int i=1;i<=m;i++)
      if(s[i]<x)
         return;
    r=min(r,s[0]);
    return;
  }
  bkt(c+1);
  for(int i=0;i<=m;i++)
    s[i]+=a[c][i];
  bkt(c+1);
  for(int i=0;i<=m;i++)
    s[i]-=a[c][i];
}
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n>>m>>x;
  for(int i=1;i<=n;i++)
  { cin>>a[i][0];
    for(int j=1;j<=m;j++)
      cin>>a[i][j];
  }
  bkt(1);
  if(r==1200001)
     r=-1;
  cout<<r<<'\n';
  return 0;
}


Measured memory_bytes: 3656
N, T = map(int, input().split())
dp = [[0]*T for i in range(N+1)]

ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
ls.sort(key=lambda x:x[0])

for i in range(N):
  a, b = ls[i]
  for j in range(T-1, a-1, -1):
    dp[i+1][j] = max(dp[i][j], dp[i][j-a]+b)
    
pre = [0]*N
pre[-1] = ls[-1][1]
for i in range(N-2, -1, -1):
  pre[i] = max(pre[i+1], ls[i][1])
    
ans = 0
for i in range(N-1):
  ans = max(ans, max(dp[i+1])+pre[i+1])
ans = max(ans, max(dp[-1]))
print(ans)

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

const int MAX = 100;

int main(){
    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i <= x + k - 1; i++){
        cout << i << " ";
    }

    cout << endl;
}

Measured memory_bytes: 256
// 構文解析の練習
// https://gist.github.com/draftcode/1357281
#include <cctype>
#include <string>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef string::const_iterator State;
class ParseError{};
int number(State&);
int term(State&);
int expression(State&);
int factor(State&);

int number(State& begin) {
    int ret = 0;
    while(isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}
int term(State& begin) {
    int ret = factor(begin);

    while(1) {
        if(*begin == '*') {
            begin++;
            ret *= factor(begin);
        }
        else if(*begin == '/') {
            begin++;
            ret /= factor(begin);
        }
        else {
            break;
        }
    }

    return ret;

}
int expression(State& begin) {
    int ret = term(begin);
    
    while(1) {
        if(*begin == '+') {
            begin++;
            ret += term(begin);
        }
        else if(*begin == '-') {
            begin++;
            ret -= term(begin);
        }
        else {
            break;
        }
    }
    return ret;

}
int factor(State& begin) {
    int ret = 0;
    if(*begin == '(') {
        begin++; // ( を飛ばす
        ret = expression(begin);
        begin++; // ) を飛ばす
    }
    else {
        ret = number(begin);
    }

    return ret;
}

int main() {
    int N;
    cin>>N;
    cin.ignore();
    rep(i,N) {
        string s;
        getline(cin,s);
        State begin = s.begin();
        int ans = expression(begin);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l-1
    if s > right:
        right = t
        ans += 1
print(ans)


Measured memory_bytes: 21400
import numpy as np

n=int(input())
h=np.array(list(map(int,input().split())))

cnt=0
while (1):
    target=h.max()
    if target == 0 :
        print(cnt)
        break
    
    flag = 0
    for i, hi in enumerate(h) :
        if hi == target:
            if flag == 0:
                flag = 1
                cnt+= 1
            h[i]-=1
        else :
            flag=0

Measured memory_bytes: 12420
using System;

class Program
{
    static void Main(string[] args)
    {
        var A = int.Parse(Console.ReadLine());
        var B = int.Parse(Console.ReadLine());
        var C = int.Parse(Console.ReadLine());
        var X = int.Parse(Console.ReadLine());

        var count = 0;
        for (var i = 0; i <= A; i++)
        {
            for (var j = 0; j <= B; j++)
            {
                for (var k = 0; k <= C; k++)
                {
                    var total = i * 500 + j * 100 + k * 50;
                    if (total == X) count++;
                }
            }
        }
        
        Console.WriteLine(count);
    }
}


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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5+5;


void solve() {

   string s,t;
   cin>>s>>t;
   int n = sz(s), m = sz(t);
   int ans = m;
   fr(i,0,n-m){
      int x = 0;
      rep(j,i,i+m)
        x+=s[j]!=t[j-i];
      mini(ans,x);
   }
   cout<<ans;
  
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   // cin >> t;
    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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

Measured memory_bytes: 3648
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

-- 
--
--

main = do
    [a,b,c] <- sort <$> getIs
    putStrLn $ bool "No" "Yes" (a + b == c)


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<ll> a(N);
    for (auto &&i : a) {
        cin >> i;
    }
    ll ans = 0;
    for (auto &&i : a) {
        ans += i - 1;
    }

    print(ans);

    return 0;
}

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

long long N=0,K=0,M=0,A=0,ansac=0,answa=0,p=0;
string S;
int main(){
    cin >> N >> M;
    vector<pair<string,long long>> P(N+1,pair<string,long long>("WA",0));

    for (int i=0;i<M;i++){
        cin >> p >> S;
        if (P[p].first != "AC"){
            P[p].first = S;
            if (P[p].first=="AC") {
                ansac++;
                answa += P[p].second;
            } else {
                P[p].second++;
            }
        }
    }
    cout << ansac << endl << answa << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define double long double
using namespace std;
struct node{
	double x,y;
}a[105];
int n;
double ansx,ansy,sy=0,sx=0;
double ans=2000,t;
double del=0.9995; 
inline double dis(node aa,node bb){
	return sqrt((aa.x-bb.x)*(aa.x-bb.x)+(aa.y-bb.y)*(aa.y-bb.y));
}
double calc(double x,double y){
	double ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,dis((node){x,y},a[i]));
	}
	return ans;
}
void SA(){
	double x=ansx,y=ansy;
	t=2000;
	while(t>1e-14){
		double X=x+((rand()<<1)-RAND_MAX)*t;
		double Y=y+((rand()<<1)-RAND_MAX)*t;
		double now=calc(X,Y);
    	double Delta=now-ans;
    	if(Delta<0){
    		x=X,y=Y;
    		ans=now;
		}
		else if (exp(-Delta/t)*RAND_MAX>rand()) x=X,y=Y; 
        t*=del;
	}
}
int main(){
	int cnt=0;
	srand(1000211237);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
		sx+=a[i].x,sy+=a[i].y;
	}
	ansx=(double)sx/n,ansy=(double)sy/n;
	while((double)clock()/CLOCKS_PER_SEC<0.93) SA(),cnt++;
	printf("%.14Lf",ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a,b,c,f[100010];
bool flag;
int main()
{
    flag=false;
    cin>>a>>b>>c;
    f[1]=a%b;
    int j=2,d=a;
    while (1)
    {
        d+=a;
        if (d%b!=f[1]) f[j++]=d%b;
        else break;
    }
    for (int i=1; i<=j; i++)
        if (f[i]==c) {cout<<"YES"<<endl; flag=true; break;}
    if (flag==false) cout<<"NO"<<endl;
    return 0;
}

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



int main() {
    int n;
    cin >> n;
    
    vector<int> l(n);
    rep(i,n) {
        cin >> l[i];
    }
    
    sort(l.begin(),l.end());
    
    ll ans = 0;
    for(int i = 2; i < n; i++) {
        for(int j = i-1; j >= 1; j--) {
            for(int k = j-1; k >= 0; k--) {
                if(l[i] < l[j] + l[k])
                    ans++;
                else
                    break;
            }
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
}


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

vector<int>v[300000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n){
		int m;scanf("%d",&m);
		rep(j,m){
			int s;scanf("%d",&s);
			v[i].push_back(s);
		}
	}
	multiset<int>se;
	ll cnt=0;
	for(int i=n-1;i>=0;i--){
		for(int j:v[i])se.insert(j);
		if(!se.empty()){
			cnt+=*se.rbegin();
			se.erase(--se.end());
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 26004
import java.util.Scanner;
public class Main{
    
    public void solve(){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int h = sc.nextInt();
		int a,b;
		if(t<h){
			System.out.println("a < b");
		}else if(t>h){
			System.out.println("a > b");
		}else if(t==h){
			System.out.println("a == b");
		}
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17160
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fizzBuzz := 0
	for i := 1; i <= n; i++ {
		if i % 3 != 0 && i % 5 != 0 {
			fizzBuzz += i
		}
	}
	fmt.Println(fizzBuzz)
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e16;
ll h,w;
ll type1(){
    ll a = w/3;
    ll b = (w-a)/2;
    ll c = w-a-b;
    ll res = (c-a)*h;
    return res;
}

ll type2(){
    ll a = h/3;
    ll b = (h-a)/2;
    ll c = (h-a-b);
    ll res = (c-a)*w;
    return res;
}

ll type3(){
    ll res = INF;
    for(ll i=1;i<w;i++){
        ll A = h*i;
        ll a = h/2;
        ll B = (w-i)*a;
        ll C = (h-a)*(w-i);
        ll m = min(A,min(B,C));
        ll M = max(A,max(B,C));
        res = min(res,M-m);
    }
    return res;
}

ll type4(){
    ll res = INF;
    for(ll j=1;j<h;j++){
        ll A = w*j;
        ll a = w/2;
        ll B = (h-j)*a;
        ll C = (w-a)*(h-j);
        ll m = min(A,min(B,C));
        ll M = max(A,max(B,C));
        res = min(res,M-m);
    }
    return res;
}

int main(){
    cin >> h >> w;
    ll ans=type1();
    chmin(ans,type2());
    chmin(ans,type3());
    chmin(ans,type4());
    cout << ans << endl;
    return 0;
}



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

using pii = pair<string, int>;

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> P[i];
	}

	vector<int> order(N);
	iota(order.begin(), order.end(), 0);
	sort(order.begin(), order.end(), [&](int i, int j) {
		if (S[i] == S[j]) {
			return P[i] >= P[j];
		} else {
			return S[i] <= S[j];
		}
	});

	for (int i = 0; i < N; i++) {
		cout << order[i] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  string s;
  cin>>s;
  
  int cnta=0,cntb=0;
  rep(i,3){
    if(s[i]=='A') cnta++;
    else cntb++; 
  }
  
  if(cnta!=0 && cntb!=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256