akhauriyash/Code-Regression huggingface dataset:
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

a = list(str(input()))
b = list(str(input()))
c = list(str(input()))

a.append(5)
b.append(5)
c.append(5)

#print(a)
#print(b)
#print(c)
#print('------')

#条件に合う要素の抽出
a_change = [ i for i in a if i!= 'a']
b_change = [ i for i in b if i!= 'b']
c_change = [ i for i in c if i!= 'c']

#print(a_change)
#print(b_change)
#print(c_change)

##条件に合う要素の置き換え
a_change = [ 0 if i=='a' else i for i in a_change]
a_change = [ 1 if i=='b' else i for i in a_change]
a_change = [ 2 if i=='c' else i for i in a_change]

b_change = [ 0 if i=='a' else i for i in b_change]
b_change = [ 1 if i=='b' else i for i in b_change]
b_change = [ 2 if i=='c' else i for i in b_change]

c_change = [ 0 if i=='a' else i for i in c_change]
c_change = [ 1 if i=='b' else i for i in c_change]
c_change = [ 2 if i=='c' else i for i in c_change]

#print(a_change)
#print(b_change)
#print(c_change)

#配列の宣言 二次元も可
lists=[]

lists.append(a_change)
lists.append(b_change)
lists.append(c_change)

#print(lists)
#print('-----')

go = 0
for i in range(400):
	#print('---'+ str(i) +'---')
	#print(go)
	next = lists[go][0]
	if next == 5:
		if go == 0:
			print('A')
			break
		elif go ==1:
			print('B')
			break
		else:
			print('C')		
			break
	del lists[go][0]
	go = next
	



Measured memory_bytes: 3064
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int R;
int S;
int P;
char T[100000+2];
int main(){
  int st;
  int res = 0;
  int b;
  rd(N);
  rd(K);
  rd(R);
  rd(S);
  rd(P);
  rd(T);
  for(st=(0);st<(K);st++){
    int i;
    b = 0;
    for(i=(st);i<(N);i+=(K)){
      if(T[i] == b){
        b = 0;
        continue;
      }
      b = T[i];
      if(T[i]=='r'){
        res += P;
      }
      if(T[i]=='p'){
        res += S;
      }
      if(T[i]=='s'){
        res += R;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int N, K, R, S, P;
// char T[1d5+2];
// 
// {
//   int res = 0, b;
//   rd(N,K,R,S,P,T);
//   rep(st,K){
//     b = 0;
//     rep(i,st,N,K){
//       if(T[i] == b) b = 0, continue;
//       b = T[i];
//       if(T[i]=='r') res += P;
//       if(T[i]=='p') res += S;
//       if(T[i]=='s') res += R;
//     }
//   }
//   wt(res);
// }


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

const long long MAX = 100005;

int main() {
  long long n;
  long long tmp;
  long long ans1 {0};
  long long ans2 {0};
  cin >> n;
  long long A[MAX], B[MAX];
  long long cum_sum = 0;

  for (long long i = 0; i < n; i++) {
    cin >> tmp;
    cum_sum += tmp;
    A[i] = cum_sum;
    B[i] = cum_sum;
  }

  // When making A[0] > 0
  tmp = 0;
  if (A[0] <= 0) {
    tmp = -A[0] + 1;
    ans1 += tmp;
    for (long long i = 0; i < n; i++) {
      A[i] += tmp;
    }
  }
  for (long long i = 0; i < n-1; i++) {
    if (A[i] > 0) {
      if (A[i+1] >= 0) {
        tmp = (A[i+1] + 1);
        ans1 += tmp;
        for (long long j = i+1; j < n; j++) A[j] -= tmp;
      }
    } else if (A[i] < 0) {
      if (A[i+1] <= 0) {
        tmp = (-A[i+1] + 1);
        ans1 += tmp;
        for (long long j = i+1; j < n; j++) A[j] += tmp;
      }
    } 
  }

  // when making B[0] < 0
  tmp = 0;
  if (B[0] >= 0) {
    tmp = B[0] + 1;
    ans2 += tmp;
    for (long long i = 0; i < n; i++) {
      B[i] -= tmp;
    }
  }
  for (long long i = 0; i < n-1; i++) {
    if (B[i] > 0) {
      if (B[i+1] >= 0) {
        tmp = (B[i+1] + 1);
        ans2 += tmp;
        for (long long j = i+1; j < n; j++) B[j] -= tmp;
      }
    } else if (B[i] < 0) {
      if (B[i+1] <= 0) {
        tmp = (-B[i+1] + 1);
        ans2 += tmp;
        for (long long j = i+1; j < n; j++) B[j] += tmp;
      }
    } 
  }
  long long ans = (ans1 > ans2 ? ans2 : ans1);
  cout << ans << endl;
}


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

int main() {
  int n; cin >> n;
  vec a(n), b(n);
  rep(i,n) {
    cin >> a[i];
    b[i] = a[i] + i;
  }

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

  ll c = 0;
  rep(i,n) {
    c += upper_bound(b.begin(), b.end(), i-a[i]) - lower_bound(b.begin(), b.end(), i-a[i]);
  }

  cout << c << endl;
}


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

using namespace std;

int main()
{
    long long N;
    cin >> N;
    long long casas[N], i;
    for(i=0; i<N; i++)
    {
        cin >> casas[i];
    }
    sort(casas, casas+N);
    cout << casas[N-1]-casas[0] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

public class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] num = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        Array.Sort(num);
        int ans = 0;
        int flag = 0;
        while (true)
        {
            flag = 0;
            for (int i = 0; i < n; i++)
            {
                if (num[i] % 2 == 1)
                {
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    if (num[i] % 2 == 1)
                    {
                        Console.WriteLine(ans + 1);
                        return;
                    }
                    else
                    {
                        num[i] = num[i] / 2;
                        flag = 1;
                    }
                }
            }
            if (flag == 1) ans++;
        }
    }

}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define NMAX 100005

typedef long long int ll;

typedef pair<int, int> iPair;
vector<iPair> adjs[NMAX];
vector<iPair> adjt[NMAX];
int N, M;

void pcc(int src, ll dist[], vector<iPair> adj[]){
	dist[src]=0;
	priority_queue <iPair, vector<iPair>, greater<iPair> > pq;
	pq.push(make_pair(0,src));
	while(!pq.empty()){
		int u = pq.top().second;
		pq.pop();
		for(auto x : adj[u]){
			int v = x.second;
			int w = x.first;
			if(dist[v] > dist[u] + w){
				dist[v] =  dist[u]+w;
				pq.push(make_pair(dist[v],v));
			}
		}
	}
}

int main(){
	
	ll yen = pow(10,15);
	
	int s, t; cin>>N>>M>>s>>t;
	for(int i=0;i<M;i++){
		int u, v, a, b;
		cin>>u>>v>>a>>b;
		adjs[u].push_back(make_pair(a,v));
		adjs[v].push_back(make_pair(a,u));
		adjt[u].push_back(make_pair(b,v));
		adjt[v].push_back(make_pair(b,u));
	}
	
	ll dist_s[NMAX];
	ll dist_t[NMAX];
	for(int i=0;i<NMAX;i++){
		dist_s[i] = LONG_LONG_MAX;
		dist_t[i] = LONG_LONG_MAX;
	}
	
	pcc(s, dist_s, adjs);
	pcc(t, dist_t, adjt);
	
	ll ans[N+1];
	ans[N] = dist_s[N] + dist_t[N];
	for(int i=N-1;i>0;i--){
		ans[i] = min(ans[i+1], dist_s[i]+dist_t[i]);
	}
	
	for(int i=1;i<=N;i++){
		printf("%lld\n",yen-ans[i]);
	}
}


Measured memory_bytes: 16316
import sys
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
totl=0
idx=0
dif1=0
for i in range(n):
  totl+=a[i]
  idx=i
  if (s/2)==totl:
    print(0)
    sys.exit()
  elif (s/2)<totl:
    dif1=totl-(s/2)
    break
dif2=a[idx]-dif1
if dif1-(dif1//1)==0:
  print(int(2*min(dif1,dif2)))
else:
  print(int(2*min(dif1,dif2)))


Measured memory_bytes: 26220
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int[]A=nai(n);
        long ans=0;
        for(int i=1;i<n;i++)
        {
            if(A[i]<A[i-1])
            {
                ans+=A[i-1]-A[i];
                A[i]=A[i-1];
            }
        }
        pn(ans);
    }
    static long mod=(long)1e9+7l;
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-- > 0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 55164
MOD = 10**9+7
n, a, b = map(int, input().split())

def make_inv(n, mod=10**9+7):
    inv = [0, 1] + [0] * (n-2)
    for i in range(2, n):
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
    return inv

inv = make_inv(10**6)

ac, bc = 1, 1
for i in range(n, n-a, -1):
    ac *= i
    ac %= MOD
for i in range(1, a+1):
    ac *= inv[i]
    ac %= MOD

for i in range(n, n-b, -1):
    bc *= i
    bc %= MOD
for i in range(1, b+1):
    bc *= inv[i]
    bc %= MOD

print((pow(2, n, MOD) - ac - bc - 1) % MOD)


Measured memory_bytes: 56176
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
#define lowbit(x) ((x)&-(x))
#define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i)
#define per(i,r,l) for(res i=r,_l=l;i>=_l;--i)
#define mkp make_pair
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem0n(a,n) memset(a,0,n*sizeof(a[0]))
#define iter(x,v) for(res v,_p=head[x];v=ver[_p],_p;_p=nxt[_p])
#ifdef cccgift //by lqh
#define SHOW(x) cerr<<#x"="<<(x)<<endl
#else
#define SHOW(x) 0
#endif
//#define getchar()(ip1==ip2&&(ip2=(ip1=ibuf)+fread(ibuf,1,1<<21,stdin),ip1==ip2)?EOF:*ip1++)
//char ibuf[1<<21],*ip1=ibuf,*ip2=ibuf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,sum0[1000001],sum1[1000001],Max[1000010];
char s[1000001];
inline int doit(int m) {
	int minn=0,now=0;
	rep(i,1,n) if(s[i]!='?') chkmin(minn,sum0[i]-sum1[i]+now);
	else {
		if(Max[i]+now+2<=m) now+=2;
		chkmin(minn,sum0[i]-sum1[i]+now);
	}
	return m-minn;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>(s+1),n=strlen(s+1);
	rep(i,1,n) {
		sum0[i]=sum0[i-1],sum1[i]=sum1[i-1];
		if(s[i]=='0') ++sum0[i];
		else ++sum1[i];
	}
	Max[n]=sum0[n]-sum1[n];
	per(i,n-1,1) Max[i]=max(Max[i+1],sum0[i]-sum1[i]);
	int maxx=0;
	rep(i,1,n) chkmax(maxx,sum0[i]-sum1[i]);
//	rep(i,1,n) print(sum0[i],' ');puts("");
//	rep(i,1,n) print(sum1[i],' ');puts("");
	print(min(doit(maxx),doit(maxx+1)),'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 16344
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

lint f(string &s){
    lint ret = 0;
    for(auto c: s){
        ret *= 16;
        ret += (isdigit(c) ? c-'0' : c-'a'+10);
    }
    return ret;
}

string g(lint a){
    string ret;
    while(a){
        ret += (a%16 <= 9 ? '0'+a%16 : 'a'+a%16-10);
        a /= 16;
    }
    reverse(ret.begin(), ret.end());
    return ret.empty() ? "0" : ret;
}

lint a[9];

void Xor(lint x){
    rep(i, 8) a[i] ^= x;
}

lint Sum(){
    lint ret = 0;
    rep(i, 8) ret += a[i];
    return ret;
}

int main(){
    int t;
    scanf("%d", &t);
    rep(_, t){
        rep(i, 9){
            string s; cin >> s;
            a[i] = f(s);
        }

        lint ans = 0;
        rep(i, 32){
            lint d = ((Sum()>>i & 1) != (a[8]>>i & 1));
            ans += d<<i;
            Xor(d<<i);
        }
        cout << g(ans) << "\n";
    }
}


Measured memory_bytes: 3144
import java.io.*;
import java.io.*;
//import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    public static void main(String args[])throws IOException{
//        Scanner scan = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        char [] c = input.toCharArray();
//        String c[] = scan.next();
        for(int i = 0; i < c.length; i++){
            if(Character.isUpperCase(c[i])){
                c[i] = Character.toLowerCase(c[i]);
            }else if(Character.isLowerCase(c[i])){
                c[i] = Character.toUpperCase(c[i]);
            }else{
                c[i] = c[i];
            }
        }
        
        System.out.println(c);
    }
}

Measured memory_bytes: 24316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 10;
char str[maxn][maxn];

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    for(int i = 0; i < 3; ++i) {
        scanf("%s", str[i]);
        printf("%c", str[i][i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] numbers = new int[n];
        for(int i = 0;i<n;i++){
            numbers[i] = sc.nextInt();
        }

        int answer = 0;

        for(int i = 0;i<n;i++){
            while(numbers[i] %2 == 0 && numbers[i] != 0){
                numbers[i] /= 2;
                answer++;
            }
        }
        System.out.println(answer);
    }
}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (100005)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


signed main(){
    int N;
    cin >> N;
    vector<pair<int,int>> BA(N);
    for(int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        BA[i] = make_pair(b,a);
    }

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

    int crt=0;
    for(int i=0; i<N; i++){
        crt += BA[i].second;
        if(crt > BA[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<math.h>
#define N 100005
#define K 200005
#define MOD (int)1e9+7
#define ll long long int
using namespace std;


int main() {
    int h,w;
    cin>>h>>w;
    vector<string> path(h);
    for(int i=0;i<h;i++)
    {
        cin>>path[i];
       // cout<<path[i];
    }
    vector<vector<int>> dp(h,vector<int>(w));
    dp[0][0]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(i+1<h&&path[i+1][j]=='.')
            {
                dp[i+1][j]+=dp[i][j];
                 if(dp[i+1][j]>MOD)
            {
                dp[i+1][j]-=MOD;
            }
            }
            if(j+1<w&&path[i][j+1]=='.')
            {
                dp[i][j+1]+=dp[i][j];
                  if(dp[i][j+1]>MOD)
            {
                dp[i][j+1]-=MOD;
            }
            }
           
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 5248
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}

int main()
{
    int n,k;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>k;
        if(k%2&&i%2)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string A,B,C;
  cin >> A >> B >> C;
  int a = A.size();
  int b = B.size();
  if(A[a-1]==B[0]&&B[b-1]==C[0])
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll getMaxscoreForPlayerOne(vector<ll> inp,vector<ll> runningSum,int n) {
	ll res=0;
	vector<vector<ll>> dp(n,vector<ll>(n,0));
	for(int i=0;i<n;i++)dp[i][i]=inp[i];
	for(int size=2;size<=n;size++) {
		for(int i=0;i<n-size+1;i++) {
			ll subSequenceSum=runningSum[size+i]-runningSum[i];
			if(subSequenceSum-dp[i][size+i-2]>subSequenceSum-dp[i+1][size+i-1]) {
				dp[i][size+i-1]=subSequenceSum-dp[i][size+i-2];
			} else {
				dp[i][size+i-1]=subSequenceSum-dp[i+1][size+i-1];
			}
		}
	}
	/*
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	res=dp[0][n-1];
	return res;
}

ll getScoreDifference(vector<ll> inp,int n) {
	ll res=0;
	vector<ll> runningSum(n+1,0);
	for(int i=1;i<n+1;i++) {
		runningSum[i]=runningSum[i-1]+inp[i-1];
	}
	res=getMaxscoreForPlayerOne(inp,runningSum,n);
	res=res-(runningSum[n]-res);
	return res;
}

int main() {
	int n=0;
	cin>>n;
	vector<ll> inp(n,0);
	for(int i=0;i<n;i++) cin>>inp[i];
	cout<<getScoreDifference(inp,n)<<endl;
	return 0;
}

Measured memory_bytes: 73748
def main():
    A, B, C, X, Y = list(map(int, input().split()))
    total = 0

    if A + B <= 2*C:
        total += X*A + Y*B
    
    else:
        if A <= 2*C and B <= 2*C:
            if X == Y:
                total += (X + Y)*C
            elif X < Y:
                total += 2*X*C
                total += (Y-X)*B
            elif X > Y:
                total += 2*Y*C
                total += (X-Y)*A
        elif A <= 2*C and B > 2*C:
            if X == Y:
                total += (X+Y)*C
            elif X < Y:
                total += 2*Y*C
            elif X > Y:
                total += 2*Y*C
                total += (X-Y)*A
        elif B <= 2*C and A > 2*C:
            if X == Y:
                total += (X+Y)*C
            elif X > Y:
                total += 2*X*C
            elif X < Y:
                total += 2*X*C
                total += (Y-X)*B
        elif A > 2*C and B > 2*C:
            total += max(X, Y)*2*C

    print(total)

main()



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
bool cmp(const vll&a, const vll& b){
    return a[0] + a[1] < b[0] + b[1];
}
lli dp[1010][20005];
lli calc(lli index, lli wt, vector<vll>& A){
    lli n = A.size();
    if(index >= n)
        return 0;
    else if(dp[index][wt] != -1)
        return dp[index][wt];
    lli ans = 0;
    ans = calc(index+1, wt, A);
    if(A[index][1] >= wt)
        ans = max(ans, calc(index+1, A[index][0] + wt, A) + A[index][2]);
    ans = max(ans, 0ll);
    dp[index][wt] = ans;
    return ans;
}
lli solve(){
    lli n;
    cin>>n;
    vector<vll> A(n, vll(3, 0));
    loop(i, 0, n)
        cin>>A[i][0]>>A[i][1]>>A[i][2];
    sort(all(A), cmp);
    memset(dp, -1, sizeof(dp));
    cout<<calc(0, 0, A)<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 161556
#define PI 3.14159265359
#define INF 2000000000
#define MAX 500000
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;

ll F[45]={0};

ll fibo(int n){
    if(F[n]) return F[n];
    if(n==0||n==1) return F[n]=1;
    return F[n]=fibo(n-1)+fibo(n-2);
}

int main(){
    int n;
    cin>>n;
    cout<<fibo(n)<<endl;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n;
    cin >> n;

    ll x = 0;
    ll sum = 0;
    for (ll i = 1; i < 10000; i++){
        sum += i;
        if (sum >= n){
            x = i;
            break;
        }
    }

    //cout << x << endl;

    for (ll i = 1; i <= x; i++){
        if (i == (sum-n)){
            continue;
        }
        cout << i << "\n";
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int x,n,a[105],t[105];
int main()
{
    cin>>x>>n;
    for(int i=1;i<=n;++i)cin>>a[i],t[a[i]]=1;
    if(t[x]==0){cout<<x;return 0;}
    int dis=1;
    while(1)
    {
        if(x-dis==0){cout<<0;break;}
        if(x+dis==101)
        {
            if(t[x-dis]==0)cout<<x-dis;
            else cout<<101;
            break;
        }
        if(t[x-dis]==0){cout<<x-dis;break;}
        if(t[x+dis]==0){cout<<x+dis;break;}
        dis++;
    }
}

Measured memory_bytes: 3648
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {

        var line1 = System.Console.ReadLine().Split(' ');
        var line2 = System.Console.ReadLine().Split(' ');
        var line3 = System.Console.ReadLine().Split(' ');

        int[,] card = new int[3, 3];
        for(int i = 0; i < 3; i++)
        {
            card[0, i] = int.Parse(line1[i]);
        }
        for (int i = 0; i < 3; i++)
        {
            card[1, i] = int.Parse(line2[i]);
        }
        for (int i = 0; i < 3; i++)
        {
            card[2, i] = int.Parse(line3[i]);
        }

        var n = int.Parse(System.Console.ReadLine());

        List<int> nums = new List<int>();
        for(int i = 0; i< n; i++)
        {
            nums.Add(int.Parse(System.Console.ReadLine()));
        }

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (nums.Contains(card[i, j])){
                    card[i,j] = -1;
                }
            }
        }

        for(int i = 0; i < 3; i++)
        {
            if(card[i,0] + card[i, 1] + card[i, 2] == -3 ||
                card[0, i] + card[1, i] + card[2, i] == -3)
            {
                System.Console.WriteLine("Yes");
                return;
            }
        }

        if(card[0, 0] + card[1, 1] + card[2, 2] == -3 ||
           card[2, 0] + card[1, 1] + card[0, 2] == -3)
        {
            System.Console.WriteLine("Yes");
            return;
        }
        System.Console.WriteLine("No");
        return;

    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<math.h>
int main() {
	int a, b,c;
	scanf("%d %d %d", &a, &b,&c);
	if (a < b&&b<c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;

}

Measured memory_bytes: 2592
#include <iostream>
#include <algorithm>

using namespace std;

int n,x;
int v[105];

int main(){
	cin >> n >> x;
	
	for(int i = 1;i <= n;i++){
		cin >> v[i];
	}
	
	sort(v + 1,v + 1 + n);
	
	for(int i = 1;i <= n;i++){
		if(x < v[i]){
			cout << i - 1;
			return 0;
		}
		x -= v[i];
	}
	
	cout << n - (x != 0);
	
	return 0;
}

Measured memory_bytes: 256
N , Y = (int(x) for x in input().split())
senen = Y//10000
result = False
gosenen = Y // 5000

for x in range(N, -1, -1):
    #Y = Y - 10000 * x
    #print("x:",x)
    for y in range(N,-1,-1):
        #Y = Y - y * 5000
        z = N - x - y
        if x * 10000 + y * 5000 + z * 1000 == Y and x + y + z <= N and z >= 0:
            result = True
            print(x,y,z)
            break
    else:
        continue
    break





if result == False:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;

struct Edge{int to,capa,flow,next;} e[4000000];
int h[20010],sum=-1,n,m,S,T;
int mp[110][110],tot=0;
bool vis[20010];
int d[20010],cur[20010];

void AddEdge(int u,int v,int w)
{
	e[++sum].to=v;
	e[sum].capa=w;
	e[sum].flow=0;
	e[sum].next=h[u];
	h[u]=sum;
}

void add_edge(int u,int v,int w)
{
	AddEdge(u,v,w);
	AddEdge(v,u,0);
}

bool BFS()
{
	memset(vis,0,sizeof(vis));
	queue<int> q;
	vis[S]=1;d[S]=0;
	q.push(S);
	while(!q.empty())
	{
		int u=q.front();
		for(int tmp=h[u];~tmp;tmp=e[tmp].next)
			if(!vis[e[tmp].to]&&e[tmp].capa>e[tmp].flow)
			{
				d[e[tmp].to]=d[u]+1;
				vis[e[tmp].to]=1;
				q.push(e[tmp].to);
			}
		q.pop();
	}
	return vis[T+tot];
}

int DFS(int u,int a)
{
	if(u==T+tot||a==0) return a;
	int flow=0,f;
	for(int& tmp=cur[u];~tmp;tmp=e[tmp].next)
		if(d[e[tmp].to]==d[u]+1)
		{
			f=DFS(e[tmp].to,min(a,e[tmp].capa-e[tmp].flow));
			if(f>0)
			{
				flow+=f;a-=f;
				e[tmp].flow+=f;
				e[tmp^1].flow-=f;
				if(a==0) break;
			}
		}
	return flow;
}

int Dinic()
{
	int flow=0;
	while(BFS())
	{
		for(int i=1;i<=2*tot;i++) cur[i]=h[i];
		flow+=DFS(S,INF);
	}
	return flow==INF?-1:flow;
}

int main()
{
	static char s[110];
	scanf("%d%d",&n,&m);
	memset(h,-1,sizeof(h));
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
		{
			if(s[j]!='.') mp[i][j]=++tot;
			if(s[j]=='S') S=tot;
			if(s[j]=='T') T=tot;
		}
	}
	for(int i=1;i<=tot;i++)
		if(i!=S&&i!=T) add_edge(i,i+tot,1);
	add_edge(S,S+tot,INF);
	add_edge(T,T+tot,INF);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int u=mp[i][j];
			if(!u) continue;
			for(int k=1;k<=n;k++)
				if(k!=i&&mp[k][j])
					add_edge(u+tot,mp[k][j],INF);
			for(int k=1;k<=m;k++)
				if(k!=j&&mp[i][k])
					add_edge(u+tot,mp[i][k],INF);
		}
	printf("%d\n",Dinic());
	return 0;
}

Measured memory_bytes: 62720
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var k, a int
	mp := map[int]int{}
	for i := 0; i < n; i++ {
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			fmt.Scan(&a)
			mp[a]++
		}
	}

	var cnt int
	for _, v := range mp {
		if v == n {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


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

   if(s[2]==s[3] && s[4]==s[5])
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
n = gets.chomp.to_i
s = []
n.times do
  s.push gets.chomp.to_i
end
ss = s.sort
sum = ss.reduce(:+)
if sum % 10 != 0
  puts sum
  exit
end
ns = ss.select { |e| e % 10 != 0 }
if ns.empty?
  puts 0
else
  puts sum - ns[0]
end


Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

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

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;
int N; 

void dfs(string s, char mx){
	if(s.length() == N){
		cout << s << endl;
		return;
	}
	for(char c = 'a'; c <= mx+1; c++){
		string t = s + c;
		dfs(t, max(mx, c));
	}

}

int main(void){

	cin >> N;
	dfs("", 'a'-1);


	return 0;

}


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

using namespace std;

int main() {
		int A, B, K;
		cin >> A >> B >> K;
		for (int k = 0;;) {
			if (A % 2 == 1) {
				--A;
				A /= 2;
				B += A;
			}
			else {
				A /= 2;
				B += A;
			}
			++k;
			if (k >= K)break;

			if (B % 2 == 1) {
				--B;
				B /= 2;
				A += B;
			}
			else {
				B /= 2;
				A += B;
			}
			++k;
			if (k >= K)break;
		}
		cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min({a + b, b + c, c + a}) << endl;
}


Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    for(int i = 1;i<=b;i++){
        if(a*i%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll mpow(ll x, ll n){
    if(n==0) return 1;
    if(n&1) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2)%MOD;
}

ll N;
ll A[10000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    vector<ll> v(1000001);
    for(ll i=1000000;i>=2;i--){
        for(ll j=i;j<=1000000;j+=i){
            v[j]=i;
        }
    }

    vector<ll> cnt(1000001);
    rep(i,N){
        ll a=A[i];
        map<ll,ll> m;
        while(a>1){
            m[v[a]]++;
            a/=v[a];
        }
        repr(e,m){
            cnt[e.first]=max(cnt[e.first],e.second);
        }
    }

    ll sum=1;
    rep(i,1000001){
        if(cnt[i]>0){
            //cout<<i<<' '<<cnt[i]<<endl;
            sum*=mpow(i,cnt[i]);
            sum%=MOD;
        }
    }
    //cout<<sum<<endl;

    ll ans=0;
    rep(i,N){
        ans+=sum*mpow(A[i],MOD-2)%MOD;
        ans%=MOD;
    }
    if(ans<0) ans+=MOD;

    cout<<ans<<endl;
}

Measured memory_bytes: 18928
#include <bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<string>
using namespace std;

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  string s,t;
  char c;
  cin>>s>>t;
  r(i,s.size()+1){
    if(s==t){cout<<"Yes"<<endl;break;}
    c=s.at(s.size()-1);
    s=s.at(s.size()-1)+s;
    //s.insert(0,s.at(s.size()));
    s.erase(s.size()-1);
    //s.push_front(c);
    if(i==s.size())cout<<"No"<<endl;
  }




return 0;}


Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

require 'set'

n = gets.to_i
l = gets.split.map(&:to_i)

s = Set.new
count = 0
n.times do |i|
  n.times do |j|
    n.times do |k|
      next if l[i]==l[j] || l[j]==l[k] || l[k]==l[i]
      if s.add?([i,j,k].sort)
        array = [l[i], l[j], l[k]].sort
        if array[0] + array[1] > array[2] &&
           array[0] < array[1] + array[2] &&
           array[0] + array[2] > array[1]
          count += 1
        end
      end
    end
  end
end


puts count 


Measured memory_bytes: 31172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
 
#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))
 
#define pb push_back
#define mp make_pair
 
#define ALL(a) (a).begin(), (a).end()
 
#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
 
#define INF 1001001001
#define LLINF 1001001001001001001LL
 
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
 
#define PQ priority_queue
 
#define FST first
#define SEC second
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
//------------------HEAD---------------------
int n, m;
int s[9][9];

bool ok(int i){

    if(i>=n) return true;
    int c=0;
    int d=0;
    rep(j,n){
        if(s[i][j]==1) ++c;
        if(s[i][j]==-1) ++d;
    }
    return c<=n/2&&d<=n/2;
}

int solve(int x,int y){

    if(x==n) return 1;
    if(y==n) return ok(x)&&ok(x+1)?solve(x+1,x+2):0;
    
    if(x==y) return solve(x, y+1);
    if(s[x][y]) return solve(x, y+1);
    int res=0;
    s[x][y]=1;
    s[y][x]=-1;
    if(ok(x)&&ok(y)) res+=solve(x,y+1);
    s[x][y]=-1;
    s[y][x]=1;
    if(ok(x)&&ok(y)) res+=solve(x,y+1);
    s[x][y]=0;
    s[y][x]=0;
    return res;
}
    
int main(){
    while(1){
        cin>>n;
        if(n==0) break;
        cin>>m;

        rep(i,n)rep(j,n)s[i][j]=0;

        rep(i,m){

            int x,y;

            cin>>x;

            cin>>y;

            --x;--y;

            s[x][y]=1;

            s[y][x]=-1;

        }

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



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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]++;
    }
    int mx=0;
    int s=0;
    queue<int> q;
    for(int i=0;i<n;i++){
        s+=p[i];
        q.push(p[i]);
        if(q.size()>k){
            s-=q.front();
            q.pop();
        }
        if(q.size()==k){
            mx=max(mx,s);
        }
    }
    double ans=mx;
    ans/=2;
    printf("%.10f\n",ans);
    return 0;
}

// double calc_exp(double num){
//     double ret=0.0;
//     for(int i=1;i<=num;i++){
//         ret+=(double)i/num;
//     }
//     return ret;
// }

// int main(){
//     int n,k;
//     cin>>n>>k;
//     vector<double> v;
//     vector<double> sum;
//     double tmp;
//     for(int i=0;i<n;i++){
//         cin>>tmp;
//         v.push_back(calc_exp(tmp));
//     }

//     for(int i=0;i<=n;i++){
//         sum.push_back(0.0);
//     }

//     for(int i=1;i<=n;i++){
//         for(int j=0;j<i;j++){
//             sum[i]+=v[j];
//         }
//     }

//     double max=0.0;
//     for(int i=0;i<n-k+1;i++){
//         if(sum[i+k]-sum[i]>max)max=sum[i+k]-sum[i];
//     }

//     printf("%f\n",max);

//     return 0;
// }

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int i, n, a[n];
  double result = 0;
  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf("%d", &a[i]);
  }
  
  for( i = 0; i < n; i++ ){
    result += 1 / (double)a[i];
  }
  
  printf("%lf\n", 1/result);
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	ll a, b;
	cin >> a >> b;
	if(a == 1 || b == 1) cout << 1 << endl;
	else cout << (a * b + 1) / 2 << endl;	
	
}





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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b,c,n,ans=0;
  cin >> a >> b >> c >> n;
  rep(i,n+1){
    rep(j,n+1){
      if((n-i*a-j*b)%c==0 && (n-i*a-j*b)/c<=n && (n-i*a-j*b)/c>=0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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




}

Measured memory_bytes: 764
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

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

    ll a, b, n;
    cin >> a >> b >> n;
    ll  x = min(n,b-1);
    cout << floor(a * x / b) << el;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int main(){
  int n;
  cin>>n;
  rep(i,n)cout<<"ACL";
  

}


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

int main(){
    int D;
    long long G;
    cin >> D >> G ;

    long long *p = new long long[D];
    long long *c = new long long[D];
    
    for(int i=0;i<D;i++){
         cin >> p[i] >> c[i]; 
    }


    long long  ans = 1<<29;

    for(int bit = 0;bit<(1<<D);bit++){
        long long sum = 0;
        long long kaisu = 0;
        for(int i=0;i<D;i++){
 //           cout << (bit & (1<<i)) << endl;
            if(bit & (1<<i)){
             sum += 100*(i+1)*p[i]+c[i]; 
             kaisu+= p[i];  
            } 
        }
   //     cout << sum <<" " <<kaisu << endl;
        if(sum >=  G){
           // cout << ans <<" "<<kaisu << " " << sum <<endl; 
            ans = min(ans,kaisu); 
        } else {
            for(int j=D-1;j>=0;j--){
                if(bit&(1<<j)){
                    continue ;
                } else {
                    for(int k=0;k<p[j];k++){
                        if(sum >= G)break;
                        sum += 100*(j+1);
                        kaisu++;
                    //    cout << sum << endl;

                    }
                }
            }
           ans = min(ans,kaisu);
        }
}
    

    delete[] p;
    delete[] c;

    cout << ans <<endl;
}

Measured memory_bytes: 256