akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHarshadNumber solver = new BHarshadNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHarshadNumber {
        private static final String YES = "Yes";
        private static final String NO = "No";

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), t = n;
            int f = 0;
            while (t > 0) {
                f += t % 10;
                t /= 10;
            }
            out.println(n % f == 0 ? YES : NO);
        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <math.h>
using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    double P;
    for(int i=1;i<N+1;i++){
        double tmp=1.0/N;
        int now=i;
        while(now<K){
            now*=2;
            tmp/=2;
        }
        P+=tmp;
    }

    printf("%.12f\n",P);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"Yes"<<'\n';
}

void no(){
    cout<<"No"<<'\n';
}

void solve(){
    ll n,k;
    cin>>n>>k;
    n = n%k;
    cout<<min(n,k-n)<<'\n';
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N,K,L = map(int,input().split())

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def check(self, x, y):
        return self.find(x) == self.find(y)

P,Q = UnionFind(N),UnionFind(N)
for _ in range(K):
    x,y = map(int,input().split())
    P.unite(x,y)
for _ in range(L):
    x,y = map(int,input().split())
    Q.unite(x,y)

D = defaultdict(int)
for i in range(1,N+1):
    D[P.find(i),Q.find(i)] += 1

print(" ".join(map(str,list(D[P.par[i],Q.par[i]] for i in range(1,N+1)))))

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1e9 // cf. INT_MAX ≒ 2x10^9
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (long long)pow
#define BIT(i) (long long)pow(2, i)
typedef long long Lint;
#define LINF 4e18 // cf. LLONG_MAX ≒ 9x10^18

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x;

  REP(i, n) {
    int a;
    cin >> a;
    x.push_back(a);
  }

  auto itGrtEq0 = lower_bound(ALL(x), 0);

  vector<int> vcMinus = {0};
  auto itMinus = itGrtEq0;
  while (itMinus != x.begin()) {
    itMinus--;
    vcMinus.push_back(-*itMinus);
  }

  vector<int> vcPlus = {0};
  auto itPlus = itGrtEq0;
  if (itGrtEq0 != x.end() and *itGrtEq0 == 0) {
    itPlus++;
    n--;
    k--;
  }
  while (itPlus != x.end()) {
    vcPlus.push_back(*itPlus);
    itPlus++;
  }

  int nMinusMax = min(k, (int)vcMinus.size() - 1);
  int nMinusMin = max(0, k - (int)vcPlus.size() + 1);
  int ans = INF;
  FOR(nMinus, nMinusMin, nMinusMax + 1) {
    int nPlus = k - nMinus;
    ans = min(ans, min(2 * vcMinus[nMinus] + vcPlus[nPlus],
                       vcMinus[nMinus] + 2 * vcPlus[nPlus]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1528
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n;
    string s;
    cin>>s;
    if(s[0]=='9'||s[1]=='9')
        yes
    else no


            return 0;
}





Measured memory_bytes: 3644
#include<cstdio>
using namespace std;
int main()
{
	char c;
	int cnt = 0,ans = 0;
	while( ( scanf( "%c" , &c ) ) == 1 ){//求你跑快点 
		cnt++;
		if( cnt % 2 ){
			if( c == 'p' )
			  ans--;//奇数出石头
			continue;
		}
		if( c == 'g' )
		  ans++;//偶数出布 
	}
	printf( "%d" , ans );
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

left = defaultdict(int)
for i in range(n):
    left[i + a[i]] += 1

ans = 0
for i in range(n):
    sub = i - a[i]
    if sub in left:
        ans += left[sub]

print(ans)

Measured memory_bytes: 40516
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    let inf = 10_0000_0000 + 7;
    let mut ans: u128 = 1;
    let mut ans1: u128 = 1;
    let mut ans2: u128 = 1;
    if n==1 {
        println!("0");
        return;
    }  else if n==2 {
        println!("2");
        return;
    } else {
        for i in 0..n {
            ans *= 10;
            ans %= inf;
            ans1 *= 9;
            ans1 %= inf;
            ans2 *= 8;
            ans2 %= inf;
            // debug!(ans);
        }
        ans1 = (((ans+inf-ans1)%inf)*2)%inf;
        ans2 = (ans+inf-ans2)%inf;
        ans = (ans1+inf-ans2)%inf;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string str;
  string front;
  string back;
  int q;
  bool rev=false;

  cin>>str>>q;
  for(int i=0;i<q;i++){
    int com;
    cin>>com;
    if(com==1){
      if(rev){
	rev=false;
      }else{
	rev=true;
      }
    }else{
      int FB;
      char c;
      cin>>FB>>c;
      if(rev){
	if(FB==1){
	  back.push_back(c);
	}else{
	  front.push_back(c);
	}
      }else{
	if(FB==1){
	  front.push_back(c);
	}else{
	  back.push_back(c);
	}
      }
    }
  }
  
  if(rev){
    reverse(str.begin(),str.end());
    reverse(back.begin(),back.end());
    str=back+str+front;
  }else{
    reverse(front.begin(),front.end());
    str=front+str+back;
  }
  cout<<str<<endl;
  return(0);
}

Measured memory_bytes: 1348
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(12);
  std::cerr << std::fixed << std::setprecision(12);

  int N, A[111];

  long double num = 1, denom = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    num *= A[i];
  }

  for (int i = 0; i < N; i ++)
    denom += num / A[i];

  std::cout << num / denom << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 2005
using namespace std;
struct eage{
	int from,to,next;
}e[maxn<<1];
int first[maxn],np=0;
void add(int u,int v){
	e[++np]=(eage){u,v,first[u]};
	first[u]=np;
}
int n,k,ans=0x3f3f3f3f,x,y,cnt,dist[maxn];
void dfs(int i,int f,int dis){
	dist[i]=min(dist[i],dis);
	for(int p=first[i];p;p=e[p].next){
		int j=e[p].to;
		if(j==f) continue;
		dfs(j,i,dis+1);
	}
}
void init(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
    if(k&1){
    	 for(int i=1;i<=np;i+=2){
    	 	memset(dist,0x3f,sizeof(dist));
    	 	cnt=0;
    	 	int u=e[i].from,v=e[i].to;
    	    dfs(u,0,0);dfs(v,0,0);
    	    for(int j=1;j<=n;j++) if(dist[j]>k/2) cnt++;
		    ans=min(ans,cnt);
		 }         
	}
	else{
		for(int i=1;i<=n;i++){
			memset(dist,0x3f,sizeof(dist));
			cnt=0;
			dfs(i,0,0);
			for(int j=1;j<=n;j++) if(dist[j]>k/2) cnt++;
			ans=min(ans,cnt); 
		}
	}
	printf("%d",ans);
} 
int main(){
	init();
	
	return 0;
}

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

struct SCC{
    int N;
    vector<bool> used;
    vector<int> vs;
    vector<int> cmp;

    void dfs(int v, const vector<vector<int>>& G){
        used[v] = true;
        for(auto u : G[v]){
            if(!used[u]) dfs(u, G);
        }
        vs.push_back(v);
    }

    void rdfs(int v, int k, const vector<vector<int>>& rG){
        used[v] = true;
        cmp[v] = k;
        for(auto u : rG[v]){
            if(!used[u]) rdfs(u, k, rG);
        }
    }

    SCC(int N, const vector<vector<int>>& G):N(N){
        vector<vector<int>> rG(N);
        for(int i=0; i<N; i++) for(int j : G[i]) rG[j].push_back(i);
        used.resize(N);
        fill(used.begin(), used.end(), false);
        for(int v=0; v<N; v++){
            if(!used[v]) dfs(v, G);
        }

        fill(used.begin(), used.end(), false);
        cmp.resize(N);
        int k = 0;
        for(int i = vs.size()-1; i>=0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++, rG);
        }
    }

    vector<vector<int>> dump_graph(const vector<vector<int>>& G){
        int sz = *max_element(cmp.begin(), cmp.end()) + 1;
        vector<vector<int>> edges2(sz);
        for(int i=0; i<N; i++){
            for(auto j : G[i]){
                if(cmp[i] != cmp[j]){
                    edges2[cmp[i]].push_back(cmp[j]);
                }
            }
        }
        return edges2;
    }
};

int main(){
    int N, D;
    cin >> N >> D;
    vector<int> A(2*N);
    for(int i=0; i<2*N; i++) cin >> A[i];
    vector<vector<int>> edges(2*N);
    for(int i=0; i<2*N; i++) for(int j=0; j<i; j++) if(i/2 != j/2 && abs(A[i] - A[j]) < D){
        edges[i].push_back(j^1);
        edges[j].push_back(i^1);
    }

    SCC scc(2*N, edges);
    
    vector<int> ans(N);
    for(int i=0; i<N; i++){
        int c1 = scc.cmp[2*i], c2 = scc.cmp[2*i+1];
        if(c1 == c2){
            cout << "No" << endl;
            return 0;
        }else if(c1 < c2){
            ans[i] = A[2*i+1];
        }else{
            ans[i] = A[2*i];
        }
    }

    cout << "Yes" << endl;
    for(int a : ans) cout << a << endl;
    return 0;
}


Measured memory_bytes: 3820
#include <stdio.h>

int main(){

      int A,B,T,i=0,j=0;

      scanf("%d%d%d",&A,&B,&T);

      for(i=1;(i*A)+0.5 <= T || (i*A) <= T;i++){
            j += B;
      }
      printf("%d",j);
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll d = n / (a + b) * a;
    ll r = n % (a + b);

    cout << (a < r ? d + a : d + r) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from fractions import gcd
class seg():
    def __init__(self,init_val):
        self.n=len(init_val)
        self.ide_ele= 0 #単位元
        self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.ide_ele]*2*self.num
        for i in range(self.n):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1):
            self.seg[i]=self.seg_func(self.seg[2*i+1],self.seg[2*i+2])
    def seg_func(self,a,b):
        #return a+b #0
        #return a*b #1
        #return gcd(a,b) #0
        return max(a,b) #0か-1か-10**10 (十分小さいもの，計算に使う場合0)
        #return min(a,b) #10**10 (十分大きいもの)
    def update(self,k,x):
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.seg_func(self.seg[k*2+1],self.seg[k*2+2])
    def query(self,p,q): #O(logN)
        if q<=p:return self.ide_ele
        p+=self.num-1
        q+=self.num-2
        self.res=self.ide_ele
        while q-p>1:
            if p&1==0:
                self.res=self.seg_func(self.res,self.seg[p])
            if q&1==1:
                self.res=self.seg_func(self.res,self.seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:self.res=self.seg_func(self.res,self.seg[p])
        else:self.res=self.seg_func(self.seg_func(self.res,self.seg[p]),self.seg[q])
        return self.res

def main():
    n, k = map(int,input().split())
    A = [int(input())for _ in range(n)]
    max_a = max(A)
    A_len = [0] * (max_a + 1) # 最後の数字がiのときの最大長さ
    SEG = seg(A_len)
    for a in A:
        SEG.update(a, SEG.query(max(a - k, 0), min(a + k, max_a) + 1) + 1)
    print(SEG.query(0, max_a + 1))

if __name__=='__main__':
    main()

Measured memory_bytes: 103196
#include <stdio.h>
#include <stdlib.h>

int change(int x, int y) {
    if(x > y) {
        return x-1;
    }
return x;
}

int kaijo(int x) {
    int ans=1;
    int i;
    for(i=2;i<=x;i++){
        ans*=i;
    }
    return ans;
}

int main() {
    int N;
    scanf("%d", &N);
    int *P = (int*)malloc(N * sizeof(int));
    int *Q = (int*)malloc(N * sizeof(int));
    int i;
    for(i=0; i<N; i++) {
        scanf("%d", &P[i]);
    }
    for(i=0; i<N; i++) {
        scanf("%d", &Q[i]);
    }
    int a = 1;
    int b = 1;
    int j;
    for(i=0; i<N-1; i++) {
        a += (P[i] - 1) * kaijo(N-i-1);
        b += (Q[i] - 1) * kaijo(N-i-1);
        for(j=i+1; j<N; j++) {
            P[j] = change(P[j], P[i]);
            Q[j] = change(Q[j], Q[i]);
        }
    }
    printf("%d\n", abs(a-b));

    free(P);
    free(Q);
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string s; cin >> s;
  if (s == "RRR") {
    cout << 3 << endl;
  } else if (s.find("RR") != string::npos) {
    cout << 2 << endl;
  } else if (s.find("R") != string::npos) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  string s1, s2;
  cin >> n >> s1 >> s2;

  rep(i, 0, n) {
    rep(j, 0, n - i) {
      if(s1[i + j] != s2[j]) break;
      if(j == s2.length() - i - 1) {
        cout << n * 2 - (n - i) << endl;
        return 0;
      }
    }
  }
  cout << n * 2 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    void calc()
    {
        string inp = Console.ReadLine();
        string rev = "";
        foreach (var item in inp)
        {
            rev = item + rev;
        }
        Console.WriteLine(rev);

    }
}

Measured memory_bytes: 5260
m,k=map(int,input().split())
r=range(2**m)
if k>2**m-1or m==k==1:
    print(-1)
elif k:
    a=[i for i in r if i!=k]
    print(*a+[k]+a[::-1]+[k])
else:
    for i in r:print(i,i)

Measured memory_bytes: 14216
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
if a > b:
    t = a
    a = b
    b = t
if b > c:
    t = b
    b = c
    c = t
if a > b:
    t = a
    a = b
    b = t
print(str(a) + " " + str(b) + " " + str(c))
 

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    cout<<a*b-a-b+1<<endl;
    return 0;
}


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

using namespace std;

int main(){
    while(true){
        int n,m;
        cin >> n >> m;
        if(n==0 && m==0)break;
        int ans=0;
        for(int i=3;i<=n;i++){
            for(int j=2;j<i;j++){
                for(int k=1;k<j;k++){
                    if(i+j+k==m)ans++;
                    else if(i+j+k>m)break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a>0 && c>0) {
        c-=b;
        if (c>0) {
            a-=d;
        }
    }
    cout << (a>0?"Yes":"No") << endl;
}


Measured memory_bytes: 3632
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll X;
int main() {

	cin>>X;
	if(X==3 || X==5 || X==7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


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


signed main() {
    int N;
    cin >> N;
    ll A[100010];
    bool res = true;
    rep (i, N) {
        cin >> A[i];
        if (A[i] == 0) {
            res = false;
        }
    }

    if (res == false) {
        cout << 0 << endl;
        return 0;
    }

    ll s = 1;
    rep (i, N) {
        if (A[i] > (1000000000000000000 / s)) {
            res = false;
            break;
        }
        s *= A[i];
    }

    if (res == false) cout << -1 << endl;
    else              cout << s  << endl;

    return 0;
}


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

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;

void solve(ll test_case)
{
  int n;
  cin>>n;
  vi array(n);
  for(int i=0;i<n;i++){
    cin>>array[i];
  }



  //n = (int)array.size();
  ll ans=0;
  if(n<3){
    cout<<0;
    return;
  }
  //set<pair<int,pair<int,int>>>ans;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){
            if(array[i]!=array[j] && array[j]!=array[k] && array[i]!=array[k]){
                if(((array[i]+array[j])>array[k]) && ((array[i]+array[k])>array[j])&& ((array[k]+array[j])>array[i])){
                   // ans.insert({array[i],{array[j],array[k]}});
                   // cout<<i+1<<" "<<j+1<<" "<<k+1<<endl;
                    // cout<<array[i]<<" "<<array[j]<<" "<<array[k]<<endl;
                    ans++;
                }
            }
        }
    }
  }


  cout<<ans;

}

int main()
{

//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1, t1 = 0;
    //cin >> t;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
 return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
  int a[3];
  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 3 ; j++){
      if(a[i] <= a[j]){
        int tmp = a[j];
        a[j] = a[i];
        a[i] = tmp;
      }
    }
  }

  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

P f(int x) {
  int a = x%10, b = 0;
  while(x) { b = x; x /= 10; }
  return P(a,b);
}

int main() {
  int N; cin >> N;
  map<P, int> mp;
  for(int i=1; i<=N; ++i) {
    P p = f(i);
    mp[p]++;
  }
  ll ans = 0;
  for(int i=1; i<=N; ++i) {
    P p = f(i);
    P q(p.second, p.first);
    ans += mp[q];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using AB = pair<int, int>;

int main() {
    int N, A, B;
    cin >> N;
    vector<AB> vec;
    for(int i = 0; i < N; i++) {
        cin >> A >> B;
        vec.emplace_back(A, B);
    }

    sort(vec.begin(), vec.end(),
         [](const AB &ab1, const AB &ab2) { return ab1.second < ab2.second; });
    ll time = 0;
    for(const auto &ab : vec) {
        time += ab.first;
        if(time > ab.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()


bool comp(pair<int, int> l, pair<int, int> r){
  return l.second < r.second || (l.second==r.second&&l.first<r.first);
}

int main () {
  IN(n);
  vector<pair<int,int> > task(n);
  int a, b;
  REP(i,n){
    cin>>a;
    cin>>b;
    task[i]=make_pair(a, b);
  }
  sort(ALL(task), comp);

  ll sum=0;
  REP(i, n){
    if (sum+task[i].first > task[i].second){
      cout<<"No";
      break;
    }
    else{
      sum+=task[i].first;
      if (i==n-1)
	cout<<"Yes";
    }
  }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N, M;
    cin >> N >> M;
    ll p;
    string S;
    vec AC(N, 0), WA(N, 0);
    REP(i,0,M) {
        cin >> p >> S;
        --p;
        if(S == "AC") AC[p] = 1;
        else if(AC[p] == 0) ++WA[p];
    }

    ll sum_ac = 0, sum_wa = 0;
    REP(i,0,N) {
        sum_ac += AC[i];
        sum_wa += WA[i] * AC[i];
    }
    PS(sum_ac);
    PR(sum_wa);



    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include<stdio.h>

int main(){

  int num,soma=0;
  scanf("%d",&num);
  int aux=num;

  while(num>0){
    soma+=num%10;
    num/=10;
  }

    if(aux % soma == 0){
        printf("Yes");
    }

    else{
        printf("No");
    }
  return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];

    int ans = 0;
    for(int i = 0; i < N; i += (K-1)){
        ans++;
        if( i + K >= N ) break;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ff first
#define ss second
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }

struct number {
	int p, q;
	number() : p(0), q(0) {}
	bool operator<(number other) const {
		return (ll) p * other.q < (ll) other.p * q;
	}
};

vector<int> dsu;

int get_root(int v) {
	return v == dsu[v] ? v : dsu[v] = get_root(dsu[v]);
}

void unite(int a, int b) {
	a = get_root(a);
	b = get_root(b);
	dsu[a] = b;
}

void solve() {
	int n;
	cin >> n;
	vector<int> parent(n);
	for (int i = 1; i < n; ++i) {
		int p;
		cin >> p;
		--p;
		parent[i] = p;
	}
	vector<number> have(n);
	set<pair<number, int>> all;
	for (int i = 0; i < n; ++i) {
		int num;
		cin >> num;
		number cur;
		if (num == 0) {
			cur.p = 1;
		} else {
			cur.q = 1;
		}
		if (i) {
			all.insert({cur, i});
		}
		have[i] = cur;
	}

	dsu = vector<int>(n);
	iota(dsu.begin(), dsu.end(), 0);
	ll ans = 0;

	for (int i = 0; i < n - 1; ++i) {
		auto cur = *--all.end();
		all.erase(--all.end());
		int ind = cur.ss;
		int p = parent[ind];
		p = get_root(p);
		all.erase({have[p], p});
		ans += (ll) have[ind].p * have[p].q;
		have[p].p += have[ind].p;
		have[p].q += have[ind].q;
		if (p) {
			all.insert({have[p], p});
		}
		unite(ind, p);
	}
	cout << ans << "\n";
}


int main() {
	//freopen(TASK_NAME ".in", "r", stdin);
	//freopen(TASK_NAME ".out", "w", stdout);
	cerr << fixed << setprecision(15);
	cout << fixed << setprecision(15);
	ios::sync_with_stdio(false);

	int tests = 1;
	// cin >> tests;
	for (int it = 1; it <= tests; ++it) {
		solve();
	}
	
	#ifdef LOCAL
		cerr << "time: " << clock() << " ms\n";
	#endif
	return 0;
}

Measured memory_bytes: 15872
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		int A = I[0], B = I[1], C = I[2];
		var g = GCD(A, B);
		WriteLine(C % g == 0 ? "YES" : "NO");
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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


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

	sort(a,a+n,greater<int>());
	int m1=a[0],m2=a[1];
	for (int i = 0; i < n; i++){
		if(m1==b[i])
			cout<<m2<<endl;
		else
			cout<<m1<<endl;
	}

	return 0;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<utility>
#include<map>
using namespace std;
int n,d;
int main()
{
	cin>>n>>d;
	int ans = 0;
	for (int i = 0 ; i < n; i++)
	{
		int x ,y;
		scanf("%d %d",&x,&y);

		double curr = sqrt(1LL*x * x + 1LL*y * y);
		//cout<<"sigao sam do "<<i<<' '<<curr<<endl;
		if (curr <= 1.0 * d ) ans++;
	}

	cout<<ans<<endl;



return 0;
}


Measured memory_bytes: 3740
# -*- coding: utf-8 -*-

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

n = int(input())
x = list(map(int,input().split()))


if n==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,x[i])
        print(element)




Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}

ll qp(ll a,ll x,ll mod)
{
    ll ans=1;
    while(x)
    {
        if(x%2==1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        x/=2;
    }
    return ans;
}
int cmp(ll a,ll b)
{
    return a<b;
}

int main()
{
    int n;
    ll a[200005],m=0,ans=0;
    read(n);
    for(int i=0;i<n;i++)
        read(a[i]);
    m=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]<m)
        {
            ans+=m-a[i];
        }
		m=max(m,a[i]);
    }
    cout<<ans<<endl;
    return 0;

}



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

int gcd(int m,int n)
{
  if(n==0){
    return m;
  }
  return gcd(n,m%n);
}

int main()
{
  int W,H,C;
  cin>>W>>H>>C;

  int g=gcd(W,H);
  cout<<W/g*H/g*C<<endl;

  return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int k;
  cin >> k;

  int now = 0;
  for(int i=1, cnt=0; cnt<k; i*=10) {
    now += i;
    while(cnt<k) {
      ++cnt;
      cout << now << endl;
      now += i;
      // (double)now/s(now)
      int a=0, x=now;
      while(x) {
        a += x%10;
        x /= 10;
      }
      double tmp = (double)now/a;
      // cout << tmp << " " << i << endl;
      if(tmp > i) {
        now -= i;
        break;
      }
    }
  }

  // FOR(i, 40000, 70000) {
  //   int a=0, x=i;
  //   while(x) {
  //     a += x%10;
  //     x /= 10;
  //   }
  //   double mi = INF;
  //   FOR(j, i+1, 70001) {
  //     int a=0, x=j;
  //     while(x) {
  //       a += x%10;
  //       x /= 10;
  //     }
  //     chmin(mi, (double)j/a);
  //   }
  //   if((double)i/a <= mi) {
  //     cout << i << " " << (double)i/a << endl;
  //   }
  //   // cout << i << " " << (double)i/a << endl;
  // }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int H, W;
deque<deque<char>> A;
void input() {
  cin >> H >> W;
  A.resize(H, deque<char>(W));
  rep(i, 0, H - 1) {
    rep(j, 0, W - 1) { cin >> A[i][j]; }
  }
}
void solve() {
  rep(i, 0, H - 1) {
    A[i].push_front('#');
    A[i].push_back('#');
  }
  rep(i, 1, W+2) { cout << "#"; }
  cout << endl;

  rep(i, 0, H - 1) {
    rep(j, 0, W + 1) { cout << A[i][j]; }
    cout << endl;
  }

rep(i, 1, W+2) { cout << "#"; }
  cout << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
long double MAX = 10000009.0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin>>n;
    ll a[n-1];
    ll b[n]={0};
    map<ll,ll> m;
    for(ll i=0;i<n-1;i++)
    {
        cin>>a[i];
        a[i]--;
        b[a[i]]++;
    }
    for(ll i=0;i<n;i++)
        cout<<b[i]<<endl;
    return 0;
}


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

using namespace std;

int n,i,j,a[200005];

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	vector <int> ans;
	
	if(n % 2 == 0){
		for(i = n - 1; i >= 0; i -= 2)
		ans.push_back(a[i]);
		for(i = 0; i < n; i += 2)
		ans.push_back(a[i]);
	}
	else{
		for(i = n - 1; i >= 0; i -= 2)
		ans.push_back(a[i]);
		for(i = 1; i < n; i += 2)
		ans.push_back(a[i]);	
	}
	
	for(i = 0; i < ans.size(); i++){
		if(i == 0)
		printf("%d", ans[i]);
		else
		printf(" %d", ans[i]);
	}
	printf("\n");
}


Measured memory_bytes: 3828
//ΔARC 095F
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111111;
int n,d[N],l,f[N],g[N],ans1[N],ans2[N];
vector<int> v[N];
void dfs(int u,int fa){
	d[u]=d[fa]+1;
	int i=v[u].size();
	while(i--){
		if(v[u][i]!=fa)
			dfs(v[u][i],u);
	}
}
int main()
{
	int i,x,y,s;
	scanf("%d",&n);
	for(i=1;i<n;i=i+1){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,0);
	y=1;
	for(i=1;i<=n;i=i+1)
		if(d[i]>y)
			x=i,y=d[i];
	dfs(x,0);
	y=1;
	for(i=1;i<=n;i=i+1)
		if(d[i]>y)
			x=i,y=d[i];
	while(1){
		f[++l]=x,g[l]=v[x].size()-1;
		if(d[x]==1)
			break;
		i=v[x].size();
		while(i--){
			if(d[v[x][i]]<d[x]){
				x=v[x][i];
				break;
			}
		}
	}
	s=n;
	for(i=1;i<=l;i=i+1){
		x=f[i];
		y=v[x].size();
		while(y--){
			if(d[v[x][y]])
				d[v[x][y]]=0,s--;
		}
	}
	if(s){
		cout<<-1;
		return 0;
	}
	g[1]=1,g[l]=1;
	x=0;
	ans1[1]=++x;
	for(i=2;i<=l;i=i+1){
		ans1[x+g[i]]=x+1;
		for(y=x+1;y<x+g[i];y=y+1)
			ans1[y]=y+1;
		x+=g[i];
	}
	x=0;
	ans2[1]=++x;
	for(i=l-1;i;i=i-1){
		ans2[x+g[i]]=x+1;
		for(y=x+1;y<x+g[i];y=y+1)
			ans2[y]=y+1;
		x+=g[i];
	}
	x=0;
	for(i=1;i<=n;i=i+1){
		if(!x){
			if(ans1[i]<ans2[i])
				x=1;
			if(ans1[i]>ans2[i])
				x=2;
		}
		if(x<2)
			printf("%d ",ans1[i]);
		else
			printf("%d ",ans2[i]);
	}
	return 0;
}

Measured memory_bytes: 13312
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
  long long N,counter=0;
  cin>>N;
  long long a[100000];
  for (long long i=1; i<=N; i++){
  cin>>a[i];}
  for (long long i=1; i<=N; i++){
  if(a[i]==i){
  counter++;
  a[i+1]=i;}}
  cout<<counter<<endl;}
  


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,p;
    cin>>a>>p;
    p += a * 3;
    PUTS(p/2);
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
CC = Counter(S)
#print(CC)
if len(CC) < 3:
  print(0)
  exit(0)

ans = CC['R'] * CC['G'] * CC['B']
for i in range(N):
  for x in range(1,N):
    if i+2*x >= N:
      break
    if S[i] != S[i+x] and S[i+x] != S[i+2*x] and S[i+2*x] != S[i]:
      ans -= 1
      
print(ans)

Measured memory_bytes: 9448
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(const void *a, const void *b){return *(int*)b-*(int*)a;}

int main(void){
	int n, i;
	int a[100000];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", a+i);
	}
	qsort(a, n, sizeof(int), comp);
	int a1=0;
	for(i=1; i<n; i++){
		if(a[i]==a[i-1]){
			a1=a[i];
			break;
		}
	}
	int a2=0;
	for(i+=2; i<n; i++){
		if(a[i]==a[i-1]){
			a2=a[i];
			break;
		}
	}
	printf("%ld\n", ((long)a1)*a2);
}


Measured memory_bytes: 892
# k
# t(k) = k * (k + 1) / 2
# t(k + 1) = (k + 1) * (k + 2) / 2

# a = t(k) - u
# b = t(k + 1) - u

# a + b = t(k) + t(k + 1) - 2u
# -a - b + t(k) + t(k + 1) = 2u

a, b = map(int, input().split())

for k in range(1, 999):
    t1 = k * (k + 1) // 2
    t2 = (k + 1) * (k + 2) // 2
    u = t1 + t2 - a - b
    if (t1 + t2 - a - b) % 2 == 0 and u > 0:
        u = u // 2
        if u <= t1 and u <= t2 and t1 - u == a and t2 - u == b:
            print(u)


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n;
int a[30];
int Q;
bool ans[3000];

void solve(int x,int t){
    t++;
    if(t==n){
        ans[x]=true;
        ans[x+a[n-1]]=true;
    }
    else{
        solve(x,t);
        solve(x+a[t-1],t);
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    solve(0,0);
    cin>>Q;
    for(int i=0;i<Q;i++){
        int m;
        cin>>m;
        if(ans[m])cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
def main():
  N = int(input())
  A = list(map(int, input().split()))

  counts = [0] * N

  for v in A:
    counts[v-1] += 1

  total = 0

  for v in counts:
    if(v > 1):
      total += v * (v - 1) // 2

  for v in A:
    n = counts[v-1]

    diff = n * (n - 1) // 2 - (n-1) * (n-2) // 2

    print(total - diff)


if __name__ == "__main__":
  main()

Measured memory_bytes: 100704
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    ll ans = 0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                ans += gcd(gcd(i,j), k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int N;
    cin >> N;
    long double x[15];
    string u[15];
    REP(i,N){
        cin >> x[i] >> u[i];
    }
    long double ans = 0.0;
    REP(i,N){
        if(u[i]=="JPY") ans += x[i];
        else ans += x[i]*380000.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//bool solve(string s, int k){
//    rep(i,sz(s)-k,k-2)
//        if(s[i] != s[i+1])
//            return false;
//    return true;
//}
//const int K = 40000, ZERO = 20000;
//bool solve(vi arr, int x){
//    bitset<K> bs;
//    bs[ZERO+x] = true;
//    for(int x : arr)
//        bs = (bs<<x)|(bs>>x);
//    return bs[ZERO];
//}
//string _(){
//    string s;
//    cin >> s;
//    int x,y;
//    cin >> x >> y;
//    reverse(all(s));
//    while(!s.empty() && s.back() == 'F'){
//        x--;
//        s.pop_back();
//    }
//    reverse(all(s));
//    s.pb('T');
//    vi part[2];
//    int cur = 0;
//    int type = 0;
//    for(char c : s){
//        if(c == 'T'){
//            part[type].pb(cur);
//            cur = 0;
//            type ^= 1;
//        }
//        else
//            cur++;
//    }
//    if(solve(part[0],x) && solve(part[1],y))
//        return "Yes";
//    return "No";
//
//}
//
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
bool solve(string s, int k){
    rep(i,sz(s)-k,k-2)
        if(s[i] != s[i+1])
            return false;
    return true;
}
const int K = 40000, ZERO = 20000;
bool solve(vi arr, int x){
    bitset<K> bs;
    bs[ZERO+x] = true;
    for(int x : arr)
        bs = (bs<<x)|(bs>>x);
    return bs[ZERO];
}
string _(){
    string s;
    cin >> s;
    int x,y;
    cin >> x >> y;
    reverse(all(s));
    while(!s.empty() && s.back() == 'F'){
        x--;
        s.pop_back();
    }
    reverse(all(s));
    s.pb('T');
    vi part[2];
    int cur = 0;
    int type = 0;
    for(char c : s){
        if(c == 'T'){
            part[type].pb(cur);
            cur = 0;
            type ^= 1;
        }
        else
            cur++;
    }
    if(solve(part[0],x) && solve(part[1],y))
        return "Yes";
    return "No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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


Measured memory_bytes: 256
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int n, m;
	cin >> n >> m;
	int a[100];
	for (int i = 0; i < m; i++)
	{
		a[i] = 0;
	}
	for(int i=0;i<n;i++)
	{
		int k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int x;
			cin >> x;
			a[x - 1]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <=m; i++)
	{
		if (a[i - 1] == n)
		{
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    string T;
    cin>>T;
    int count=0;
    rep(i,sz(T)){
        if(T.at(i)=='?'){cout<<'D';}
        else{cout<<T.at(i);}
    }
    cout<<endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    
    for(int i=0;i<n;i++){
        int cost;
        cin >> cost;
        v[i] -= cost;
    }
    sort(v.begin(),v.end());

    int ans = 0;
    for(int i=0;i<n;i++){
        ans += max(v[i],0);
    }
    cout << ans << endl;

}

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

int main()
{
ll a ;
cin >> a ;

cout << a*a*a+a*a+a << endl;
return 0;
}

Measured memory_bytes: 3628