akhauriyash/Code-Regression huggingface dataset:
def main():
    S = input()
    p = 2019
    d = {i:0 for i in range(p)}
    d[0] = 1
    r = 0
    x = 0
    for i in range(len(S)):
        x += int(S[len(S)-1-i]) * pow(10, i, p)
        x %= p
        r += d[x]
        d[x] += 1
    return r
print(main())


Measured memory_bytes: 68588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;cin >> n >> m;
	if(abs(n - m) >= 2){
		cout << 0 << endl;
		return 0;
	}
	ll ans1 = 1, ans2 = 1;
	rep(i,n){
		ans1 *= i + 1;
		ans1 %= mod;
	}
	rep(i,m){
		ans2 *= i + 1;
		ans2 %= mod;
	}
	ll ans = ans1 * ans2 % mod;
	if(n == m) ans = ans * 2 % mod;
	cout << ans << endl;
}


Measured memory_bytes: 384
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3
4980
7980
6980"# => r#"15950"#,
r#"4
4320
4320
4320
4320"# => r#"15120"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        p: [usize; n],
    }
    (p.iter().sum::<usize>() - ( p.iter().max().unwrap() / 2) ).to_string()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int dp[105][105];
string s;

int f(int start,int fin){
	int&ret = dp[start][fin];
	if(~ret) return ret;
	ret = 0;
	if(start==fin || start>fin) return ret;
	if(s[start]==s[fin]) return ret = f(start+1,fin-1);

	return ret = 1+f(start+1,fin-1);
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>s;
	int n = s.length()-1;
	cout<<f(0,n);
}

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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

int main(){
  int n;cin>>n;
  vector<int> x(n), y(n);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    x[i]=y[i]=a;
  }
  sort(y.begin(), y.end());
  for(int i=0;i<n;i++){
    if(x[i]<=y[n/2-1])cout<<y[n/2]<<endl;
    else cout<<y[n/2-1]<<endl;
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
long long i,t[100010];
long long tot,n,m,ap[100010],k,k2,ans[100010];
pair<long long,long long>v[100010];
long long gaseste(long long x)
{
    if(x!=t[x])t[x]=gaseste(t[x]);
    return t[x];
}
void uneste(long long x,long long y)
{
    long long tx,ty;
    tx=gaseste(x);
    ty=gaseste(y);
    if(tx<ty)
    {
        t[ty]=tx;
        ap[tx]+=ap[ty];
        ap[ty]=0;
        gaseste(ty);
    }
    else
    {
        t[tx]=ty;
        ap[ty]+=ap[tx];
        ap[tx]=0;
        gaseste(tx);
    }
}
int main()
{
   // ifstream cin ("a.in");
   // ofstream cout ("a.out");
    cin>>n>>m;
    for(i=1; i<=n; ++i)t[i]=i,ap[i]=1;
    tot=n*(n-1)/2;
    ans[m]=tot;
    for(i=1; i<=m; ++i)
        cin>>v[i].first>>v[i].second;
    for(i=m; i>=2; --i)
    {
        k=k2=0;
        if(gaseste(v[i].first)!=gaseste(v[i].second))
        {
            k=ap[gaseste(v[i].first)];
            k2=ap[gaseste(v[i].second)];
            uneste(v[i].first,v[i].second);
        }
        if(ans[i]>=k*k2)ans[i-1]=ans[i]-k*k2;
        else ans[i-1]=0;
        if(ans[i-1]==0)break;
    }
    for(i=1; i<=m; ++i)
        cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    
    cout << N*N << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            
            string s;
            cin >> s;
            bool ok = 0;
            for(char c:s)
                if(c == '7')
                    ok = 1;
            cout << ((ok)?"Yes":"No") << endl;




           return 0;
        }
          

Measured memory_bytes: 3608
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
const int maxn=2e5+5;
int i,j,c,ne[maxn];
char S[maxn];
ll num[maxn][26],l,r,T,n;
ll f(ll len){
	if (len<=n) return num[len][c];
	if (len<=n*2) return num[n][c]+num[len-n][c];
	ll f1=num[n][c],f2=num[n][c]+num[T][c],l1=n,l2=n+T;
	for(;len>l1+l2;)swap(f1,f2),f2+=f1,swap(l1,l2),l2+=l1;
    return f2+f(len-l2);
}
ll work(ll len){
	if (n%T==0) return len/T*num[T][c]+num[len%T][c];
    return f(len);
}
int main(){
	scanf("%s",S+1);
	n=strlen(S+1),n>>=1;
	fo(i,1,n) {
		fo(j,0,25) num[i][j]=num[i-1][j];
		num[i][S[i]-'a']++;
	}
	j=0;
	fo(i,2,n){
		for(;j&&S[j+1]!=S[i];j=ne[j]);
		if (S[j+1]==S[i]) j++;
		ne[i]=j;
	}
	T=n-j;
	scanf("%lld%lld",&l,&r);
	fo(c,0,25) printf("%lld ",work(r)-work(l-1));
}

Measured memory_bytes: 23040
from collections import deque
n = int(input())
# 最終的に出力する色
colors = [-1] * n
# 重み付き無向グラフ
conns = [set() for _ in [0] * n] 

for x in range(1, n):
  v1, v2, dis = map(int, input().split())
  # (接続ノード, 重み) を加える
  conns[v1-1].add((v2-1, dis))
  conns[v2-1].add((v1-1, dis))

# BFSの為に根ノードを初期化. (基準ノード, 距離, 過去のノード)
q = deque([(0, 0, -1)])
# BFS開始
while q:
  v, dis, past = q.popleft()
  
  # 奇数なら1で,偶数なら0で塗る
  colors[v] = dis&1
  
  # 基準ノードから生える各エッジに対し
  for edge, w in conns[v]:
    
    # エッジが既に調べたものなら飛ばす
    if edge == past:
      continue
    # 根からここまでの距離を足しつつ,新しく探索先を追加.
    q.append((edge, dis + w, v))

print('\n'.join(map(str, colors)))

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

int a, b, c;

int main () {
	cin >> a >> b >> c;
	if (b+c >= a) {
		cout << c-a+b << endl; 
	} else if ((b+c < a)&&(b < c)) {
		cout << 0 << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans=0;
int n;
int a[100010],b[100010],c[100010];
 int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;++i)
		scanf("%d",&b[i]);
	for (int i=1;i<=n;++i)
		scanf("%d",&c[i]);
	sort(a+1,a+n+1);sort(b+1,b+n+1);sort(c+1,c+n+1);
	for (int i=1;i<=n;++i)
	{
		int lena=(upper_bound(a+1,a+n+1,b[i]-1)-a)-1;
		int lenc=n-(upper_bound(c+1,c+n+1,b[i])-c)+1;
		ans+=(ll)lena*lenc;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<malloc.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a[100], b[100];
struct node{
    int left = -1;
    int right = -1;
};
node chi[100];

void dfs(int l, int r, int p, int q){
    if(r - l <= 1 || q - p <= 1)return;
    //printf("called [%d, %d)[%d, %d)\n", l, r, p, q);
    //return;
    int pos = -1;
    int v = a[l];
    for(int i = p; i < q; i++){
        if(v == b[i])pos = i;
    }
    if(pos < 0)return;
    if(pos == p){
        chi[v].left = -1;
        chi[v].right = a[l + 1];
    }
    else if(pos == q - 1){
        chi[v].right = -1;
        chi[v].left = a[l + 1];
    }
    else {
        chi[v].left = a[l + 1];
        chi[v].right = a[l + pos - p + 1];
    }
    //printf("call [%d, %d)[%d, %d)\n", l + 1, l + pos - p + 1, p, pos + 1);
    //printf("call [%d, %d)[%d, %d)\n", l + pos - p + 1, r, pos + 1, q);
    dfs(l + 1, l + pos - p + 1, p, pos);
    dfs(l + pos - p + 1, r, pos + 1, q);
}

vector<int> post;

void dfs2(int v){
    if(v < 0)return;
    dfs2(chi[v].left);
    dfs2(chi[v].right);
    post.push_back(v);
}

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    int root = a[0];
    dfs(0, N, 0, N);
    dfs2(root);
    for(int i = 0; i < N; i++){
        cout << post[i] << ((i == N - 1) ? "\n" : " ");
    }

    return 0;
}

/*

*/


Measured memory_bytes: 3156
import scala.io.{ StdIn => in}
import scala.annotation.tailrec

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val graph = Array.ofDim[Boolean](n, n)

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt - 1))
    .foreach(e => {
      graph(e(0))(e(1)) = true
      graph(e(1))(e(0)) = true
    })

  def solve():Int = {
    var cnt = 0
    val p = Array.ofDim[Int](n)

    def evalute():Unit = {
      // println(p.mkString(" "))
      @tailrec
      def rec(idx:Int):Boolean = {
        val next = idx+1
        if(next == n) true
        else if(graph(p(idx))(p(next))) rec(next)
        else false
      }

      if(rec(0)) cnt += 1
    }

    def dfs(pos:Int, mask:Int):Unit = {
      if(pos == n) evalute
      else {
        for(i <- 0 until n if (mask & (1<<i)) > 0) {
          p(pos) = i
          dfs(pos+1, mask ^ (1<<i))
        }
      }
    }

    dfs(1, ((1<<n)-1) ^ 1<<0)
    cnt
  }

  println(solve)
}

Measured memory_bytes: 30012
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    const char* x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int n;
    while (scanf("%d", &n), n) {
        char s[128], res[128];
        int i, k[128];
        for(i=0;i<n;++i) scanf("%d", k+i);
        scanf("%s", s);
        for(i=0;s[i];++i)
            res[i]=x[(s[i]-(islower(s[i])?'a':('A'-26))-k[i%n]+52)%52];
        res[i]=0;
        puts(res);
    }
    return 0;
}

Measured memory_bytes: 592
import sys

A, B, C, D, E, F = map(int, sys.stdin.readline().split())

max_a = (F - 1) // (100 * A) + 1
max_b = (F - 1) // (100 * B) + 1

max_rate = 0
ans_water = 0
ans_sugar = 0
for a in range(max_a + 1):
    for b in range(max_b + 1):
        water = 100 * A * a + 100 * B * b
        if water >= F:
            break

        max_sugar = min(F - water, water // 100 * E)
        # print("max_sugar", max_sugar)
        max_c = (max_sugar - 1) // C + 1
        max_d = (max_sugar - 1) // D + 1
        for c in range(max_c + 1):
            for d in range(max_d + 1):
                sugar = C * c + D * d
                if sugar > max_sugar or sugar + water > F:
                    break

                if sugar * (ans_water + ans_sugar) >= ans_sugar * (water + sugar):
                    ans_water = water
                    ans_sugar = sugar

print(ans_water + ans_sugar, ans_sugar)

Measured memory_bytes: 70944
n, m = map(int, input().split())
a = [0 for i in range(n)]
ac = 0
wa = [0 for i in range(n)]
ww = 0
for i in range(m):
	p,s = map(str, input().split())
	if a[int(p)-1] == 0 and s == "WA":
		wa[int(p)-1] += 1
	if a[int(p)-1] == 0 and s == "AC":
		a[int(p)-1] =1
		ac += 1
		ww += wa[int(p)-1]
print (ac,ww)


Measured memory_bytes: 4760
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;


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

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 = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);

	ll cnt = 1;
	ll h = g;
	for (ll i = 2; i * i <= h; i++) {
		if (g % i != 0) continue;
		cnt++;
		while (g % i == 0) {
			g /= i;
		}
		if (g == 1) break;
	}
	if (g != 1) cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np


x = int(input())

MAX_PRIME = 100003
prime = np.array(range(MAX_PRIME+1))

prime[0:2] = 0
for i, v in enumerate(prime):
    if v == 0:
        continue
    prime[i*2::i] = 0

rst = MAX_PRIME
for i in range(x, MAX_PRIME+1):
    if prime[i] != 0:
        rst = i
        break

print(rst)




Measured memory_bytes: 22112
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    static List<Node> nodes = new List<Node>();
    static int time = 0;

    class Node
    {
        public bool visited = false;
        public int d_time = 0;
        public int f_time = 0;
        public List<int> adjacentIds;
    }

    static void Main(string[] args)
    {
    	// 行数を取得
        int n = int.Parse(Console.ReadLine().Split()[0]);

        // nodeを作成
        for (int i = 0; i < n; i++)
        {
            nodes.Add(new Node());
        }

        // nodeの中身設定
        for (int i = 0; i < n; i++)
        {
            List<int> nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToList();
            nodes[nums[0] - 1].adjacentIds = nums.GetRange(2, nums[1]).Select(id => id - 1).ToList();
        }

        // dfs
        while (nodes.Exists(node => node.d_time == 0))
        {
            dfs(nodes.Where(node => node.d_time == 0).ToList()[0]);
        }

        // 出力
        for (int i = 0; i < n; i++)
        {
            System.Console.WriteLine(string.Format("{0} {1} {2}", i + 1, nodes[i].d_time, nodes[i].f_time));
        }
    }

    static void dfs(Node node)
    {
        time++;
    	node.visited = true;
       	if (node.d_time == 0)
       	{
       		node.d_time = time;
       	}
        if (node.adjacentIds.Count() == 0)
        {
            node.f_time = time;
        }
        foreach (var adjacentId in node.adjacentIds)
        {
        	if (!nodes[adjacentId].visited)
        	{
	            dfs(nodes[adjacentId]);
	        }
        }
        time++;
        node.f_time = time;
    }
}



Measured memory_bytes: 9736
#include<bits/stdc++.h>
using namespace std;
main() {
    int i,j,ok;
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    ok = 0;
    for(i=0;i<=n;i++) {
        for(j=0;j<=m;j++) {
            if(m*i + n*j - 2*i*j == k) ok = 1;
        }
    }
    if(ok) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N;
	cin >> N;

	int ans = 0;
	int a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		a--;
		ans += a;
	}

	cout << ans << endl;

	return 0;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);

    vector<int> a(n);
    rep(i,n)
    {
        scanf(" %d", &a[i]);
        --a[i];
    }

    int ans=0;

    rep(i,n)
    {
        // printf("%d, %d, %d\n", i,a[i],a[a[i]]);
        if(a[a[i]]==i && i<a[i]) ++ans;
    }

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
struct info
{
    int x,y,h;
    info(int x,int y,int h):x(x),y(y),h(h){}
};
vector<info> I;

void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x,y,h; cin >> x >> y >> h;
        I.emplace_back(x,y,h);
    }
    
}

int calc_h(int x, int y,int cx,int cy, int h){
    return max(h-abs(cx-x)-abs(cy-y),0);
}

bool chk(int cx, int cy, int h){
    for (int i = 0; i < N; i++)
    {
        if(I[i].h<calc_h(I[i].x,I[i].y,cx,cy,h)) return false;
    }
    return true;    
}

bool isok(int cx, int cy, int h){
    for (int i = 0; i < N; i++)
    {
        if(I[i].h!=calc_h(I[i].x,I[i].y,cx,cy,h)) return false;
    }
    return true;    
}

int solve(){
    for (int cx = 0; cx <= 100; cx++)
    {
        for (int cy = 0; cy <= 100; cy++)
        {
            int ok = 1, ng = 1e9+200;
            while(ng-ok>1){
                int mid = (ok+ng)/2;
                if(chk(cx,cy,mid)) ok=mid;
                else ng=mid;
            }
            if(isok(cx,cy,ok)) {
                cout << cx << " " << cy << " " << ok << endl;
                return 0;
                }
        }
        
    }
    
    return 0;
}   

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

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        long K = nint();
        int[] A = nints(N);
        int[] c = new int[2001];
        for (int i_A = 0; i_A < N; i_A++) {
            for (int i_c = 1; i_c <= 2000; i_c++) {
                if (A[i_A] < i_c) {
                    c[i_c]++;
                }
            }
        }
        long add = 0;
        for (int i = 0; i < N; i++) {
            add += c[A[i]];
        }
        
        long invA = inv(A);
        
        long f = invA;
        long l = (invA + add * (K-1));
        
        if (K % 2 == 0) {
            System.out.println(K/2 * ((f+l) % MOD) % MOD);
        } else {
            System.out.println(K * ((f+l)/2 % MOD) % MOD);
        }
        
    }
    
    static long inv(int[] a) {
        int inv = 0;
        for (int i = 0; i < a.length; i++) {
            for (int j = i+1; j < a.length; j++) {
                if (a[i] > a[j]) {
                    inv++;
                }
            }
        }
        return inv;
    }
    

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 26100
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main() {

	int x;
	cin>>x;
	if (x>=400 && x<=599)
	{
		cout<<8<<endl;
	}
	if (x>=600 && x<=799)
	{
		cout<<7<<endl;
	}

	if (x>=800 && x<=999)
	{
		cout<<6<<endl;
	}
	if (x>=1000 && x<=1199)
	{
		cout<<5<<endl;
	}
	if (x>=1200 && x<=1399)
	{
		cout<<4<<endl;
	}
	if (x>=1400 && x<=1599)
	{
		cout<<3<<endl;
	}
	if (x>=1600 && x<=1799)
	{
		cout<<2<<endl;
	}
	if (x>=1800 && x<=1999)
	{
		cout<<1<<endl;
	}


return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int[] h = new int[N];
   for(int i=0;i<N;i++) h[i] = sc.nextInt();
   int[] dp = new int[N+1];
   dp[0]=0;
   dp[1]=Math.abs(h[1]-h[0]);
   for(int i=2;i<N;i++)
   {
     if(dp[i-2]+Math.abs(h[i-2]-h[i])>=dp[i-1]+Math.abs(h[i-1]-h[i]))
     dp[i]=dp[i-1]+Math.abs(h[i-1]-h[i]);
     else dp[i]=dp[i-2]+Math.abs(h[i-2]-h[i]);
   }
   System.out.println(dp[N-1]);
 }
}

Measured memory_bytes: 51520
import java.util.Scanner;
public class Main {
	static int[][] gyo2=new int[100000][12];
	static int count=0;
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		long K=sc.nextLong();
		long ans=0;
		if(K>A) {
			ans+=A;
			K-=A;
		}else {
			ans+=K;
			K=0;
		}
		if(K>0) {
			K-=B;
		}
		if(K>0) {
			if(K>C) {
				ans-=C;
			}else {
				ans-=K;
			}
		}
		System.out.println(ans);

}

}


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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    long a[] = new long[100001];

    s = r.readLine();
    sl = s.split(" ");
     for(int i = 0; i < n; i++)
     {
       a[i] = Long.parseLong(sl[i]);
     }

    RemRing rr = new RemRing(1000000007L);

    long c[] = new long[3];
    long v = 1;

    for(int i = 0; i < n; i++)
    {
      boolean b = true;
      long l = 0;
      for(int j = 0; j < 3; j++)
      {
        if(c[j] == a[i])
        {
          l++;
          if(b)
          {
            b = false;
            c[j]++;
          }
        }
      }
      v = rr.prod(v, l);
      // System.out.println(v);
    }

    System.out.println(v);

  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 53176
A, B, M = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
x = [0]*M
y = [0]*M
c = [0]*M
for i in range(M):
  x[i], y[i], c[i] = map(int, raw_input().split())
  x[i] -= 1
  y[i] -= 1

ans = min(a)+min(b)
for i in range(M):
  ans = min(ans, a[x[i]]+b[y[i]]-c[i])
print ans


Measured memory_bytes: 21644
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;(a)<=i;--i)
template<class T> class segtree{
	int n = 1;
	vector<T> dat;
	T def;
	function<T(T, T)> f1;
	function<void(T&, T)> f2;
public:
	segtree(const int& _n, function<T(T, T)> _f1, function<void(T&, T)> _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		while (n < _n)n <<= 1;
		dat.resize((n << 1) - 1, def);
	}
	segtree(const vector<T>& _dat, function<T(T, T)> _f1, function<void(T&, T)> _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		int _n = _dat.size();
		while (n < _n)n <<= 1;
		dat.resize((n << 1) - 1, def);
		FOR(i, 0, _n)dat[i + n - 1] = _dat[i];
		rFOR(i, 0, n - 1)dat[i] = f1(dat[(i << 1) + 1], dat[(i << 1) + 2]);
	}
	void update(int i, T a) {
		i += n - 1;
		f2(dat[i], a);
		while (0 < i) {
			--i >>= 1;
			dat[i] = f1(dat[(i << 1) + 1], dat[(i << 1) + 2]);
		}
	}
	T value(const int a, const int b, int l, int r, int k) {
		if (a <= l && r <= b)return dat[k];
		if (r <= a || b <= l)return def;
		T s = value(a, b, l, l + r >> 1, (k << 1) + 1);
		T t = value(a, b, l + r >> 1, r, (k << 1) + 2);
		return f1(s, t);
	}
	T value(const int a, const int b) { return value(a, b, 0, n, 0); }
};

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

	vector<int> a(n);
	FOR(i, 0, n)a[i] = 1 << (s[i] - 'a');
	segtree<int> seg(a,
		[](int a, int b) {return a | b; },
		[](int& a, int b) {a = b; });

	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c;
			seg.update(i - 1, 1 << (c - 'a'));
		}
		else {
			int l, r; cin >> l >> r;
			int b = seg.value(l - 1, r);
			int ans = 0;
			FOR(i, 0, 26)if (b & (1 << i))++ans;
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 6916
#define s(X,Y,Z)(t=X,X=Y,Y=t,p=Z?&X:&Y,*p^=127,a&7)
m,a,b,c,t,r,*p;main(n){while(scanf("%d",&n),n){for(r=1,a=49,b=42,c=35;n--;scanf(" %c%*s",&t),m=t-76,r+=m%6==0?s(c,b,m):1<m&m<8?s(b,a,m^7):s(c,a,m>0));printf("%d\n",r);}}

Measured memory_bytes: 0
def c_typical_stairs(N, M, A, MOD=10**9 + 7):
    a = set(A)
    stairs = [0] * (N + 100)
    stairs[0] = 1
    for i in range(N):
        if i + 1 <= N and (i + 1) not in a:
            stairs[i + 1] += stairs[i]
        if i + 2 <= N and (i + 2) not in a:
            stairs[i + 2] += stairs[i]
    return stairs[N] % MOD

N, M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]
print(c_typical_stairs(N, M, A))

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

using namespace std;


int main() 
{
    long long int x,ans;
    cin>>x;
    long long int h[100009],dp[100009];
    long long int i;
    for(i=1;i<=x;i++)
    {
        cin>>h[i];
        dp[i]=0;
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(i=3;i<=x;i++)
    {
        dp[i]=min(((abs(h[i]-h[i-1]))+dp[i-1]),((abs(h[i]-h[i-2]))+dp[i-2]));
    }
    ans=dp[x];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<cstdlib>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn=1e5+5;
int n,k;
ll a[maxn];
ll mp[maxn];

int main()
{
    int n;
    cin>>n;
    if(n==1) cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Dcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        public static void Method(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int q = int.Parse(s[2]);
            var ranges = new int[n,n];
            for (int i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split(' ');
                int l = int.Parse(s[0]) - 1;
                int r = int.Parse(s[1]) - 1;
                ranges[l, r]++;
            }
            var rangeSums = new int[n, n];
            for(int i = 0; i < n; i++)
            {
                //string ss = "";
                for(int j = i; j < n; j++)
                {
                    if (j == i)
                    {
                        rangeSums[i, j] = ranges[i, j];
                    }
                    else
                    {
                        rangeSums[i, j] = rangeSums[i, j - 1] + ranges[i, j];
                    }
                    //ss += rangeSums[i, j].ToString() + " ";
                }
                //Console.WriteLine(ss);
            }

            var questions = new int[q, 2];
            for (int i = 0; i < q; i++)
            {
                s = Console.ReadLine().Split(' ');
                questions[i, 0] = int.Parse(s[0]) - 1;
                questions[i, 1] = int.Parse(s[1]) - 1;
            }

            for (int i = 0; i < q; i++)
            {
                int cnt = 0;
                for (int j = questions[i, 0]; j <= questions[i, 1]; j++)
                {
                    cnt += rangeSums[j, questions[i, 1]];
                }
                Console.WriteLine(cnt);
            }

        }
    }
}

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

int main(void){
  string S,T;
  cin>>S;
  cin>>T;
  int acc=0;
  for(int i=0;i<3;i++){
    if(S[i]==T[i]){
      acc+=1;
    }
  }
  cout<<acc<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define PI acos(-1)
int a[1000008],b[1000008];
int main()
{
	double a,b,x,f;
	while(~scanf("%lf%lf%lf",&a,&b,&x)){
	if(x*2>a*b*a){
        f=a*b*a-x;
        f=(f*2)/(a*a*a);
	}
	else{
            f=(a*b*b)/(2*x);
	}
	f=atan(f);
	f*=180;
	f/=PI;
	printf("%.10lf\n",f);
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const ll mod = 1000000007;
using namespace std;

int H,W;
char G[1010][1010];
ll f[1010][1010];
ll sovle(){
    f[1][1] = 1;
    for(int i = 1;i<=H;i++){
        for(int j = 1;j<=W;j++){
            if(i == 1 && j == 1) continue;
            if(G[i][j] == '#') continue;
            f[i][j] = (f[i-1][j] + f[i][j-1]) %mod;
        }
    }
    return f[H][W];
}

int main(){
    // debug;
    ios;
    cin>>H>>W;
    for(int i = 1;i<=H;i++){
        for(int j = 1;j<=W;j++){
            cin>>G[i][j];
        }
    }
    cout<<sovle()<<'\n';



    
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define right sefudermano
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}



const int N = 500100;
const int M =1e9 + 7;
// long long?

ll fat[N],inv[N];
inline ll C(int n,int k){
  if(k>n)return 0;
  return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}
inline ll P(int n,int k){
  if(k>n)return 0;
  return mod(fat[n] * inv[n-k],M);
}
void init(){
  fat[0] = inv[0] = 1;
  for(int i=1;i<N;i++){
    fat[i] = (1LL*fat[i-1]*i)%M;
  }
  inv[N-1] = exp(fat[N-1],M-2,M);
  for(int i=N-2;i>=0;i--){
    inv[i] = (inv[i+1]*(i+1))%M;
  }
}
int32_t main(){
  fastio;
  int n,m;
  init();
  cin >> n >> m;
  ll res=0;
  for(int k=0;k<=n;k++){
    ll cur = C(n,k) * P(m,k) %M;
    cur = cur * mod(P(m-k,n-k) * P(m-k,n-k),M) %M ;
    //cout << k<<" "<<cur << endl;
    if(k&1)res=mod(res - cur,M);
    else res = mod(res + cur,M);
  }
    cout << res << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
} 

Measured memory_bytes: 11384
n = int(input())

def count(x):
    res = 0
    for i in range(1, x + 1):
        if x % i == 0:
            res += 1
    return res

res = 0
for x in range(1, n+1, 2):
    if count(x) == 8:
        res += 1

print(res)


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

int main(){
	int d, n, p, count = 0, ans = 0;
	cin >> d >> n;
	if(d == 0) p = 1;
	else if(d == 1) p = 100;
	else if(d == 2) p = 10000;
	while(1){
		count++;
		ans += p;
		if(d == 0 && ans % 100 == 0){
			count--;
		}else if(d == 1 && ans % 10000 == 0){
			count--;
		}else if(d == 2 && ans % 1000000 == 0){
			count--;
		}
		if(count == n) break;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
   int n;
   cin >> n;
   int sol = -1;
   for(int i =0; i < 50001; i++){
        if(floor((double)i * 1.08) == n){
            cout << i << endl;
            exit(0);
        }
   }
   cout << ":(" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <map>
#include <cassert>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,h,w;
  int x[LIMIT2]={0},y[LIMIT2]={0};
  ll xx,yy;
  ll hMax[2]={0},wMax[2]={0};
  vector<ll> hh,ww;
  string s;
  map<P,ll> dp;
  
  cin >> h >> w >> m;
  rep(i,m){
    cin >> xx >> yy;
    xx--;
    yy--;
    x[xx]++;
    y[yy]++;
    dp[{xx,yy}]+=1;
    if(hMax[0]<x[xx]){
      hMax[0] = x[xx];//0:Max, 1:Pointer
      hMax[1] = xx;
    }
    if(wMax[0]<y[yy]){
      wMax[0] = y[yy];
      wMax[1] = yy;
    }
  }
  rep(i,h){
    if(hMax[0]==x[i]) hh.push_back(i);
  }
  rep(i,w){
    if(wMax[0]==y[i]) ww.push_back(i);
  }
  rep(i,hh.size()){
    rep(j,ww.size()){
      if(!dp.count({hh[i],ww[j]})){//ダブりがないのがあった
        cout << hMax[0]+wMax[0] << endl;
        return 0;
      }
    }
  }

  result = hMax[0]+wMax[0]-(dp.count({hMax[1],wMax[1]}) ? dp[{hMax[1],wMax[1]}] : 0);//重複を除く
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 34304
N = gets.to_i
a = Array.new(10**6,0)
for x in 1..100
  for y in 1..100
    for z in 1..100
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      a[n] += 1
    end
  end
end
a.shift
a.each_with_index do |n,i|
  puts n if i <= N - 1
end


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

namespace ABC175
{

  class B
  {
  public:
    B() = default;
    ~B() = default;


    void Run()
    {
      int N = {};
      std::cin >> N;

      std::vector<long long> L = {};
      L.reserve(N);
      for (int i = 0; i < N; ++i)
      {
        long long l = 0;
        std::cin >> l;
        L.push_back(l);
      }

      std::sort(L.begin(), L.end());

      int A = 0;
      for (int i = 2; i < N; ++i)
      {
        long long Li = L[i];
        for (int j = 1; j < i; ++j)
        {
          long long Lj = L[j];
          for (int k = 0; k < j; ++k)
          {
            long long Lk = L[k];
            if (Li != Lj && Lj != Lk && (Li < Lj + Lk)) ++A;
          }
        }
      }

      std::cout << A << std::endl;
    }
  };

}

int main()
{

  ABC175::B prob;
  prob.Run();

  return 0;
}


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

int main(){
    int N ,L;
    cin >> N >> L;
    string S[N];
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    sort(S,S+N);
    string bb="";
    for(int i=0;i<N;i++){
        bb += S[i];
    }
    cout << bb << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;

ll dp[110][1000100];//n番目に入れた入れてない価値vのナップサック、中身はそれの最小の重さw

int main(){
  ll n,w;
  cin >> n >>w;
  ll wl[110],v[110];
  rep(i,n)cin >> wl[i] >> v[i];
  
  rep(i,110){
    rep(r,1000100){dp[i][r]=10000000000000;}
  }
  dp[0][0]=0;

  rep(i,n){
    rep(r,1000100){
      if(v[i]<=r){chmin(dp[i+1][r],dp[i][r-v[i]]+wl[i]);}
      chmin(dp[i+1][r],dp[i][r]);
    }
  }
  ll res=0;
  rep(i,1000100){
    if(dp[n][i]<=w)res=i;
  }

  cout << res << endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<std::vector<char>> a(n, std::vector<char>(n));
  std::cin >> a;

  std::set<int64_t> s;
  int64_t m = 0;
  std::vector<int64_t> p(n, 0);

  bool possible = false;

  for (int64_t i = 0; i < n; i++) {
    bool flag = false;
    for (int j = 0; j < n; j++) {
      if (!flag && a[j][i] == '.') {
        flag = true;
        m++;
      }
      if (a[i][j] == '#') {
        s.insert(j);
        possible = true;
      } else {
        p[i]++;
      }
    }
  }

  if (!possible) {
    std::cout << -1 << std::endl;
    return 0;
  }

  int64_t ans = 3 * n;

  for (int64_t i = 0; i < n; i++) {
    if (s.count(i) == 1) {
      ans = std::min(ans, m + p[i]);
    } else {
      ans = std::min(ans, m + p[i] + 1);
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 512
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		int n = scn.nextInt();
		long a[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scn.nextInt();

		}
		long sum[][]=new long[n][n];
		for(int i=0;i<n;i++){
			long s=0;
			for(int j=i;j<n;j++){
				sum[i][j]=a[j]+s;
				s+=a[j];
			}
		}
		
		long dp[][] = new long[n][n];
		for (int g = 0; g < n; g++) {
			for (int i = 0, j = i + g; j < n; j++, i++) {
				if (g == 0) {
					dp[i][j] = 0;
				} else if (g == 1) {
					dp[i][j] = a[i] + a[j];
				} else {
					long ans = Long.MAX_VALUE;
					
					for (int k = i; k <= j; k++) {
						if(k==i){
						ans=Math.min(ans, dp[k+1][j]+sum[k][j]);	
						}
						else  if(k==j){
							ans=Math.min(ans, dp[i][k-1]+sum[i][k]);	
						}
						else{
						ans = Math.min(ans,dp[i][k-1]+dp[k][j]+sum[i][j]);
						}
					}
					dp[i][j] = ans;
				}

			}
		}
		System.out.println(dp[0][n - 1]);

	}
}

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

int main(){
    
    int N;cin>>N;
    vector<int> sosuu;
    for(int i=3;i<=N;i++){
        for(int j=2;j<i;j++){
            if(i%j==0) break;
            if(j==i-1) sosuu.push_back(i);
        }
    }
    int M=sosuu.size(),ans=0;
    for(int i=0;i<M;i++){
        for(int j=i+1;j<M;j++){
            if(sosuu[i]*sosuu[i]*sosuu[i]*sosuu[j]<=N) ans++;
            if(sosuu[i]*sosuu[j]*sosuu[j]*sosuu[j]<=N) ans++;
        }
    }
    for(int i=0;i<M;i++){
        for(int j=i+1;j<M;j++){
            for(int l=j+1;l<M;l++){
                if(sosuu[i]*sosuu[j]*sosuu[l]<=N) ans++;
            }
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void)
{
 int a,b,i;

 scanf("%d%d",&a,&b);
 if(a>b){
 for(i=0;i<a;i++){
  printf("%d",b);
  }
 }
 else{
  for(i=0;i<b;i++){
  printf("%d",a);
  }
 }
  return 0;

}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define MAX 100000

typedef struct PP{
    char name[1000];
    int time;
}P;

void initialize();
void enqueue(P);
P dequeue();
int min(int, int);

P Q[MAX];
int head,tail;

int main()
{
    int elaps=0,c;
    int n,q,i;
    P u;
    initialize();
    scanf("%d%d",&n,&q);

    for(i=1;i<=n;i++)
    {
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].time);
    }
    head = 1;
    tail = n+1;
    
    while(head!=tail)
    {
        u = dequeue();
        c = min(q, u.time); //qまたは必要な時間u.timeを処理
        u.time -= c; //残りの必要な時間
        elaps += c;  //経過時間
        if(u.time > 0)
        {
            enqueue(u);
        }
        else
        {
            printf("%s %d\n",u.name, elaps);
        }
    }
    return 0;
}

void initialize()
{
    head = tail = 0;
}

void enqueue(P x)
{
    Q[tail] = x;
    if(tail+1==MAX)
    {
        tail = 0;
    }
    else tail++;
}

P dequeue()
{
    P tmp;
    tmp = Q[head];
    if(head+1==MAX)
    {
        head = 0;
    }
    else head++;
    return tmp;
}

int min(a, b)
{
    if(a>b) return b;
    if(a<=b) return a; 
    return 0;
}


Measured memory_bytes: 99828
#include <bits/stdc++.h>
#define N 1000010
#define mod 998244353
using namespace std;

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;
}
inline int qpow(int bas,int pw)
{
	int ret=1;
	for(;pw;pw>>=1,bas=1ll*bas*bas%mod)
		if(pw&1) ret=1ll*ret*bas%mod;
	return ret;
}
inline void Add(int &x,int y)
{
	x+=y; if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
int n,k,fac[N],inv[N],Ans;
inline int C(int x,int y)
{
	if(y<0||x<y) return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline int ways(int X,int Y,int T)
{
	if(T<=0) return 0;
	return C(X+Y,X)-C(X+Y,Y-T);
}
inline int calc(int R,int B)
{
	if(R<B) return 0;
	if(R==B) return ways(R,B-1,B-n+1);
	if(R>B) return ways(R,B,R-n+1);
	return 0;
}
int main()
{
	n=read(); k=read();
	fac[0]=1; for(int i=1;i<=N-10;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-10]=qpow(fac[N-10],mod-2);
	for(int i=N-11;i>=0;i--) 
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(int i=0;i<=k;i++) Add(Ans,calc(i,k-i));
	cout << Ans << endl; return 0;
}



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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
vector<ll> dp(50001, LONG_LONG_MAX);
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll n, m;
vector<ll> C;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  cin >> n >> m;
  C.resize(m);
  rep(i, m) cin >> C[i];
  dp[0] = 0;
  rep(i, n+1) {
    rep(j, m) {
      if (i >= C[j]) {
        if (dp[i] > dp[i-C[j]] + 1) {
          dp[i] = dp[i-C[j]] + 1;
        }
      }
    }
  }

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



Measured memory_bytes: 3260