akhauriyash/Code-Regression huggingface dataset:
n = int(input())

table = [0]*(10**4+100)

for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            total = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if total < 10100:
                table[total] += 1
            
for i in range(n):
    print(table[i+1])

Measured memory_bytes: 9304
program main
  implicit none
  integer i, N, X, ans, d1, d2, ex1, ex2
  integer,allocatable:: P(:)
  read(*, *)X, N
  if (N == 0) then
    write(*, *) X
  else
    allocate(P(N))
    read(*, *) (P(i), i = 1,N)
    d1 = X
    d2 = X
    ex1 = 0
    ex2 = 0
    do
      do i = 1,N
        if (d1 == P(i)) then
          ex1 = 1
        endif
        if (d2 == P(i)) then
          ex2 = 1
        end if
      end do
      if (ex1 == 0) then
        ans = d1
        exit
      else
        d1 = d1-1
      endif
      if (ex2 == 0) then
        ans = d2
        exit
      else
        d2 = d2+1
      endif
      ex1 = 0
      ex2 = 0
    end do
    write(*, *) ans
  end if
end program main


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 100 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

    //code
    
    string s;
    cin >> s;

    if( s[0] == s[s.length()-1] ^ (s.length()%2))
    	cout << "First";
    else
    	cout << "Second";
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int n,a,x[100001],i;
    scanf("%d", &n);
    for(i=1; i<=n; i++)
    {
        scanf("%d", &a);
        x[a]=i;
    }
    for(i=1; i<=n; i++)
    {
        printf("%d", x[i]);
        if(i<n)
        printf(" ");
    }
    printf("\n");
    
    return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<int> x(3);
  input(x[0], x[1], x[2]);
  sort(all(x));

  outl(x[0] * x[1] / 2);

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int main() {

	int N, a[123];

	scanf("%d", &N);
	rep(i, N) scanf("%d", &a[i]);

	int sum = 0;
	rep(i, N) sum += a[i];
	int n_n = 1000000000, n_i = 0;

	rep(i, N) {
		if (n_n > abs(sum - a[i] * N)) {
			n_n = abs(sum - a[i] * N);
			n_i = i;
		}
	}


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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
ll K, A[100000], S[40][2], MAX, MS[40], SUM;

int main(){
	cin >> N >> K;
	for (int i = 0; i != N; ++i)
		cin >> A[i];
	for (int i = 0; i != 40; ++i) {
		for (int j = 0; j != N; ++j) {
			if (A[j] & (1ll << i)) {
				S[i][0] += 1ll << i;
			}
			else {
				S[i][1] += 1ll << i;
			}
		}
	}
	MS[0] = max(S[0][0], S[0][1]);
	for (int i = 1; i != 40; ++i) {
		MS[i] = MS[i - 1] + max(S[i][0], S[i][1]);
	}
	for (int i = 39; i != -1; --i) {
		if (K&(1ll << i)) {
			if (i)
				MAX = max(MAX, SUM + S[i][0] + MS[i - 1]);
			else
				MAX = max(MAX, SUM + MS[0]);
			SUM += S[i][1];
		}
		else {
			SUM += S[i][0];
		}
	}
	cout << max(MAX, SUM) << endl;
}

Measured memory_bytes: 1024
/*
      author : nishi5451
      created: 12.08.2020 10:57:08
*/

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


int main(){
    string s;
    cin >> s;
    rep(i,s.size()-1){
        if(s[i]=='A' && s[i+1]=='C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3576
#
# abc068 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """100"""
        output = """ABC100"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """425"""
        output = """ABC425"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """999"""
        output = """ABC999"""
        self.assertIO(input, output)


def resolve():
    print("ABC" + input())


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16192
#include <stdio.h>
 
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define pii pair<ll,ll>

const ll maxn = 1e5 + 101;
ll w[maxn],v[maxn];
ll f[maxn];
int main(){
    ll n,W;
    scanf("%lld%lld",&n,&W);
    for(ll i=1;i<=n;++i){
        scanf("%lld%lld",w+i,v+i);
    }
    ll ans=0;
    memset(f,0x3f3f3f3f,sizeof f);
    f[0]=0;
    for(ll i=1;i<=n;++i){
        for(ll l=1e5;l>=v[i];--l){
            f[l]=min(f[l],f[l-v[i]]+w[i]);
            if(f[l]<=W) ans=max(ans,l);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4564
#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,int> P;
const ll INF=1e18;


int main() {
  ll N;cin>>N;
  string s;
  cin>>s;
  ll n=s.size();
  ll cnt=0;
  ll cnt1=0;

  rep(i,n){
    if (s[i]=='R')cnt++;
  }
  rep(j,cnt){
    if (s[j]=='W')cnt1++;
  }
  cout<<cnt1;
}


Measured memory_bytes: 3696
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int v[n];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int m = 0;
    for(int a = 0; a <= min(n, k); a++){
        for(int b = 0; a+b <= min(n, k); b++){
            int tmp = 0;
            vector<int> minus;
            for(int i = 0; i < a; i++){
                tmp+=v[i];
                if(v[i] < 0){
                    minus.push_back(v[i]);
                }
            }
            for(int i = 0; i < b; i++){
                tmp+=v[n-1-i];
                if(v[n-i-1] < 0){
                    minus.push_back(v[n-1-i]);
                }
            }
            sort(minus.begin(), minus.end());
            for(int i = 0; i < k-(a+b) && i < minus.size(); i++){
                tmp -= minus[i];
            }
            m = max(m, tmp);
        }
    }

    cout << m << endl;
    
    return 0;
}

Measured memory_bytes: 256
// 2020-08-30 11:39:56
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int h, w;
  cin >> h >> w;
  map<int, int> mp;
  multiset<int> ms;
  rep(i, w) {
    mp[i] = i;
    ms.insert(0);
  }
  rep(i, h) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    auto it = mp.lower_bound(a);
    int mx = -1;
    while (it != mp.end() && it->first <= b + 1) {
      chmax(mx, it->second);
      ms.erase(ms.lower_bound(it->first - it->second));
      mp.erase(prev(++it));
    }
    if (b < w - 1 && mx >= 0) {
      mp[b + 1] = mx;
      ms.insert(b + 1 - mx);
    }
    if (ms.size() > 0) {
      cout << (*ms.begin()) + i + 1 << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	double ans = 0, x;
	string S;
	while(N--)
	{
		cin >> x >> S;
		ans += (S == "BTC" ? 380000 : 1) * x;
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
@D=map[glob<>],@@=0..$'-<>=~$";map{$j=0;for$x(split){$k=($i+$j++)%3 .'';--$x;$$k[$_]+=$D[$x][$_]for@@}++$i}<>;$\=1e15;for$i(@@){for$j(@@){$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$0[$i]-$1[$j]-$2[$_]for@@}}print

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

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

	int cnt=0;
	for(int i=0;i<N;i++){
		int h;
		cin>>h;
		if(h>=K) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) (a).size())

const int N = (int) 1e6 + 10;
vector<int> adj[N], radj[N], order;
int n, m, u, v, root, pos[N], used[N], p[N]	;

void dfs(int v) {
	used[v] = 1;
	for (int u : adj[v]) {
		if (!used[u]) {
			dfs(u);
		}
	}
	order.pb(v);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n - 1 + m; ++i) {
		scanf("%d%d", &u, &v), --u, --v;
		adj[u].pb(v), radj[v].pb(u);
	}
	for (int i = 0; i < n; ++i) {
		if (sz(radj[i]) == 0) {
			root = i;
		}
	}
	dfs(root);
	for (int i = 0; i < n; ++i) {
		pos[order[i]] = i;
	}
	for (int i : order) {
		p[i] = -1;
		for (int j : radj[i]) {
			if ((p[i] == -1) || (pos[j] < pos[p[i]])) {
				p[i] = j;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		printf("%d%c", p[i] + 1, " \n"[i == n - 1]);
	}
	return 0;
}

Measured memory_bytes: 69244
N = int(input())
S = input()
counter = 0

for i in range(N-2):
    for j in range(i+1,(N+i-1)//2+1):
        k = 2*j-i
        if not S[i]==S[j] and  not S[j]==S[k] and not S[i]==S[k]:
            counter += 1

rgb = S.count("R")*S.count("G")*S.count("B")
print(rgb-counter)



Measured memory_bytes: 67888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi w(n);
  rep(i,n) cin>>w[i];
  int sum=0,sumex=0;
  int ans=INF;
  rrep(i,100){
    sum=0;sumex=0;
    rep(j,n){
      if(j<=i) sum+=w[j];
      if(j>i)  sumex+=w[j];
    }
    mins(ans,abs(sum-sumex));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define MOD 1000000007

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	for (int i = 0; 1; ++i) {
		a -= d;
		c -= b;
		if (a <= 0 || c <= 0) {
			if (c > 0) {
				cout << "No";
			} else {
				cout << "Yes";
			}
			break;
		}
	}
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < h.length - k + 1; i++) {
			int calc = h[i+k-1] - h[i];
			ans = Math.min(ans,calc);
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 49764
#include<iostream>
#include<cstdio>

typedef long long ll;

using namespace std;

int main()
{
  ll sum = 0;
  int n;

  cin >> n;

  for ( int i = 0; i < n; ++i ) {
    int tmp;
    scanf("%d", &tmp);
    sum += tmp;
  }

  sum -= n;

  cout << sum << "\n";
}


Measured memory_bytes: 256
def getN():
    return int(input())

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

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

a, b = getlist()

if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)



Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

int jo,io;

int main(void){
  char c[10000];
  int cnum;
  while(  (scanf("%s",c)) != EOF){
    jo = io = 0;
    check(c,strlen(c));
    printf("%d\n%d\n",jo,io);
  }
  return 0;
}

int check(char *c,int i){
  if(i < 2)
    return 0;
  
  if(c[i] == 'I'){

    if(c[i-1] == 'O'){

      switch(c[i-2]){
      case 'I':
	io++;
	check(c,i-2);
	break;
      case 'J':
	jo++;
	check(c,i-3);
	break;
      default:
	check(c,i-3);
	break;
      }

    }else if(c[i-1] =='I'){
      check(c,i-1);
    }else{
      check(c,i-2);
    }
  }else{
    check(c,i-1);
  }
      
  return 0;
	  
}

Measured memory_bytes: 640
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <array>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;
array<int,2> tab[N] ;
int pre[N] ;
void solve(){
	int n , d , a ;
	cin >> n >> d >> a ;
	for(int i = 0 ; i < n ; i++){
		cin >> tab[i][0] >> tab[i][1] ;
	}
	int ans = 0 ;
	sort(tab, tab+n) ;
	for(int i = 0 , j = 0 ; i < n ; i++){
		while(j<n && tab[j][0] <= tab[i][0] + 2*d){
			j++ ;
		}
		int need = (tab[i][1] - (pre[i]*a) + a - 1) / a ;
		if(need < 0LL) need = 0LL ;
		ans += need ;
		pre[i] += need; 
		pre[j] -= need ;
		pre[i+1] += pre[i] ;
	}
	cout << ans ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


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

int main() {
	int n; cin >> n; // n is always even
	long long a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b+n);
	long long medianL, medianR;
	bool diff = false;
	if (b[(n-1)/2] == b[(n-1)/2+1]) {
		medianL = medianR = b[(n-1)/2];
	} else {
		medianL = b[(n-1)/2];
		medianR = b[(n-1)/2+1];
		diff = true;
	}
	for (int i = 0; i < n; i++) {
		if (not diff) {
			cout << medianR << endl;
		} else {
			if (a[i] <= medianL) {
				cout << medianR << endl;
			} else {
				cout << medianL << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define f1(n) for(int i=0;i<n;i++)
int min1(int *arr,int n)
{
            if(n<=1)return 0;
            if(n==2) return abs(arr[n-1]-arr[n-2]);
            
int arr1[n];
arr1[0]=0;
arr1[1]=abs(arr[1]-arr[0]);
for(int i=2;i<n;i++)
{
  int a1=abs(arr[i]-arr[i-2]);
  int a2=abs(arr[i]-arr[i-1]);
  if((a1+arr1[i-2])<(a2+arr1[i-1]))
  {
              arr1[i]=a1+arr1[i-2];
  }
  else
  {
              arr1[i]=a2+arr1[i-1];
  }
  
}

return arr1[n-1];
}
int main()
{
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
 int n;
 cin>>n;
 int arr[n];
 f1(n)
 {
             cin>>arr[i];
 

}
cout<<min1(arr,n);
}


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

#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ld					  long double

#define ss                       second
#define ff                        first

#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)

#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())

#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define pd					 pair<ld,ld>
#define endl                 '\n'

#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define mod					 1000000007
#define inf                  1000000007
#define eps                  0.000000000000001

typedef vector<int> vi; 
typedef vector< ll > vl;
typedef vector< ld > vd;
typedef vector< pi > vpi;
typedef vector< pll > vpl;
typedef vector< vi > vvi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//vector<int> adj[200010],value(200010),par(200010),vis(200010,0),dis(200010,0),g(200010,0),col(200010,-1);
//int myrandom (int i) { return std::rand()%i;}

int main()
{
	ll n; cin>>n;
	vl a(n),cnt(100001,0);
	ll s=0;
	f(i,n){
		cin>>a[i];
		cnt[a[i]]++;
		s+=a[i];
	}
	ll q;cin>>q;
	vl b(q),c(q);
	f(i,q){
		cin>>b[i]>>c[i];
		s-=(cnt[b[i]]*b[i]);
		s+=(cnt[b[i]]*c[i]);
		cnt[c[i]]+=cnt[b[i]];
		cnt[b[i]]=0;
		cout<<s<<endl;
	}
	return 0;
}


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

#define INF 1e18
using ll = long long;

ll a[200010];
ll b[200010];

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

    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i+1]=b[i]+a[i];
    }

    ll m=INF;
    for(int i=1;i<n;i++)
    {
        m=min(m,abs((b[n]-b[i])-(b[i]-b[0])));
    }

    cout<<m<<"\n";

    return 0;
}


Measured memory_bytes: 6744
n,a=map(int,input().split())
x=list(map(int,input().split()))
import numpy as np
dp=np.zeros((n+1,2501),int)
dp[0,0]=1
for xi in x:
  for i in range(n-1,-1,-1):
    dp[i+1][xi:]+=dp[i,:-xi]
ans=0
for i in range(1,n+1):
  ans+=dp[i,i*a]
print(ans)


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a;
    cin >> a;
    double PI = 3.141592653589793;
    double f1 = 1.0*a*a*PI;
    double f2 = 2.0*a*PI;
    printf("%lf %lf\n",f1,f2);
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6+5;
int n;
char s[N];
int g[N];

int v[N], h[N];

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int mx=0,ss=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')ss++;
		else ss--;
		v[i]=h[i]=ss;
		mx=max(mx,ss);
	}
	int mn=0;
	for(int i=n-1;i;i--)v[i]=max(v[i],v[i+1]);
	// cerr << mx << "?" << endl;
	ss=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')ss++;
		else if(s[i]=='0')ss--;
		else if(s[i]=='?'){
			// cerr << ss+1+g[i+1] << " " << mx << endl;
			if(ss+v[i]+2-h[i-1]<=mx)ss++;
			else ss--;
		}
		// assert(ss<=mx);
		// cerr << ss << ",";
		// cerr << g[i+1] << "?" << endl;
		mn=min(mn,ss);
	}
	int ans=mx-mn;
	mn=ss=0;
	++mx;
	for(int i=1;i<=n;i++){
		if(s[i]=='1')ss++;
		else if(s[i]=='0')ss--;
		else if(s[i]=='?'){
			// cerr << ss+1+g[i+1] << " " << mx << endl;
			if(ss+v[i]+2-h[i-1]<=mx)ss++;
			else ss--;
		}
		// assert(ss<=mx);
		// cerr << ss << ",";
		// cerr << g[i+1] << "?" << endl;
		mn=min(mn,ss);
	}
	ans=min(ans,mx-mn);
	printf("%d\n",ans);
}

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

int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	int a[n+1];
	for(int i=1;i<=n;i++) a[i]=k;
	for(int i=0;i<q;i++)
	{
		int ai;cin>>ai;
		a[ai]+=1;
	}
	for(int i=1;i<n+1;i++)
	{
		if(a[i]-q>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

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

    int n, s1 = 0, s2 = 0, ans = 10001, temp = 0;
    cin >> n;
    vector<int> v(n);

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

    for (int i = 0; i < n; i++)
    {
        temp += v[i];
        int aux = 0;
        for (int j = i + 1; j < n; j++)
        {
            aux += v[j];
        }
        ans = min(ans, abs(aux - temp));
    }

    cout << ans << '\n';

    return 0;
}

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

int N,a,b,c;

int main(){
  for(;;){
    cin >> N;
    if(N!=0){
      a = 1;
      b = 0;
      for(int i = 0; i < N; i++){
        cin >> c;
        if(c != 0){
          a++;
        }
        if(c > 1){
          b++;
        }
      }
      if(b == 0){
        cout << "NA" << endl;
      }else{
        cout << a << endl;
      }
    }else{
      break;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    auto solve = [&](auto&& rec, int node, int prev) -> int {
        int n = 0;
        bool z = false;
        for (auto next : G[node]) if (next != prev) {
            int m = rec(rec, next, node);
            if (!z && m == 0) z = true;
            else n += max(1, m);
        }
        return n;
    };
    for (int s = 0; s < N; s++) {
        if (G[s].size() >= 3) {
            cout << solve(solve, s, -1) << '\n';
            return 0;
        }
    }
    cout << 1 << '\n';
    return 0;
}


Measured memory_bytes: 7296
#include<stdio.h>
#include<string.h>
#include<math.h>
int a;
int b;
int c;
int d;
int main() {
	scanf("%d",&a);
	b = a / 100;
	c = a % 100 / 10;
	d = a % 10;
	if (b == 1)
		b = 9;
	else if (b == 9)
		b = 1;
	if (c == 1)
		c = 9;
	else if (c == 9)
		c = 1;
	if (d == 1)
		d = 9;
	else if (d == 9)
		d = 1;
	a = b * 100 + c * 10 + d;
	printf("%d", a);
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if(N * A > B ){
  cout << B << endl;
  }
  if(N * A == B){
  cout << B << endl;
  }
  if(N * A < B){
  cout << N * A << endl;
  }
}

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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
    int x,n;
    cin>>x>>n;
    int i,j,arr[n];
    set<int>s;
    for(i=0;i<n;i++){
    	cin>>arr[i];
    	s.insert(arr[i]);
    }
    int mini = 1000;
    i = x;
    while(s.find(i)!=s.end()){
    	i--;
    }
    j = x;
    while(s.find(j)!=s.end()){
    	j++;
    }
    if(j-x<x-i){
    	cout<<j;
    }
    else{
    	cout<<i;
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
typedef pair<ll,ll> P;
int n;
vector<int> a(9),b(9);
int ka(int a){
    int res = 1;
    while(a > 1){
        res *= a;
        a--;
    } 
    return res;
}
int get(vector<int> a){
    int res = 0;
    rep(i,n-1){
        res += (a[i]-1)*ka(n-i-1);
        rep(j,n-1){
            if (a[i+j] > a[i]) a[i+j]--;
        }
    }
    return res;
}
int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    PRINT(abs(get(a)-get(b)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
vector<int> G[1001];
string s[1000];
void dfs(int v,int d){
	if(v!=0){
		cout<<string(d,'.');
		cout<<s[v-1]<<endl;
	}
	for(int u:G[v]) dfs(u,d+1);
}
int main(){
	int N;
	cin>>N;
	rep(i,N){
		int a;
		cin>>a;
		G[a].pb(i+1);
		cin>>s[i];
	}
	dfs(0,-1);
}

Measured memory_bytes: 1444
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    int N, cnt = 0;
    cin >> N;
    string S;
    for(int i = 0; i < N; i++){
        cin >> S;
        if(S == "E869120")cnt++;
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3208
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
int h,w;
char board[22][22];
bool visited[22][22];
int dist[22][22];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
bool check(int i, int j) {
	return (i >= 0) && (i < h) && (j >= 0) && (j < w) && (board[i][j] == '.');
}
 
int bfs(int sx,int sy){
    for(int k = 0;k<h;k++){
        for(int l = 0;l<w;l++){
            visited[k][l]=false;
        }
    }
    int ans = 0;
    queue<P>que;
    que.push(P(sx,sy));
    dist[sx][sy]=0;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x =p.first;
        int y =p.second;
        if(visited[x][y])continue;
        visited[x][y]=true;
        for(int m=0;m<4;m++){
            int nx =x+dx[m];
            int ny =y+dy[m];
            if(!check(nx,ny))continue;
            if(visited[nx][ny])continue;
            dist[nx][ny]=dist[x][y]+1;
            ans =max(ans,dist[nx][ny]);
            que.push(P(nx,ny));
        }
    }
    return ans;
}
 
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>board[i][j];
        }
    }
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(board[i][j]=='#')continue;
            ans =max(ans,bfs(i,j));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	while (n--){
		int s;
		cin>>s;
		if (s%2==0)
			if (s%3!=0&&s%5!=0){
				cout<<"DENIED"<<endl;
				return 0;
			}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <random>
#include <bitset>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(x) begin(x), end(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr int inf = 1e9+7;
int main() {
    string s; cin >> s;
    int n = s.length();
    vector<int> acc(n + 1);
    repeat (i, n) {
        acc[i + 1] = acc[i] ^ (1 << (s[i] - 'a'));
    }
    unordered_map<int, vector<int> > f;
    vector<int> dp(n + 1, inf);
    dp[0] = 0;
    repeat (r, n) {
        f[acc[r]].push_back(r);
        repeat (c, 27) {
            int k = acc[r + 1] ^ (c == 26 ? 0 : (1 << c));
            if (f.count(k)) {
                auto & ls = f[k];
                repeat (i, min<int>(ls.size(), 300)) {
                    int l = ls[i];
                    setmin(dp[r + 1], dp[l] + 1);
                }
                if (ls.size() > 300) {
                    repeat_from (i, ls.size() - 300, ls.size()) {
                        int l = ls[i];
                        setmin(dp[r + 1], dp[l] + 1);
                    }
                }
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 22392
import java.io.*;
 
class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String sNyuryoku=br.readLine();
         
        int i=0;
         
         //??\???????????????????????????????????£????????????????????????
        while(!sNyuryoku.equals("0")){
            //i???+1??????
            i++;
            
            //????????????????????????
            sb.append("Case ").append(i).append(": ").append(sNyuryoku).append("\n");
           
            sNyuryoku=br.readLine();
        }
        System.out.print(sb);
    }
}
 

Measured memory_bytes: 29380
import itertools

n, m, x = map(int,input().split())
all_list = [0] * n
for i in range(n):
    all_list[i] = list(map(int,input().split()))

prices = []

for r in range(n):
    for tup in (map(list,itertools.combinations(all_list, r+1))):
        sum = [0] * (m+1)
        for lis in tup:
            for i, val in enumerate(lis):
                sum[i] += val
        for i in range(m):
            if sum[i+1] < x:
                break
        else:
            prices.append(sum[0])

if prices:
    print(min(prices))
else:
    print(-1)

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

using namespace std;

int main() {
  string A,B,C; cin >> A >> B >> C;
  if(A.at(A.size()-1) == B.at(0)){
    if(B.at(B.size()-1) == C.at(0))
    cout << "YES" << endl;
    else 
    cout << "NO" << endl;
  }
  else
  cout << "NO" << endl;

  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  FOR(i,1,10)FOR(j,i,10){
    if(n == i * j){
      Yes(true);
      return 0;
    }
  }
  Yes(false);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
int n;
int main(void){
	cin >> n;
	int b[n-1];
	for(int i=0;i<n-1;i++){
		cin >> b[i]; 
	}
	int a[n];
	int ans =0;
	for(int i=0;i<n;i++){
		if(i==0){
			a[i] = b[i];
			ans += a[i];
			continue;
		}
		if(i==n-1){
			a[i] = b[i-1];
			ans += a[i];
			continue;
		}
		a[i] = min(b[i-1],b[i]);
		ans += a[i];
	}
	cout << ans;
return 0;
}



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


int main() {
    int a,b,h;
    cin >>a>>b>>h;
    if (a == b) {
        if (a == h)cout << '1' << endl;
        else cout << '2' << endl;
    }
    else if (a == b)cout << '2' << endl;
    else if (h== b)cout << '2' << endl;
    else if (a == h)cout << '2' << endl;
    else cout << '3' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,m=0;
  char c;
  for(i=0;i<3;i++){
  	scanf("%c",&c);
    if(c=='A') m++;
  }
  if((m==0)||(m==3)){
    printf("No");
  }else{
    printf("Yes");
  }
  return(0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[10],b=10,c,ans=0;
	for(int i=0;i<5;i++){
		cin>>a[i];
		if(a[i]%10!=0 && a[i]%10<b){
			b=a[i]%10;
			c=i;
		}
	}
	for(int i=0;i<5;i++){
		if(i!=c){
			if(a[i]%10==0)
			ans+=a[i];
			else
			ans+=a[i]-a[i]%10+10;
		}
	}
	cout<<ans+a[c]<<endl;
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int sum = 0;
    for (char c : S) {
        sum += c - '0';
    }
    if (sum % 9 == 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 3748
n=int(input())
s=input()
p=0
q=s[0]
ans=s[1:].count('E')
y=ans
for i in range(1,n):
  p=q
  q=s[i]
  if p=='W':
    y+=1
  if q=='E':
    y-=1
  ans=min(ans,y)
print(ans)

Measured memory_bytes: 3672
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ks = readln.split.to!(int[]);
    auto K = ks[0];
    auto S = ks[1];
    int r;
    foreach (i; 0..K+1) {
        foreach (j; 0..K+1) {
            auto k = S - i - j;
            if (0 <= k && k <= K) ++r;
        }
    }
    writeln(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    ll a = 1;
    ll n = 0;
    while(true){
        if((a-1)/25 <= N && N < (a*26-1)/25){
            break;
        }
        n++;
        a *= 26;
    }
    ll b = N - (a-1)/25;
    string s = "";
    rep(i, n){
        ll c = b % 26;
        s += 'a' + c;
        b /= 26;
    }
    reverse(all(s));
    cout << s << endl;
}

Measured memory_bytes: 3532
import math


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

n = int(input())
ans_dict = {}

for _ in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    try:
        ans_dict[s] += 1
    except:
        ans_dict[s] = 1

ans = 0
for key in ans_dict:
    if ans_dict[key] >= 2:
        ans += combinations_count(ans_dict[key], 2)
print(ans)



Measured memory_bytes: 17932
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       int n,k;
       cin>>n>>k;
       int a[n],s=0;
       for(int i=0;i<n;i++)
       cin>>a[i];
       sort(a,a+n);
       for(int i=0;i<k;i++)
       s=s+a[i];
       cout<<s<<"\n";
    }
}



Measured memory_bytes: 3648
N, Q = [int(s) for s in input().split()]
S = input()
AC = [0]
for i in range(N-1):
    if S[i:i+2] == 'AC':
        AC.append(AC[-1] + 1)
    else:
        AC.append(AC[-1])
for i in range(Q):
    l, r = [int(s)-1 for s in input().split()]
    print(AC[r] - AC[l])

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

#define vi vector<int>
#define p pair<int, int>
#define REP(i, n) for(int i = 0;i < n; i++)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define BR cout << endl;
#define INF  2000000000

int main(){
    int n, a, b, c, d;
    cin >> n;
    d = n % 10; n /= 10;
    c = n % 10; n /= 10;
    b = n % 10; n /= 10;
    a = n % 10;

    REP(i, 2) REP(j, 2) REP(k, 2){
        int ans = a;
        ans += b * (i ? 1 : -1);
        ans += c * (j ? 1 : -1);
        ans += d * (k ? 1 : -1);
        if(ans == 7){
            cout << a << (i?'+':'-') << b << (j?'+':'-') << c << (k?'+':'-') << d << "=7" << endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 3;
const int N = 5e3 + 10, M = 1e6 + 10;
const ll INF = 2e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int p[N];
int c[N];
int n, k;
int cnt;
bool vis[N];
int way[N];
__int128 sum[N];

void dfs(int x)
{
    if (!vis[p[x]])
    {
        way[++cnt] = p[x];
        vis[p[x]] = 1;
        dfs(p[x]);
    }
}

inline void print(__int128 x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9)
        print(x / 10);
    putchar(x % 10 + '0');
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        scanf("%d", &p[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &c[i]);
    __int128 res = -1000000000000000000000000000000000000000000;
    for (int i = 1; i <= n; i++)
    {
        memset(vis, 0, sizeof vis);
        cnt = 0;
        dfs(i);
        if (k <= cnt)
        {
            __int128 ans = -1000000000000000000000000000000000000000000;
            for (int j = 1; j <= k; j++)
            {
                sum[j] = sum[j - 1] + c[way[j]];
                ans = max(ans, sum[j]);
            }
            res = max(res, ans);
        }
        else
        {
            for (int j = 1; j <= cnt; j++)
            {
                sum[j] = sum[j - 1] + c[way[j]];
            }
            if (sum[cnt] >= 0)
            {
                if (k % cnt)
                {
                    __int128 s = (k / cnt) * sum[cnt];
                    int r = k % cnt;
                    for (int j = 0; j <= r; j++)
                        res = max(res, s + sum[j]);
                }
                else
                {
                    __int128 s = (k / cnt - 1) * sum[cnt];
                    for (int j = 0; j <= cnt; j++)
                        res = max(res, s + sum[j]);
                }
            }
            else
            {
                for (int j = 1; j <= cnt; j++)
                    res = max(res, sum[j]);
            }
        }
    }
    print(res);
    return 0;
}
/*

*/

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

void solve () {
	int n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<ll>());
	ll com = a[0];
	int cnt = 1;
	for (ll i = 1; i < n - 1; i++) {
		if (cnt == n - 1)
			break;
		else if (cnt == n - 2) {
			com += a[i];
			break;
		}
		cnt += 2;
		com += 2 * a[i];
	}
	cout << com << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

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

  for (auto &p : va) {
    cout << p.second + 1 << '\n';
  }

  return 0;
}

Measured memory_bytes: 1536
from collections import Counter

N = int(input())
S = []
for i in range(N):
    s_in = input()
    # if s_in == '' or s_in is None: break
    S.append(s_in)

counter = Counter(S)
for ans in ['AC', 'WA', 'TLE', 'RE']:
    print(f'{ans} x {counter[ans]}')

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if (a<b)
    {
        rep(i,b) cout<<a;
    }
    else {
        rep(i,a) cout<<b;
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define el cout<<endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, m, x;
    cin >> n >> m >> x;
    set<int> a;
    rep (m) {
        int t; cin >> t;
        a.insert(t);
    }
    int s = 0, t = 0;
    repeat (i, n) {
        if (a.find(i) != a.end()) {
            if (i < x) ++s;
            else ++t;
        }
    }
    cout << min(s, t) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    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;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 2e5+10;

ll n,k,x,s[maxn],tree[maxn*4];
vector<ll> v;

void add(ll x){
    while(x < maxn){
        tree[x] += 1;
        x += x&-x;
    }
}

ll sum(ll x){
    ll res = 0;
    while(x > 0){
        res += tree[x];
        x -= x&-x;
    }
    return res;
}

int main(){
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        x = read();
        x -= k;
        s[i] = s[i-1]+x;
    }
    for(int i=0; i<=n; i++)
        v.push_back(s[i]);
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    for(int i=0; i<=n; i++) s[i] = lower_bound(v.begin(),v.end(),s[i])-v.begin()+1;

    ll ans = 0;
    for(int i=0; i<=n; i++){
        ans += sum(s[i]);
        add(s[i]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 5104