akhauriyash/Code-Regression huggingface dataset:
# Highway Toll

PRICE_LIST = (
    (0, 0, 0, 0, 0, 0, 0, 0),
    (0, 0, 300, 500, 600, 700, 1350, 1650),
    (0, 6, 0, 350, 450, 600, 1150, 1500),
    (0, 13, 7, 0, 250, 400, 1000, 1350),
    (0, 18, 12, 5, 0, 250, 850, 1300),
    (0, 23, 17, 10, 5, 0, 600, 1150),
    (0, 43, 37, 30, 25, 20, 0, 500),
    (0, 58, 52, 45, 40, 35, 15, 0),
)

while True:
    i = int(raw_input())
    if i == 0:
        break

    it = int(raw_input().strip().replace(' ', ''))
    o = int(raw_input())
    ot = int(raw_input().strip().replace(' ', ''))

    half = False
    if (1730 <= it <= 1930 or 1730 <= ot <= 1930) and PRICE_LIST[o][i] <= 40:
        half = True

    p = PRICE_LIST[i][o]
    if half:
        p /= 2
        if p % 50:
            p = (p / 50) * 50 + 50

    print p

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

const int N = 1e5 + 10;
int n, m, dis[N];
vector <int> adj[N], jav[N];
bool mark[N];

void dfs(int v) {
    mark[v] = 1;
    for (int i : adj[v]) {
        if (!mark[i]) {
            dis[i] = dis[v] + 1;
            dfs(i);
            if (jav[i].size() % 2 == 0) {
                //cout << v << " " << i << endl;
                jav[v].push_back(i);
            }
            else {
                //cout << i << " " << v << endl;
                jav[i].push_back(v);
            }
        }
        else if (dis[i] > dis[v]) {
            if (jav[i].size() % 2 == 0){
                //cout << v << " " << i << endl;
                jav[v].push_back(i);
            }
            else{
                //cout << i << " " << v << endl;
                jav[i].push_back(v);
            }
        }
    }
}
void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i ++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
}
void solve() {
    input();
    if (m % 2)
        cout << -1  << endl;
    else {
        dfs(1);
        for (int i = 0; i <= n; i ++) {
            sort(jav[i].begin(), jav[i].end());
            for (int j : jav[i])
                cout << i << " " << j << endl;
        }
    }
}

int main() {
    solve();
    return 0;
}


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long d = sc.nextLong();
    int answer = 0;
    for (int i = 0; i < n; i++) {
      long x = sc.nextInt();
      long y = sc.nextInt();
      if (x * x + y * y <= d * d ) {
        answer++;
      }
    }
    System.out.println(answer);
  }
}


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

struct Node
{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL; // ポインタにポインタを代入, tmpであるxの親
    Node *x = root; // tmp, rootからスタートして、zが入る位置を探す
    Node *z;


    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x!= NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    }
    else {
        if (z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) {
        return;
    }

    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) {
        return;
    }

    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main() {

    int N;
    cin >> N;

    string command;
    int node_n;

    for (int i = 0; i < N; i++)
    {
        cin >> command;

        if (command == "insert") {
            cin >> node_n;
            insert(node_n);
        }
        else {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}



Measured memory_bytes: 26656
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pp pair<ll,ll>
#define inf 1e9
using namespace std;
ll siev[1000005];
ll phi[1000005];
 
inline void Scan_f(ll &a){char c = 0;while(c<33)c = getc(stdin);a = 0;while(c>33){a = a*10 + c - '0';c = getc(stdin);}}
void sieve(){for(ll i=2;i<=1e6;i++){if(siev[i]==0){for(ll j=i;j<=1e6;j+=i)siev[j]=i,phi[j]=phi[j]*(i-1)/i;}}}
ll gcd(ll a,ll b){if(a<b)swap(a,b);while(b!=0){ll temp=b;b=a%b;a=temp;}return a;}
ll power(ll x, ll y,ll z){if (y == 0)return 1;ll p = power(x, y/2,z) % z;p = (p * p) % z;return (y%2 == 0)? p : (x * p) % z;}
ll modInverse(ll a,ll m){return power(a, phi[m]-1,m);}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n,k,x,m;
    cin>>n>>k;
    
    cin>>x;m=x;
    for(int i=1;i<n;i++)
    {
        int y;
        cin>>y;
        m=max(m,y);
        x=__gcd(x,y);
    }
   
   if(k<=m&&k%x==0)
   cout<<"POSSIBLE\n";
   else
   cout<<"IMPOSSIBLE\n";
    
    
 
    return 0;
} 

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

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;


int main(){
    _fastio
    ll two=0,five=0;

    ll n;
    cin>>n;
    if(n%2) cout<<0<<endl;
    else{
        ll i=2;
        while(n/i>0){
            two+=(n/i-1);
            i*=2;
        }
        ll j=5;
        while(n/j>0){
            five+=(n/j-1)/2;
            ll x=n/j-1;
            if(x%2&&j%2){
                five++;
            }
            j*=5;
        }
        cout<<min(two,five)<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())
    mod = 10**9 + 7

    a = 10 ** N % mod
    b = 9 ** N % mod
    c = 8 ** N % mod
    ans = a - b - b + c
    ans %= mod
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

int n, sl;
vector<ll> h, b, dp;
vector<ll> segt;

ll query(int l, int r){
    l += sl, r += sl;
    ll res = -1;
    for(; l < r; l /= 2, r /= 2){
        if(l & 1) res = max(res, segt[l++]);
        if(r & 1) res = max(res, segt[--r]);
    }
    return res;
}

void modify(int idx, ll x){
    idx += sl;
    segt[idx] = x;
    for(int p = idx; p > 1; p /= 2){
        segt[p/2] = max(segt[p], segt[p ^ 1]);
    }
}


int main(){
    cin>>n;
    h.resize(n), b.resize(n);
    for(int i = 0; i < n; i++){
        cin>>h[i];
    }
    for(int i = 0; i < n; i++){
        cin>>b[i];
    }
    // this is N^2 so TLE but correct solution
    // dp.resize(n);
    // dp[0] = b[0];
    // for(int i = 1; i < n; i++){
    //     dp[i] = 0;
    //     for(int j = 0; j < i; j++){
    //         if(h[j] < h[i]){
    //             dp[i] = max(dp[i], dp[j]);
    //         }
    //     }
    //     dp[i] += b[i];
    // }
    // ll res = *max_element(dp.begin(), dp.end());
    auto mxh = *max_element(h.begin(), h.end());
    sl = mxh + 1;
    segt.resize(2 * sl);
    for(int i = 0; i < n; i++){
        ll ph = query(0, h[i]);
        modify(h[i], ph + b[i]);
    }
    ll res = segt[1];
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 6528
import java.awt.geom.*;
import java.util.*;
import static java.lang.Math.*;
public class Main{
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1166();
	}
	
	class AOJ1166{
		AOJ1166(){
			while(sc.hasNext()){
				int w=sc.nextInt(),
					h=sc.nextInt();
				if((w|h)==0)	break;
				solve(w,h);
			}
		}
		final int INF=1<<29;
		int[] vx={0,1,0,-1},vy={-1,0,1,0};
		void solve(int w,int h){
			w*=2; h*=2;
			--w; --h;
			boolean[][] wall=new boolean[w][h];
			// input
			for(int y=0; y<h; ++y){
				if(y%2==0){
					for(int x=1; x<w; x+=2)	wall[x][y]=(sc.nextInt()==1);
				}else{
					for(int x=0; x<w; x+=2)	wall[x][y]=(sc.nextInt()==1);
					for(int x=1; x<w; x+=2)	wall[x][y]=true;
				}
			}
			
			LinkedList<Pair> open=new LinkedList<Pair>();
			open.add(new Pair(0,0,0));
			
			int[][] closed=new int[w][h];
			for(int i=0; i<w; ++i)for(int j=0; j<h; ++j)closed[i][j]=INF;
			
			int ans=0;
			while(!open.isEmpty()){
				Pair now=open.poll();
				if(now.x==w-1&&now.y==h-1){
					ans=now.s;
					break;
				}
				for(int i=0; i<4; ++i){
					int xx=now.x+vx[i],yy=now.y+vy[i];
					if(!(0<=xx&&xx<w && 0<=yy&&yy<h))	continue;
					if(wall[xx][yy])	continue;
					if(closed[xx][yy]<=now.s+1)	continue;
					open.add(new Pair(xx,yy,now.s+1));
					closed[xx][yy]=now.s+1;
				}
			}
			System.out.println(ans>0? ans/2+1: 0);
		}
		class Pair{
			int x,y,s;
			Pair(int x,int y,int s){
				this.x=x;
				this.y=y;
				this.s=s;
			}
		}
	}
}

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 1e3 + 10;

int n, m;

void prework(){

}

void read(){

}

char s[MAXN];
int cnt[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++){
		scanf("%s", s);
		for (int j = 0; j < m; j++)
			cnt[s[j] - 'a']++;
	}
	int flag = 1;
	if ((n & 1) && (m & 1)){
		int sm = 0;
		for (int i = 0; i < 26; i++)
			if (cnt[i] % 2 == 1){
				cnt[i]--;
				sm++;
			}
		flag &= (sm == 1);
		sm = 0;
		for (int i = 0; i < 26; i++)
			sm += (cnt[i] % 4 == 2);
		flag &= (sm <= n / 2 + m / 2);
	}
	else if ((n & 1) || (m & 1)){
		if (m & 1) swap(n, m);
		// n -> odd
		int sm = 0;
		for (int i = 0; i < 26; i++)
			flag &= (cnt[i] % 2 == 0);
		for (int i = 0; i < 26; i++)
			sm += (cnt[i] % 4 == 2);
		flag &= (sm <= m / 2);
	}
	else{
		for (int i = 0; i < 26; i++)
			flag &= (cnt[i] % 4 == 0);
	}
	puts(flag ? "Yes" : "No");
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] arr = s.toCharArray();
		int total = 0;
		for (char c : arr) {
			total += c - '0';
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 19924
#include<iostream>
#include<cstring>
#include<vector>
#define int long long
using namespace std;
int ans = 0;
int func(vector<int>a, int n)
{
	vector<int>dp(n + 1, 0);
	dp[1] = 0;
	for (int i = 2; i <= n; i++)
	{
		int option1 = abs(a[i] - a[i - 1]) + dp[i - 1];
		int option2 = (i == 2) ? 1e9 : abs(a[i] - a[i - 2]) + dp[i - 2];
		dp[i] = min(option1, option2);
	}
	return dp[n];
}
int32_t main()
{
	int n;
	cin >> n;
	vector<int>a(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	cout << func(a, n ) << "\n";
}

Measured memory_bytes: 5604
package main

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

func main() {
	N := ReadInt()
	L := ReadInts(N)
	max := Max(L...)
	sum := Sum(L...)
	if sum-max > max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    int ans=0;
    fir(i,1,n+1){
       int c=n/i;
       ans=ans+i*(c*(c+1))/2;
    }
    cout<<ans<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15052
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {

		int a = sc.nextInt();
		int p = sc.nextInt();
		int result;

		result = (a*3+p)/2;

		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define len_max 4000
string x, y;
long long dp[len_max+1][len_max+1];

long long lcs(){
    long long m = x.size();
    long long n = y.size();

    x = ' ' + x;
    y = ' ' + y;

    for(long long i = 0; i <= n; i++) dp[i][0] = 0;
    for(long long i = 0; i <= m; i++) dp[0][i] = 0;

    for(long long i = 1; i <= n; i++){
        for(long long j = 1; j <= m; j++){
            if(y[i] == x[j]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    return dp[n][m];
}

int main(){
    cin >> x >> y;

    long long len = lcs();

    long long i = y.size();
    long long j = x.size();
    i--;
    j--;
    len--;
    //printf("len %lld\n", len);
    string ans;

    while(len >= 0){
        if(x[j] == y[i]){
            //ans[len] = y[i];
            ans.push_back(y[i]);
            i--;
            j--;
            len--;
        }
        else if(dp[i][j] == dp[i-1][j]) i--;
        else j--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 85960
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 998244353;

template<int N, int MOD>
struct Comb{
    ll fact[N+1], inv[N+1];
    Comb(){
        fact[0] = inv[0] = inv[1] = 1;
        for(int i=2;i<=N;i++) inv[i] = (MOD+((ll)-inv[MOD%i]*(MOD/i))%MOD)%MOD;
        REPS(i, N){
            fact[i] = fact[i-1]*i%MOD;
            inv[i] = inv[i]*inv[i-1]%MOD;
        }
    }
    ll operator()(int n, int r){
        if(n < 0 || r < 0 || r > n) return 0;
        ll res = inv[r]*inv[n-r];
        if(res >= MOD) res%= MOD;
        res *= fact[n];
        if(res >= MOD) res%= MOD;
        return res;
    }
};
Comb<300000, MOD> C;

ll n, a, b, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> a >> b >> m;
    ll ans = 0;
    REP(i, n + 1) {
        ll r = m - a * i;
        if (r < 0 || r % b != 0) {
            continue;
        }
        ans += C(n, i) * C(n, r / b) % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}


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

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> vec(N + 1);
    int cnt = 0;
    rep(i, N) {
        vec[i] = cnt;
        if (S[i] == 'A' && S[i + 1] == 'C') {
            cnt += 1;
        }
    }
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << vec[r - 1] - vec[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,p[N],cnt;

int main() {
	scanf("%d",&n);
	rep(i,1,n+1) scanf("%d",p+i);
	rep(i,1,n+1) if (p[i]>i&&p[p[i]]==i) cnt++;
	printf("%d\n",cnt);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#defien itnt long long
using namespace std;
int i,j;
int main ()
{
//    int res = 0;
//    for ( int i = 1 ; i <= 4 ; i++ )
//    {
//        for ( int j = 1 ; j <= 4 ; j++ )
//        {
//            for ( int l = 1;  l <= 4 ; l++ )
//            {
//                for ( int k = 1 ;  k<= 4 ; k++ )
//                {
//                    for ( int a = 1 ; a <= 4 ; a++ )
//                    {
//                        if (abs(i-j)==3)res++;
//                        if (abs(l-j)==3)res++;
//                        if (abs(k-l)==3)res++;
//                        if (abs(k-a)==3)res++;
//                    }
//                }
//            }
//        }
//    }
//    cout << res << endl;
    long double a,b,c;
    cin >> a >> b >> c;
    if ( c == 0 )
    cout << setprecision(15) << fixed << (b-1)/a << endl;
    else
    {
        cout << setprecision(15) << fixed << ((b-1)/a)*(2*(a-c)/a) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;

bool compare(const pair<string, int>&a, const pair<string, int>&b){
    return a.second<b.second;
}

int main(){
    int n, m, o, x, y;
    string temp;
    map<string, int> blue;
    cin>>n;
    for(x=0; x<n; x++){
        cin>>temp;
        blue[temp]++;
    }
    cin>>m;
    for(x=0; x<m; x++){
        cin>>temp;
        blue[temp]--;
    }
    o=max_element(blue.begin(), blue.end(), compare)->second;
    o>0 ? cout<<o : cout<<0;
}


Measured memory_bytes: 256
//総当たり//参考2703920
using System;
using System.Linq;
using System.Text;

namespace tst
{
    class Program
    {
        public static bool Solve(int i , int sum , int m, int n, int[]A)
        {
            if (i == n)
            {
                return sum==m;
            }
            return Solve(i + 1, sum, m, n, A) || Solve(i + 1, sum + A[i], m, n, A);
        }
        public static void Main()
        {
            //入力
            int n= int.Parse(Console.ReadLine());
            string[] text1 = Console.ReadLine().Split(' ');
            int[] A = text1.Select(s => int.Parse(s)).ToArray();
            int q = int.Parse(Console.ReadLine());
            string[] text2 = Console.ReadLine().Split(' ');
            int[] M = text2.Select(s => int.Parse(s)).ToArray();
            //処理
            //Mに関するループ
            for (int i = 0; i < q; i++)
            {
                Console.WriteLine(Solve(0, 0, M[i], n, A) ? "yes" : "no");
            }
        }

    }
}


Measured memory_bytes: 18276
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==1)
		a=14;
	if(b==1)
		b=14;
	if(a>b)
		printf("Alice\n");
	else if(a<b)
		printf("Bob\n");
	else
		printf("Draw\n");
	return 0;
}

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

int main(){

    int c[3][3];
    for( int i = 0; i < 3; i++ ){
        for( int j = 0; j < 3; j++ ){
            cin >> c[i][j];
        }
    }

    int a[3], b[3];
    bool flag = true;

    a[0] = 0;
    for( int i = 0; i < 3; i++ ) b[i] = c[0][i] - a[0];
    a[1] = c[1][1] - b[1];
    a[2] = c[2][1] - b[1];

    for( int i = 0; i < 3; i++ ){
        for( int j = 0; j < 3; j++ ){
            if( c[i][j] != a[i] + b[j] ) flag = false;
        }
    }

    if( flag ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    set<string> set;
    rep(i,n){
        string s;
        cin>>s;
        set.insert(s);
    }
    int m;
    cin>>m;
    bool f=true;
    rep(i,m){
        string s;
        cin>>s;
        if(set.find(s)!=set.end()){
            cout<<(f?"Opened":"Closed")<<" by "<<s<<endl;
            f=!f;
        }
        else{
            cout<<"Unknown "<<s<<endl;
        }
    }
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	char c;
	cin >> c;
	char r = c+1;
	cout << r << endl;
	return 0;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int n = 0;
        for (int i = a; i <= b; i++) {
            if (c % a == 0) {
                n++;
            }
            a++;
        }
        System.out.println(n);
    }
}


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

using namespace std;
#define forr(i, n) for(ll i = n-1; i >= 0; i--)
#define forn(i, n) for(ll i = 0; i < n; i++)
#define forab(i, a, n) for(ll i = a; i < n; i++)
#define forabr(i, a, b) for(ll i = a; i >= b; i--)
#define endl '\n'
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(7); cout.setf(ios::fixed);
#define fale_io ifstream fin("grants.in"); ofstream fout("grants.out");
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

typedef long long ll;
typedef string S;

const ll mod = 1e9 + 7;
const ll Inf = LONG_LONG_MAX;
const double long PI = 3.1415926535;

ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll max(ll a, ll b){if(a > b)return a;return b;}
ll gcd (ll a, ll b) {while (b) {a %= b;swap (a, b);}return a;}
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }

int n, k, mx;

int main() {
    fast_io;
    cin >> k >> n;
    vector<int> a(n);
    forn(i, n)cin >> a[i];
    sort(all(a));
    mx = k - a[n-1] + a[0];
    forn(i, n-1)mx = max(mx, a[i+1] - a[i]);
    cout << k - mx;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  vector<bool> B(1e6 + 1, 1);
  B.at(0) = B.at(1) = 0;
  for (long i = 2; i <= 1e6; i++) {
    if (B.at(i)) for (long j = i * i; j <= 1e6; j += i) B.at(j) = 0;
  }
  
  vector<vector<int>> V(1e6+1);
  for (int i = 2; i <= 1e6; i++) {
    if (B.at(i)) for (int j = i; j <= 1e6; j += i) V.at(j).push_back(i);
  }

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  vector<bool> B2(1e6+1);
  for (auto a : A) {
    for (auto b : V.at(a)) {
      if (B2.at(b)) goto NG;
      B2.at(b) = 1;
    }
  }
  return cout << "pairwise coprime" << "\n", 0;
  NG:;
  
  int G = 0;
  for (int i = 0; i < N; i++) {
    G = gcd(G, A.at(i));
  }
  cout << ((G == 1) ? "setwise coprime" : "not coprime") << "\n";
}

Measured memory_bytes: 62876
N = int(input())
W = list(map(int, input().split()))

minans = 100000
for i in range(N):
    if abs(sum(W[:i+1]) - sum(W[i+1:])) < minans:
        minans = abs(sum(W[:i+1]) - sum(W[i+1:]))
    
print(minans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

void printVector(vector<vector<long> > v) {
    for (long i = 0; i < v.size(); i++ ) {
        for (long j = 0; j < v.front().size(); j++) {
            cout << v[i][j]; 
            if (j != v.front().size() - 1) {
            cout << " "; 
            }
        }
        cout << endl;
    }
}


int main(void) {
    long n; // row in A
    long m; // column in A and column in B
    long l; // column in B
    cin >> n >> m >> l;
    vector<vector<long> > a(n, vector<long>(m, 0));
    vector<vector<long> > b(m, vector<long>(l, 0));
    vector<vector<long> > answer(n, vector<long>(l, 0));
    for (long i = 0; i < n; i++) {
        for (long j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (long i = 0; i < m; i++) {
        for (long j = 0; j < l; j++) {
            cin >> b[i][j];
        }
    }

    //printVector(a);
    //printVector(b);

    for (long i = 0; i < n; i++) {
        for (long j = 0; j < l; j++) {
            for (long k = 0; k < m; k++) {
                answer[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    printVector(answer);

    return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;


int main() {
    //ios_base::sync_with_stdio(false);
    //cout<<setprecision(17);
    int n;
    ll a[200000];
    cin>>n;
    a[0]=0;
    for(int i=1;i<n+1;i++){
        cin>>a[i];
    }
    a[n+1]=0;
    ll ans=0;
    for(int i=0;i<n+1;i++){
        ans+=abs(a[i]-a[i+1]);
    }
    for(int i=1;i<n+1;i++){
        if((a[i-1]<=a[i]&&a[i]<=a[i+1])||(a[i-1]>=a[i]&&a[i]>=a[i+1])){
            cout<<ans<<endl;
        }
        else{
            cout<<ans-abs(a[i]-a[i+1])-abs(a[i]-a[i-1])+abs(a[i-1]-a[i+1])<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2048
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    A, B, T = input_nums()
    time = 0
    total = 0
    while True:
        time += A
        if time > T +0.5: break
        total += B
    print(total)
if __name__ == '__main__':
    main()


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

#define PI 3.1415926

int main(void){

	double x=0,y=0;
	int z,turn;
	double angle=0;

	while(scanf("%d,%d",&z,&turn)!=EOF){

		if(z==0 && turn==0)
			break;

		x += cos(PI*angle/180.0)*z;
		y += sin(PI*angle/180.0)*z;
		
		angle += turn;

	}


	printf("%d\n%d\n",(int)y,(int)x);

	return 0;
}

Measured memory_bytes: 604
from itertools import accumulate
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

##累積和のリストが得られる
a_cum = [0] + list(accumulate(a))
b_cum = [0] + list(accumulate(b))

ans = [0]
for i in range(n + 1):    #0~n+1
    c = bisect_right(b_cum, k-a_cum[i]) - 1 ##Aをi冊読んだ場合の残り時間 : k-a[i]  bisect_rightでbの累積時間の最大のインデックス(本の冊数)が求まる
                                 ##bisectは位置が求まるので、-1で冊数を求めている
    if c != -1: #0から始まるので、冊数が0の場合は-1となってしまう
        ans.append(c+i)

print(max(ans))

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

void main()
{
    int n, k, x, y;
    readf("%d\n%d\n%d\n%d\n", &n, &k, &x, &y);
    writeln((n > k ? k : n)*x + (n - k < 0 ? 0 : n - k)*y);
}

Measured memory_bytes: 256
#include<iostream> 
#include<algorithm> 
#include<cstdio> 
#include<string>
#include<cmath>
#include<cstring>
using namespace std; 
int main() 
{ 
 	int x1,x2,x3,x4,y1,y2,y3,y4;
 	cin>>x1>>y1>>x2>>y2;
 	x4=x1-(y2-y1);
 	y4=y1+(x2-x1);
 	x3=x4-(y1-y4);
 	y3=y4+(x1-x4);
 	printf("%d %d %d %d",x3,y3,x4,y4);
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	ll n, k,ans;
	cin >> n >> k;
	ll x[100000];
	int s = -1; 
	ans = 100000000000;
	int m;
	REP(i, n) {
		cin >> x[i];
		if (s == -1 && x[i] >= 0) {
			s = i;
		}
	}
	if (x[n - 1] >= 0) {
		if (s - k < 0) {
			REP(i, s) {
				if (i == 0) {
					m = min(abs(x[i + k - 1]), abs(x[i]));
					ans = m + x[i + k - 1] - x[i];
				}
				if (i != 0 && i + k - 1 <= n - 1) {
					m = min(abs(x[i + k - 1]), abs(x[i]));
					ans = min(m + x[i + k - 1] - x[i], ans);
				}
			}
		}
		else {
			FOR(i, s - k + 1, s) {
				if (i == s - k + 1) {
					m = min(abs(x[i + k - 1]), abs(x[i]));
					ans = m + x[i + k - 1] - x[i];
				}
				if (i != s - k + 1 && i + k - 1 <= n - 1) {
					m = min(abs(x[i + k - 1]), abs(x[i]));
					ans = min(m + x[i + k - 1] - x[i], ans);
				}
			}
		}

		if (s >= k) {
			ans = min(ans, abs(x[s - k]));
			//cout << "1" << endl;
		}
		if (s + k - 1 <= n - 1) {
			ans = min(ans, x[s + k - 1]);
			//cout << "2" << endl;
		}
	}
	else {
		ans = abs(x[n - k]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD =   998244353;

ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k;cin>>n>>m>>k;
    ll ans = 0;
    p=prods(500000);
    for(int i=0; i<=k; i++ ){
        ans += m*power(m-1,n-i-1)%MOD*comb(n-1,i)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
    int n;
    scanf("%d",&n);
    if(n<1000)printf("ABC\n");
    else printf("ABD\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    string a, b;
    cin >> a >> b;

    a += b;

    double sqrt_str = sqrt(stoi(a));
    if(sqrt_str - (int)(sqrt_str) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,dp[3003][3003],pre[3003][3003];
string s;

void solve(){
    cin>>n>>s;
    dp[1][0]=1;
    rep(i,0,n+1) pre[1][i]=1;
    rep(i,2,n+1){
        rep(j,0,i){
            // j to i-2
            if(s[i-2]=='>') dp[i][j]=(pre[i-1][i-2]-(j-1>=0?pre[i-1][j-1]:0)+hell)%hell;
            else dp[i][j]=pre[i-1][j-1];
            pre[i][j]=(dp[i][j]+(j?pre[i][j-1]:0))%hell;
        }
    }
    int ans=0;
    rep(i,0,n) ans=(ans+dp[n][i])%hell;
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 69376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  cout << (n%k == 0 ? 0 : 1) << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.nextLine());
        int w = Integer.parseInt(sc.nextLine());
        int n = Integer.parseInt(sc.nextLine());
        int large;
        int small;
        // 合計
        int total = 0;
        int paint = 0;
        if(h >= w){
            large = h;
            small = w;
        }else {
            large = w;
            small = w;
        }
        
        while(total < n){
            total = total + large;
            paint++;
        }
        System.out.println(paint);
    }
    
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

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

    vector<ll> L(N);
    REP (i, N) {
        cin >> L[i];
    }

    ll ans = 0;
    REP (i, N) {
        for (ll j=i+1; j<N; j++) {
            for (ll k=j+1; k<N; k++) {
                if ((L[i] != L[j]) && (L[j] != L[k]) && (L[k] != L[i]) ) {
                    //三角形成立条件　 |b−c|<a<b+c
                    if ((abs(L[j]-L[k]) < L[i]) && (L[i] < (L[j]+L[k]))) {
                        ans++;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
import sys
readline = sys.stdin.readline
def mergeup(Av, Aw, vw):
    v, w = vw
    rv, rw = [], []
    N = len(Av)
    idx = 0
    jdx = 0
    for _ in range(2*N):
        if idx == N or Aw[idx] > Aw[jdx] + w:
            if Aw[jdx] + w > limit:
                break
            rw.append(Aw[jdx]+w)
            rv.append(Av[jdx]+v)
            jdx += 1
        else:
            rw.append(Aw[idx])
            rv.append(Av[idx])
            idx += 1

    return rv, rw

def mergedown(Av, Aw, vw):
    v, w = vw
    resv, resw = [], []
    N = len(Av)
    idx = 0
    jdx = 0
    for _ in range(2*N):
        if jdx == N or Aw[idx] <= Aw[jdx] - w:
            resv.append(Av[idx])
            resw.append(Aw[idx])
            idx += 1
        else:
            if Aw[jdx] - w < 0:
                jdx += 1
                continue
            resv.append(Av[jdx] + v)
            resw.append(Aw[jdx] - w)
            jdx += 1
    return resv, resw


limit = 10**5
N = int(readline())
VW = [None] + [tuple(map(int, readline().split())) for _ in range(N)]
BS = min(N, 1<<12)
Q = int(readline())
VL = [None] + [tuple(map(int, readline().split())) for _ in range(Q)]


Rv = [[0] for _ in range(BS+1)]
Rw = [[0] for _ in range(BS+1)]
for i in range(1, BS):
    for vm, wm in zip(*mergeup(Rv[i//2], Rw[i//2], VW[i])):
        if Rv[i][-1] < vm:
            Rv[i].append(vm)
            Rw[i].append(wm)
    
ans = [0]*(Q+1)
for i in range(1, Q+1):
    v, l = VL[i]
    Kv, Kw = [0], [l]
    while v >= BS:
        Kv, Kw = mergedown(Kv, Kw, VW[v])
        v >>= 1
    cnt = len(Rv[v])-1
    ctr = 0
    for j in range(len(Kv)-1, -1, -1):
        kv, kw = Kv[j], Kw[j]
        while kw < Rw[v][cnt]:
            cnt -= 1
        ctr = max(ctr, kv+Rv[v][cnt])
    ans[i] = ctr

print('\n'.join(map(str, ans[1:])))


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, k, i;
	int x, pos = -1;
	int sol = 1<<30;
	
	cin>>n>>k;
	
	for (i = 0; i < n; ++i)
	{
		cin>>x;
		if (x == 1)
			pos = i;
	}
	
	assert(pos != -1);
	
	for (i = 0; i < k; ++i)
	{
		if (pos - i < 0 || pos - i + k > n)
			continue;
		
		sol = min(sol, (pos - i + k - 2) / (k - 1) + (n - (pos - i + k) + k - 2) / (k - 1));
	}
	
	cout<<1 + sol<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  ll s=0,cnt=0;
  vector<ll> vec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
    s+=a;
  }
  for(int i=0;i<n;i++){
    if(4*m*vec[i]>=s) cnt++;
  }
  cout<<(cnt>=m?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n,m;
  int result[150]={0};
  int target[150];
  
  cin>>n;

  cin>>m;

  for(int i=1;i<=m;++i)
     cin>>target[i];

  for(int i=1;i<=m;++i){
    int expect[150];
    for(int j=1;j<=n;++j){
      cin>>expect[j];

      if(expect[j]==target[i])
	result[j]++;
      else
	result[target[i]]++;
    }
  }

  for(int i=1;i<=n;++i)
    cout<<result[i]<<endl;
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<math.h>

int main(){
	char men[10][10],t;
	int i,j;
	
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			men[i][j]=0;
		}
	}

	while(0<=scanf("%s%*c",men[0])){
		for(i=1;i<8;i++){
			scanf("%s%*c",men[i]);
		}
		
		t='0';
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(men[i][j]=='1'){
					t='2';
					break;
				}
			}
			if(t=='2')
			break;
		}
		
		if(men[i][j+1]=='1' && men[i+1][j]=='1' && men[i+1][j+1]=='1'){
			printf("A\n");
		}else if(men[i+2][j]=='1'){
			printf("B\n");
		}else if(men[i][j+2]=='1'){
			printf("C\n");
		}else if(men[i+2][(j-1)%10]=='1'){
			printf("D\n");
		}else if(men[i+1][(j+2)%10]=='1'){
			printf("E\n");
		}else if(men[(i+2)%10][(j+1)%10]=='1'){
			printf("F\n");
		}else{
			printf("G\n");
		}
/*		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				printf("%c",men[i][j]);
				men[i][j]=0;
			}
			printf("\n");
		}*/
		
		
	}
	return 0;
}

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

using namespace std;

int main(void){
	while(1){
		int num;
		int count = 0;
		cin >> num;
		if(num == 0){
			break;
		}

		for(int i = 2; double(num) / i - i / 2 > 0; i++){
			if(i % 2 == 0){
				if(num % i == i / 2){
					count += 1;
				}
			}else{
				if(num % i == 0){
					count += 1;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 2928
# include <bits/stdc++.h>
# define rr
# define int long long
const int N=200010,INF=0x3f3f3f3f;
int head[N],sum;
int dfn[N],t;
int p[N];
int to[N];
int n,k;
int S,T;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
void dfs(int now){
	if(dfn[now]){
		S=dfn[now],T=t;
		return;
	}
	dfn[now]=++t;
	p[t]=now;
	dfs(to[now]);
	return;
}
signed main(void){
	n=read(),k=read();
	for(rr int i=1;i<=n;++i){
		to[i]=read();
	}
	dfs(1);
	++k;
	if(k<=t){
		printf("%lld",p[k]);
		return 0;
	}
	k-=(S-1);
	k=(k-1)%(T-S+1)+1;
	printf("%lld",p[S+k-1]);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
string s;

int main(){
	cin>>s;
  n=s.size();
  ll res=INF;
  for(char c='a';c<='z';c++){
    string t=string(&c)+s+string(&c);
    ll i=1,pre=0;
    ll crt=0;
    while(i<t.size()){
      while(i<t.size()&&t[i]!=c)i++;
      maxch(crt,i-pre-1);
      pre=i;
      i++;
    }
    minch(res,crt);
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import fractions
from functools import reduce
N, X =list(map(int,input().split()))
listx = list(map(int,input().split()))
list1 = [abs(x-X) for x in listx]

for i in range(0,N-1):
  ans = fractions.gcd(list1[i],list1[i+1])

print(reduce(lambda a,b:fractions.gcd(a,b),list1,list1[0]))


Measured memory_bytes: 89236
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

const int N = 100005;

int n,h[N],dp[N];

int main() {

	n=read(); rep(i,1,n) h[i]=read();
	dp[1]=0; dp[2]=dp[1]+abs(h[1]-h[2]); rep(i,3,n) dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i-1]-h[i]));
	printf("%d\n",dp[n]);	

	return 0;
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
template <class X> void print(X x) { cout << x << endl; }
void print(vl x) {
    for(ll i : x) {
        cout << i << " ";
    }
    cout << endl;
}
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v, m;
ll codeforces = 1;
string S, T;
vl A, B;
void input() { cin >> l >> r >> d; }
void solve() { print(r / d - (l - 1) / d); }
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    while(codeforces--) {
        solve();
    }
}

Measured memory_bytes: 3604