akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<double> p(n);
  for (auto&& e : p) {
    cin >> e;
    e /= 100;
  }
  vector<long long> c(1 << n);
  for (int bt = 0; bt < 1 << n; ++bt) {
    long long l = 1;
    for (int i = 0; i < n; ++i) {
      if (bt >> i & 1) {
        if (l / __gcd(l, a[i]) > m / a[i] + 1) {
          l = m + 1;
          break;
        }
        l = l / __gcd(l, a[i]) * a[i];
      }
    }
    c[bt] = m / l;
  }
  for (int i = 0; i < n; ++i) {
    for (int bt = 0; bt < 1 << n; ++bt) {
      if (bt >> i & 1) {
        c[bt] -= c[bt ^ 1 << i];
      }
    }
  }
  double res = 0;
  for (int bt = 0; bt < 1 << n; ++bt) {
    double pp = 1;
    for (int i = 0; i < n; ++i) {
      if (bt >> i & 1) {
        pp *= p[i];
      } else {
        pp *= 1 - p[i];
      }
    }
    if (__builtin_parity(bt)) {
      res += pp * (m + c[bt]);
    } else {
      res += pp * (m - c[bt]);
    }
  }
  cout << res << '\n';
}



Measured memory_bytes: 11144
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void reverse(int* list, int size);

int main(void) {
	int n;
	int i = 0;
	int list[100];
	char buff[10240];
	char *ptr;
	memset(list, 0x00, sizeof(list));

	scanf("%d\n", &n);
	gets(buff);

	ptr = strtok(buff, " ");
	while(ptr != NULL) {
		list[i++] = atoi(ptr);
		ptr = strtok(NULL, " ");
	}

	reverse(list, n);

	for(i=0;i<n;i++) {
		printf("%d", list[i]);
		if(i<n-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}

	return 0;
}

void reverse(int* list, int size) {
	int i, tmp;
	for(i=0;i<size/2;i++) {
		tmp = list[i];
		list[i] = list[size-1-i];
		list[size-1-i] = tmp;
	}
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<long long> num(K, 0);
  for (int i = 1; i <= N; i++) num.at(i % K)++;
  long long ans = 0;
  for (int a = 0; a < K; a++) {
    int b = (K-a) % K;
    int c = (K-a) % K;
    if ((b+c) % K != 0) continue;
    ans += num.at(a) * num.at(b) * num.at(c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
s=input()

YYMM=False
MMYY=False

month=[]
for i in range(1,13):
    if len(str(i))==1:
        month.append("0"+str(i))
    else:
        month.append(str(i))

if s[:2] in month:
    MMYY=True

if s[2:] in month:
    YYMM=True

if MMYY is True and YYMM is True:
    print("AMBIGUOUS")
elif  MMYY is True and YYMM is False:
    print("MMYY")
elif  MMYY is False and YYMM is True:
    print("YYMM")
else:
    print("NA")

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



int main(){
    int n;
    int ans=0;
    cin >> n;
    rep(i,n){
        int l,r;
        cin >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;
   return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int ans = s.size();
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] != s[i + 1]) {
      ans = min(ans, max(i + 1, (int) s.size() - i - 1));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;

	vector<int64_t> as(n + 1);
	int64_t init_sum = 0;
	for (auto& a : as) {
		cin >> a;
		init_sum += a;
	}

	vector<int64_t> bs(n);
	for (auto& b : bs) {
		cin >> b;
	}

	FOR_DW(i, n - 1, 0) {
		if (bs[i] < as[i + 1]) {
			as[i + 1] -= bs[i];
			continue;
		}
		int64_t next = as[i + 1];
		as[i + 1] -= next;
		bs[i] -= next;
		as[i] -= min(as[i], bs[i]);
	}

	int64_t sum = 0;
	FOR_LT(i, 0, n + 1) {
		sum += as[i];
	}

	cout << (init_sum - sum) << endl;


	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j,r,c;
    int t[101][101];
    int sum;
    
    for(i=0; i<101; i++){
        for(j=0; j<101; j++){
            t[i][j]=0;
        }
    }
    
    scanf("%d %d",&r,&c);
    
    for(i=0; i<r; i++){
        sum = 0;
        for(j=0; j<c; j++){
            scanf("%d",&t[i][j]);
            sum += t[i][j];
        }
        t[i][c] = sum;
    }
    
    for(j=0; j<c+1; j++){
        sum = 0;
        for(i=0; i<r; i++){
            sum += t[i][j];
        }
        t[r][j] = sum;
    }
    
    for(i=0; i<r+1; i++){
        for(j=0; j<c+1; j++){
            if(j!= 0)printf(" ");
            printf("%d",t[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2044
lens = int(input())
vals = [int(x) for x in input().split()]

ans = 0
maxs = 0

for i in range(lens - 1):
    if vals[i] >= vals[i + 1]:
        ans += 1
    else:
        maxs = max(maxs, ans)
        ans = 0

print(max(maxs, ans))



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

int main() {
	int A,B,C;
	//scanf("%d %d %d",&A,&B,&C);
	cin >> A;
	cin >> B;
	cin >> C;
	if ((A==B && B!=C) || (B==C && C!=A) || (C==A && A!=B))
		{
			cout << "Yes" << endl;
		}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int x[N], y[N], h[N];
	rep(i, 0, N) cin >> x[i] >> y[i] >> h[i];

	rep(cx, 0, 101) rep(cy, 0, 101) {
		if(h[0] != 0) {
			int H = h[0] + abs(x[0] - cx) + abs(y[0] - cy);
			bool flag = true;
			rep(i, 1, N) {
				if(h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
					flag = false;
					break;
				}
			}

			if(flag) {
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		} else {
			int max_h = abs(x[0] - cx) + abs(y[0] - cy);
			rep(hi, 0, max_h + 1) {
				bool flag = true;
				rep(i, 0, N) {
					if(h[i] != max(hi - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
						flag = false;
						break;
					}
				}
				if(flag) {
					cout << cx << " " << cy << " " << hi << endl;
					return 0;
				}
			}

		}

	}

}


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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
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;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  reverse(all(a));
  ll ans=0;
  rep(i,n/2)ans+=a[i]*2;
  ans-=a[0];
  if(n%2==1)ans+=a[n/2];
  cout<<ans<<endl;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repc(i, b, e) for(auto i = (b); i != (e); i++)

int main(){
    ll x, y, r;
    cin >> x >> y;
    while (y != 0){
        r = x % y;
        x = y;
        y = r;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <math.h>
using namespace std;
typedef long double ll;
int main()
{
  int n;
  ll d;
  cin>>n>>d;
  int c=0;
  for(int i=1;i<=n;i++)
  {
    ll x,y;
    cin>>x>>y;
    ll dis=sqrt((x*x)+(y*y));
    if(dis<=d)
      c++;
  }
  cout<<c;
  return 0;
}
      

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

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

	vector<int> V(N);
	vector<int> C(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> V[i];
	}
	for (auto i = 0; i < N; ++i)
	{
		cin >> C[i];
	}

	auto sum = 0;
	for (auto i = 0; i < N; ++i)
	{
		auto diff = V[i] - C[i];
		if (diff > 0)
		{
			sum += diff;
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = list(map(str, input().split()))
while True:
    strn = str(n)
    for i in range(len(strn)):
        if strn[i] in d:
            n += 1
            break
        if i == len(strn)-1:
            print(n)
            exit()


Measured memory_bytes: 40048
#include<stdio.h>
int main(){
  int i,j,n,count[100]={0};
  char ch;
  while(scanf("%c",&ch)!=EOF){
    if(ch>='a' && ch<='z'){
      count[ch-'a']++;
    }
    else if(ch>='A'&& ch<='Z'){
      count[ch-'A']++;
    } 
  }
  for(j=0;j<26;j++){
  printf("%c : %d\n",j+'a',count[j]);
  }
  return (0);
}

Measured memory_bytes: 540
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1e15
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N;
    cin>>N;
    v A(N+1);
    rep(i,0,N+1)cin>>A[i];
    v max_l(N+1);
    bool ok = true;
    max_l[0] = 1-A[0];

    rep(i,1,N+1){
        max_l[i] = min(max_l[i-1]*2-A[i],ll(INF));
        if(max_l[i]<0)ok = false;
    }
    ll ans = A[N],now = A[N];
    for(ll i = N-1;i >=0; i--){
        if(now == 0)ok = false;
        if(now > max_l[i] * 2)ok = false;
        ll now_l = min(now,max_l[i]);
        now = now_l + A[i];
        ans += now;
    }
    if(ok == false || (N == 0 && A[0] >= 2))cout<<-1;
    else cout<<ans;

    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a = max<T>(a, b);}

const ll INF = 1LL<<55;

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n  >>k;
	VI v(n);
	rep(i, n) cin >>v[i];
	vector<VL> dp(k+4, VL(3, -INF));
	dp[0][0] = 0;
	rep(i, n){
		vector<VL> ndp(k+4, VL(3, -INF));
		rep(j, k+1){
			amax(ndp[j+1][0], dp[j][0] + v[i]);
			amax(ndp[j+2][0], dp[j][0] );
			amax(ndp[j][1],   max(dp[j][0], dp[j][1]));
			amax(ndp[j][2],   dp[j][0] );
			amax(ndp[j+1][2], max(dp[j][1], dp[j][2] ) + v[i]);
			amax(ndp[j+2][2], dp[j][2]);
		}
		swap(dp, ndp);
	}
	ll ans = 0;
	rep(i, k+1) rep(j, 3) ans = max(ans, dp[i][j]);
	cout << ans <<"\n";

	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve() {
	int n;
	cin >> n;

	int ac = 0, wa = 0, tle = 0, re = 0;

	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "AC")
			ac++;
		if (s == "WA")
			wa++;
		if (s == "TLE")
			tle++;
		if (s == "RE")
			re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Ma = sc.nextInt();
    int Mb = sc.nextInt();
    // dp[n][i][j]は薬品nまででAをig,Bをjgつくる最小予算を表す。
    int[][][] dp = new int[N][N * 10 + 1][N * 10 + 1];
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }
    for(int i = 0; i < N * 10 + 1; i++) {
      for(int j = 0; j < N * 10 + 1; j++) {
        if((i == a[0]) && (j == b[0])) {
          dp[0][i][j] = c[0]; 
        } else {
          if((i != 0) || (j != 0)) dp[0][i][j] = 10000;
        }
      }
    }
    for(int n = 1; n < N; n++) {
      for(int i = 0; i < N * 10 + 1; i++) {
        for(int j = 0; j < N * 10 + 1; j++) {
          if((i >= a[n]) && (j >= b[n])) {
            dp[n][i][j] = Math.min(dp[n - 1][i][j], dp[n - 1][i - a[n]][j - b[n]] + c[n]);
          } else {
            dp[n][i][j] = dp[n - 1][i][j];
          }
        }
      }
    }
    int ans = 10000;
    for(int k = 1; k <= 400; k++) {
      if((k * Ma < N * 10 + 1) && (k * Mb < N * 10 + 1)) ans = Math.min(ans, dp[N - 1][k * Ma][k * Mb]);
    }
    if(ans == 10000) ans = -1;
    System.out.println(ans); 
  }
}

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

int main(){

    int n;
    cin >> n;

    vector<double> v;
    int i;
    long int a;

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

    long int min, max, sum = 0;

    sort(v.begin(), v.end());
    min = v[0];
    max = v[n-1];
    for(i=0; i<n; i++)  sum += v[i];

    printf("%ld %ld %ld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 3408
import java.util.Scanner;
 
class Main {
    public static void main (String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
            if (A[i] > max) {
                max = A[i];
            }
        }
 
        int[] B = countingSort(A, max);
 
        StringBuilder sb = new StringBuilder("");
        sb.append(B[0]);
        for (int i = 1; i < B.length; i++) {
            sb.append(" ").append(B[i]);
        }
        System.out.println(sb);
    }
 
    public static int[] countingSort(int[] A, int k) {
        int[] B = new int[A.length];
        int[] C = new int[k + 1];
        int i;
        for (i = 0; i < A.length; i++) {
            C[A[i]]++;
        }
        for (i = 1; i <= k; i++) {
            C[i] += C[i - 1];
        }
        for (i = A.length - 1; i >= 0; i--) {
            B[C[A[i]] - 1] = A[i];
            C[A[i]]--;
        }
        return B;
    }
}


Measured memory_bytes: 507856
using System;

class Atcoder71
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int d = int.Parse(input[3]);

        if ((a + b) > (c + d))
            Console.WriteLine("Left");
        else if ((a + b) < (c + d))
            Console.WriteLine("Right");
        else
            Console.WriteLine("Balanced");
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.lang.model.util.ElementScanner6;

class Main {
    public static boolean isPrime(int a) {
        for (int i = 2; i <= Math.sqrt(a); i++) {
            if (a % i == 0)
                return false;
        }
        return true;
    }

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int n = Integer.parseInt(br.readLine());
            int[] nums = new int[n];
            int count = 0;

            for (int i = 0; i < n; i++)
                nums[i] = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                if (isPrime(nums[i]))
                    count++;
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}


Measured memory_bytes: 30280
#include<bits/stdc++.h>
using namespace std;
int n;
double dp[303][303][303];
int main()
{
    cin>>n;
    int a1=0,b1=0,c1=0;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        if(t==1)
        a1++;
        if(t==2)
        b1++;
        if(t==3)
        c1++;
    }
    for(int c=0;c<=n;c++)
        for(int b=0;b<=n;b++)
            for(int a=0;a<=n;a++)
            {
                int res=a+b+c;
                if(res==0){
                dp[0][0][0]=0.0;continue;}
                if(res>n)
                    break;
                double ans=n;
                if(a)
                ans+=a*dp[a-1][b][c];
                if(b)
                ans+=b*dp[a+1][b-1][c];
                if(c)
                ans+=c*dp[a][b+1][c-1];
                ans/=res;
                dp[a][b][c]=ans;   
            }
    cout<<setprecision(10)<<dp[a1][b1][c1];
}

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

int main()
{
    int n ;
    cin >> n ;
    long long arr[n+5]{};
    for(int i = 0 ; i < n ; i++){
        cin >> arr[i];
    }
    if(n<3){
        cout << "0" << endl;
        return 0;
    }
    sort(arr,arr+n);
    long long ans = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = i ; j < n ; j++){
            for(int k = j ; k < n ; k++){
                set<long long>s;
                s.insert(arr[i]);
                s.insert(arr[j]);
                s.insert(arr[k]);
                if(s.size() == 3){
                    if(arr[i] + arr[j] > arr[k]){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n+1)
count=0
now=1
f=1
for _ in range(k):
    if b[now]:
        f=0
        break
    count+=1
    b[now]=count
    now=a[now-1]
if f:
    print(now)
    exit()
x=count-b[now]+1
y=(k-b[now]+1)%x
for i in range(y):
    now=a[now-1]
print(now)

Measured memory_bytes: 32376
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int A, B;

void solve() {
}

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

    int MIN = 0, MAX = 0;
    int N;
    cin >> N >> A >> B;
    MIN = (N - 2) * A;
    MAX = (N - 2) * B;
    int ans = 0;
    if (A > B)
        ans = 0;
    else if (A < B && N == 1)
        ans = 0;
    else
        ans = MAX - MIN + 1;
    cout << ans << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3612
N = int(input())
C = []
S = []
F = []
for i in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    t = 0
    for j in range(i, N - 1):
        if t <= S[j]:
            t = S[j]
        else:
            t = (t // F[j] + (t % F[j] > 0)) * F[j]
        t += C[j]
    print(t)
    

Measured memory_bytes: 3188
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    lint h, w;
    cin >> h >> w;

    if(h == 1LL || w == 1LL){
        cout << 1 << endl;
        return 0;
    }

    lint ans = 0;

    lint a = (w + 1LL) / 2LL;
    lint b = (h + 1LL) / 2LL;

    ans += a * b;

    a = w / 2LL;
    b = h / 2LL;

    ans += a * b;

    cout << ans << endl;

    cout << flush;

    return 0;
}

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

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i<n; i++){
        cin >> b.at(i);
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(b.at(i) == a.at(j).at(k)){
                    a.at(j).at(k) = 0;
                }
            }
        }
    }
    int flag = 0;
    for(int i = 0; i < 3; i++){
        if(a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0){
            flag = 1;
        }
    }
    for(int i = 0; i < 3; i++){
        if(a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0){
            flag = 1;
        }
    }
    if(a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0){
        flag = 1;
    }
    if(a.at(0).at(2) == 0 && a.at(1).at(1) == 0 && a.at(2).at(0) == 0){
        flag = 1;
    }
    if(flag == 1){
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;



void main() {
    string[] input = new string[](3);

    while ((input = readln.chomp.split(" ")).length != 0) {
        auto sum = 0;
        auto data = input.map!(to!int).array;

        data[0] %= data[1];
        foreach (i; 0..data[2]) {
            data[0] *= 10;
            sum += data[0] / data[1];
            data[0] %= data[1];
        }

        writeln(sum);
    }
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;

    return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,a0=0,a1=0,s0=0,s1=0,nxt,fv;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  s0 = a[0];
  s1 = a[0];
  if(a[0]<=0){
    a0 += -a[0] + 1;
    s0 = 1;
  }
  if(a[0]>=0){
    a1 += a[0] + 1;
    s1 = -1;
  }
  for(int i=1;i<n;i++){
    nxt = s0 + a[i];
    if(nxt*s0>=0){
      if(nxt>=0){
        a0 += nxt+1;
        nxt = -1;
      }else{
        a0 += -nxt+1;
        nxt = 1;
      }
    }
    s0 = nxt;

    nxt = s1 + a[i];
    if(nxt*s1>=0){
      if(nxt>=0){
        a1 += nxt+1;
        nxt = -1;
      }else{
        a1 += -nxt+1;
        nxt = 1;
      }
    }
      s1 = nxt;
  }
  cout << min(a0,a1)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9+5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main1(){
    int n;
    while(cin>>n){
        vi dp(n+1, 1e6);
        vi h(n+1);
        for(int i=1; i<=n; i++)
            cin>>h[i];
        
        for(int i=1; i<=n; i++){
            int c1 = i-1>=0 ? dp[i-1] + abs(h[i] - h[i-1]) : 0;
            int c2 = i-2>=0 ? dp[i-2] + abs(h[i] - h[i-2]) : 0; 
            dp[i] = min(c1,c2);
        }

        cout<<dp[n]<<endl;
    }
    

    return 0;
}

int main(){
    int n;
    while(cin>>n){
        vi dp(n+1, inf);
        vi h(n);
        for(int i=0; i<n; i++)
            cin>>h[i];
        
        dp[0] = 0;        
        for(int i=0; i<n; i++){
            for(int j: {i+1, i+2}){
                if(j<n){
                    dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
                }
            }
        }

        cout<<dp[n-1]<<"\n";
    }
}

Measured memory_bytes: 1024
//2019.5.16 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=4e5+10;
namespace MAIN {
    int n,m,a[N];
    inline bool check(const res &lim){
        for(res i=n-lim*2+1,j=n,p=lim;p;p--,i++,j--)if(a[i]+a[j]<m)return 0;
        return 1;
    }
    int ans;
    inline void MAIN(){
        n=read()<<1,m=read();
        for(res i=1;i<=n;i++)a[i]=read();
        sort(a+1,a+n+1);
        res l=0,r=n>>1,ret=-1;
        while(l<=r){
            res mid=(l+r)>>1;
            if(check(mid))l=mid+1,ret=mid;
            else r=mid-1;
        }
        for(res i=n-ret*2+1,j=n,p=ret;p;p--,i++,j--)ans=max(ans,a[i]+a[j]-m);
        for(res i=1,j=n-ret*2,p=n/2-ret;p;p--,i++,j--)ans=max(ans,a[i]+a[j]);
        printf("%d\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}


Measured memory_bytes: 1024
# SPDX-License-Identifier: X11
# 2020-09-01
# Making Triangle (200pt)

function main()
  N = parse(Int, readline())
  L = parse.(Int, split(readline()))
  sort!(L)

  c = 0
  for i ∈ 1:N - 2
    for j ∈ i + 1:N - 1
      for k ∈ j + 1:N
        L[i] != L[j] != L[k] && L[i] + L[j] > L[k] && (c += 1)
      end
    end
  end

  println(c)
end

main()


Measured memory_bytes: 173320
r, c = [int(i) for i in input().split()]
a = []

for i in range(r):
    total = 0
    b = input().split()
    for j in b:
        total += int(j)
    b.append(total)
    a.append(b)
C = []
for i in range(c + 1):
    t = 0
    for j in range(r):
        t += int(a[j][i])
    C.append(t)
a.append(C)
for i in a:
    for j in range(len(i)):
        if j != len(i)-1:
            print(i[j], end =" ")
        else:
            print(i[j])


Measured memory_bytes: 6728
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define vi vector<int> 
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define fi first
#define se second
using namespace std;
void solve()
{
	int n;
	cin>>n;
	if(n==1)
	cout<<0;
	else if(n==0)
	cout<<1;
}
int32_t main()
{
	//freopen("shell.in", "r", stdin);
	//freopen("shell.out", "w", stdout);
	int t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3584
from collections import deque
 
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
stage = ['#'+input()+'#' for i in range(h)]
stage = ['#'*(w+2)] + stage + ['#'*(w+2)]
queue = deque([(ch,cw)])
check = [[1]*(w+2) for i in range(h+2)]
searched_temp = [(ch,cw)]
count = 0
 
while True:
  searched = searched_temp
  
  while len(queue):
    v = queue.popleft()
    if v == (dh,dw):
      print(count)
      exit()
 
    if stage[v[0]-1][v[1]] == '.' and check[v[0]-1][v[1]]:
      queue.append((v[0]-1,v[1]))
      check[v[0]-1][v[1]] = 0
      searched.append((v[0]-1,v[1]))
    if stage[v[0]+1][v[1]] == '.' and check[v[0]+1][v[1]]:
      queue.append((v[0]+1,v[1]))
      check[v[0]+1][v[1]] = 0
      searched.append((v[0]+1,v[1]))
    if stage[v[0]][v[1]-1] == '.' and check[v[0]][v[1]-1]:
      queue.append((v[0],v[1]-1))
      check[v[0]][v[1]-1] = 0
      searched.append((v[0],v[1]-1))
    if stage[v[0]][v[1]+1] == '.' and check[v[0]][v[1]+1]:
      queue.append((v[0],v[1]+1))
      check[v[0]][v[1]+1] = 0
      searched.append((v[0],v[1]+1))
  
  count += 1
  searched_temp = []
  for s in searched:
    for i in range(-2,3):
      for j in range(-2,3):
        y = s[0] + i
        x = s[1] + j
        if 1 <= y and y <= h and 1 <= x and x <= w:
          if stage[y][x] == '.' and check[y][x]:
            check[y][x] = 0
            queue.append((y,x))
            searched_temp.append((y,x))
          
  if len(queue) == 0:
    print(-1)
    break

Measured memory_bytes: 97568
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  int x;
  int ans=1;
  cin >> x;
  for(int i=0;i<3;i++){
    ans=ans*x;
  }
    cout << ans << endl;

  return 0;
}




Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N;
    cin >> N;
    VVI g(N);
    VI C(N);
    REP(i,N){
        cin >> C[i];
        C[i]--;
    }

    REP(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].eb(b);
        g[b].eb(a);
    }

    VVI res(N);
    VI cnt(N);
    vector<map<int,int>> dp(N);
    auto dfs = [&](auto&& dfs, int i, int p) -> void{
        for(int j : g[i]){
            if(j == p) continue;
            dfs(dfs,j,i);
            cnt[i] += cnt[j];

            int c = cnt[j];
            if(dp[j].count(C[i])) c -= dp[j][C[i]];
            res[C[i]].eb(c);

            if(SZ(dp[i]) < SZ(dp[j])) swap(dp[i], dp[j]);
            for(auto p : dp[j]) dp[i][p.first] += p.second;
        }
        cnt[i]++;
        dp[i][C[i]] = cnt[i];
    };
    
    dfs(dfs,0,-1);
    REP(i,N) res[i].eb(N - dp[0][i]);
    
    LL all = 1LL * N * (N+1) / 2;
    VL ans(N,all);
    REP(i,N) for(LL a : res[i]) ans[i] -= a*(a+1) / 2;

    for(LL a : ans) cout << a << endl;



}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string a,b;cin >>a>>b;
    a+=b;
    ll n=a.size();
    ll num=0;
    for (int i = 0; i < n; ++i) {
        num*=10;
        num+=a[i]-'0';
    }
    bool flg=false;
    for (int i = 0; i < num; ++i) {
        if(num==i*i){
            flg=true;
        }
    }
    if(flg){
        puts("Yes");
    }
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
def possibleCombos(num):
    num2 = num - 1
    return (num2*num2 + num2)//2
N = int(input())
A = [int(i) for i in input().split()]
data = [0] * (N+1)
total = 0
for i in A:

    data[i] +=1

for i in data:
    total += possibleCombos(i)
for i in A:
    result = total - possibleCombos(data[i]) + possibleCombos(data[i]-1)
    print(result)







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

int main() {
    vector<bool> prime(300'001, true);
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i < 300'001; i++) {
        if ((i % 7 == 1 || i % 7 == 6) && prime[i]) {
            for (int j = i*2; j < 300'001; j += i) {
                prime[j] = false;
            }
        }
        if (i % 7 != 1 && i % 7 != 6) prime[i] = false;
    }
    while (1) {
        int n;
        cin >> n;
        if (n == 1) break;
        cout << n << ":";
        vector<int> ans;
        for (int i = 1; i <= sqrt(n); i++) {
            if (n % i == 0) {
                ans.push_back(i);
                if (i * i != n) ans.push_back(n/i);
            }
        }
        sort(ans.begin(), ans.end());
        int k = (int)ans.size();
        for (int i = 0; i < k; i++) {
            if (prime[ans[i]]) cout << " " << ans[i];
        }
        cout << endl;
    }
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,br=0,a,b,c;
    cin >> n;
    vector<int> v(n);
    for (int i=0;i<n;i++)
        cin >> v[i];
    for (int i=0;i<n-2;i++)
        for (int j=i+1;j<n-1;j++)
            for (int k=j+1;k<n;k++)
            {
                a=v[i]; b=v[j]; c=v[k];
                if(a+b>c && b+c>a && a+c>b && a!=b && b!=c && a!=c)
                    br++;
            }
    cout << br;
}


Measured memory_bytes: 3588
import numpy as np
from itertools import combinations, permutations

n = int(input())
ls = [list(map(int, input().split())) for _ in range(n)]


def mean_dis(data):
    comb = permutations(data, n)
    sum = 0
    count = 0
    for c in comb:
        count += 1
        for i in range(1, len(c)):
            _c = np.array([c[i-1], c[i]])
            euclid = np.sqrt(np.sum((_c[0]-_c[1]) ** 2))
            sum += euclid
    return sum/count


def mean_dis2(data, n):
    comb = combinations(data, 2)
    all_dis = 0
    for c in comb:
        _c = np.array([c[0], c[1]])
        euclid = np.sqrt(np.sum((_c[0] - _c[1]) ** 2))
        all_dis += euclid

    return (all_dis*2)/n

print(mean_dis2(ls, n))

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

const int N = 1e5 + 5;

long long a[N], b[N];

int main() {
#ifdef HOME_NONU
    freopen("dat.in", "r", stdin);
    freopen("dat.out", "w", stdout);
#endif
    long long n, ans = 0;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
        scanf("%lld %lld", &a[i], &b[i]);
    for (int i = n; i >= 1; i--) {
        if ((a[i] + ans) % b[i] > 0) {
            ans = ans + b[i] - (a[i] + ans) % b[i]; } }
    printf("%lld\n", ans);
    return 0; }


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

int main() {
  int A, B;
  cin >> A >> B;

  if (A == 1) A += 13;
  if (B == 1) B += 13;

  if (A > B)
    cout << "Alice";
  else if (A < B)
    cout << "Bob";
  else
    cout << "Draw";

  cout << endl;
}

Measured memory_bytes: 256
n ,k =map(int, input().split())
S=[]

def merge(array):                                   # line1
    mid = len(array)                                # line2
    if mid > 1:                                     # line3
        left = merge(array[:(mid//2)])               # line4
        right = merge(array[(mid//2):])              # line5
        array = []                                  # line6
        while len(left) != 0 and len(right) != 0:   # line7
            if left[0] < right[0]:                  # line8
                array.append(left.pop(0))           # line9
            else:                                   # line10
                array.append(right.pop(0))          # line11
        if len(left) != 0:                          # line12
            array.extend(left)                      # line13
        elif len(right) != 0:                       # line14
            array.extend(right)                     # line15
    return array



for i in range(n):
	a=int(input())
	S.append(a)
L=merge(S)

ans=-L[0]+L[n-1]
for i in range(n-k+1):
	if -L[i]+L[i+k-1]<ans:
		ans=-L[i]+L[i+k-1]
print(ans)
	

Measured memory_bytes: 16208
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  ll a, b;
  cin >> n >> a >> b;
  ll l, r;
  cin >> l;
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    cin >> r;
    ans += min((r - l) * a, b);
    l = r;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(item) for item in input().split()]

ans = 0
for c in range(1, n):
    visited = set([0, n-1])
    total = 0
    for k in range(1, n):
        odd = n - 1 - k*c
        even = k * c
        if even >= n - 1:
            break
        if odd < c:
            break
        if even in visited:
            break
        visited.add(even)
        if odd in visited:
            break
        visited.add(odd)
        total += a[odd] + a[even]
        ans = max(ans, total)
        # print(c, k, total)
        # print(visited)
print(ans)

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

using namespace std;

int main(){
   long long int a,b;
   cin >> a >> b;
   if(a>0){
      cout << "Positive" << endl;
      return 0;
   }
   if(a <= 0 && b >= 0){
      cout << "Zero" << endl; 
      return 0;
   }
   if(b < 0){
      if((b-a+1)%2 == 0){
         cout << "Positive" << endl;
      } 
      else{
         cout << "Negative" << endl;
      }
   }
   return 0;
}


Measured memory_bytes: 256
fn readline() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}
fn readnums() -> Vec<i64> {
    readline().split(" ").map(|x| x.parse().unwrap()).collect()
}

fn main() {
    readline();
    let a = readnums();

    let mut map = std::collections::HashMap::new();
    let mut ans = 0;

    for (i, ai) in (&a).into_iter().enumerate() {
        if let Some(cnt) = map.get(&(i as i64 - ai)) {
            ans += cnt
        }

        map.entry(i as i64 + ai)
            .and_modify(|x| *x += 1)
            .or_insert(1i64);
    }

    println!("{}", ans)
}


Measured memory_bytes: 12316
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
int main() {
	// your code goes here
	int a,b,i,ans;
	cin>>a>>b;
	int t1,t2;
	for(int i=1;i<=1000;i++){
		t1=i*0.08;
		t2=i*0.1;
		if(t1==a && t2==b){
          cout<<i;
          return 0;
		}
	}
	cout<<-1;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int ch[10101];

int main() {
	int n;
	while (cin >> n&&n) {
		for (int i = 1; i <= n; i++) {
			cin >> ch[i];
		}
		ch[0] = ch[n + 1] = 5;
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= 3; j++) {
				int color = j;
				int sum = 0, count = 1;
				int left = i - 1, right = i + 1;
				while (1) {
					while (ch[left] == color)left--, count++;
					while (ch[right] == color)right++, count++;
					if (count < 4)break;
					sum += count;
					count = 0;
					if (ch[left] != ch[right])break;
					color = ch[left];
				}
				ans = max(ans, sum);
			}
		}
		cout << n - ans << endl;
	}
}

Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll K;
    cin >> K;
    vector<ll> res(50);
    rep(i, 50) { res[i] = K / 50 + 49; }
    for(int i = 0; i < 50; i++) {
        if(i < K % 50) {
            res[i] = res[i] + 50 - (K % 50) + 1;
        } else {
            res[i] = res[i] - (K % 50);
        }
    }
    cout << 50 << endl;
    rep(i, 50) { cout << res[i] << " "; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a[3][3];
  int n,i,j,k;
  int b[11];
  scanf("%d %d %d\n%d %d %d\n%d %d %d\n%d",&a[1][1],&a[1][2],&a[1][3],&a[2][1],&a[2][2],&a[2][3],&a[3][1],&a[3][2],&a[3][3],&n);
  for(i=1;i<=n;i++){
    scanf("\n%d",&b[i]);
  }
  
  int p[3][3];
  for(i=1;i<=3;i++){
    for(j=1;j<=3;j++){
      p[i][j]=0;
      for(k=1;k<=n;k++){
        if(a[i][j]==b[k]){
          p[i][j]=1;
        }
      }
    }
  }
  
  int x=0;
  for(i=1;i<=3;i++){
    if(p[i][1]*p[i][2]*p[i][3]==1){
      x=1;
    }
    if(p[1][i]*p[2][i]*p[3][i]==1){
      x=1;
    }
  }
  if(p[1][1]*p[2][2]*p[3][3]==1||p[1][3]*p[2][2]*p[3][1]==1){
    x=1;
  }
  
  if(x==1){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 256