akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,int> P;
typedef pair<ll,ll> p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

int dp[110000][2];

bool flag[110000];
int C[110000];

int main(){
    int N;
    ll T,A[110000];
    P S[110000],L[110000];
    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    S[0].first=A[0]; L[N-1].first=A[N-1];
    S[0].second=1; L[N-1].second=1;
    for(int i=1;i<N;i++){
        S[i].first=S[i-1].first;
        S[i].second=S[i-1].second;
        if(S[i].first==A[i]){
            S[i].second++;
        }else if(S[i].first>A[i]){
            S[i].first=A[i]; S[i].second=1;
        }

        L[N-1-i].first=L[N-i].first;
        L[N-1-i].second=L[N-i].second;
        if(L[N-1-i].first==A[N-1-i]){
            L[N-1-i].second++;
        }else if(L[N-i-1].first<A[N-1-i]){
            L[N-1-i].first=A[N-1-i]; L[N-1-i].second=1;
        }

    }
    ll ans=0;
    for(int i=0;i<N-1;i++){
        ans=max(ans,L[i+1].first-S[i].first);
        //cout<<S[i].first<<endl;
    }
    //cout<<ans<<endl;
    ll sum=0;
    map<p,int> B;
    for(int i=0;i<N-1;i++){
        if(ans==L[i+1].first-S[i].first){
            B[make_pair(S[i].first,L[i+1].first)]=max(B[make_pair(S[i].first,L[i+1].first)],min(S[i].second,L[i+1].second));
        }
    }
    map<p,int>::iterator it;

    for(it=B.begin();it!=B.end();it++){
        sum+=it->second;
    }
    cout<<sum<<endl;
}



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

int main() {
    int C; cin >> C;
    for (int CASE = 0; CASE < C; ++CASE) {
        string S, T; cin >> S >> T;
        int n = (int)T.size();
        reverse(S.begin(), S.end());
        for (auto c : S) {
            string nT = T;
            if (c == 'J') nT = "", nT += T.back(), nT += T.substr(0, n-1);
            else if (c == 'C') nT = T.substr(1) + T[0];
            else if (c == 'E') {
                for (int i = 0; i < n; ++i) {
                    if (i < n/2) nT[i] = T[i + (n+1)/2];
                    else if (i >= (n+1)/2) nT[i] = T[i - (n+1)/2];
                    else nT[i] = T[i];
                }
            }
            else if (c == 'A') {
                reverse(nT.begin(), nT.end());
            }
            else if (c == 'P') {
                for (int i = 0; i < n; ++i) {
                    if (T[i] >= '0' && T[i] <= '9') {
                        int val = T[i] - '0';
                        val = (val + 9) % 10;
                        nT[i] = '0' + val;
                    }
                    else nT[i] = T[i];
                }
            }
            else if (c == 'M') {
                for (int i = 0; i < n; ++i) {
                    if (T[i] >= '0' && T[i] <= '9') {
                        int val = T[i] - '0';
                        val = (val + 1) % 10;
                        nT[i] = '0' + val;
                    }
                    else nT[i] = T[i];
                }
            }
            T = nT;
        }
        cout << T << endl;
    }
}


Measured memory_bytes: 3016
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

int main() {
    int n;
    cin >> n;
    long a[n];
    long sum = 0, others=0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
        if (i%2) others += a[i];
    }
    long prev = sum - others*2;
    for (int i = 0; i < n - 1; i++) {
        cout << prev << ' ';
        prev = a[i] * 2 - prev;
    }
    cout << prev << '\n';
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
string f(int n)
{
    while(n)
    {
      if(n%10==7)
         return "Yes";
        n /=10;
    }
  return "No";
}
int main()
{
     int n;
  cin>>n;
  cout<<f(n)<<endl;
}

Measured memory_bytes: 3576
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    N = len(S)
    count = 0
    count_ = 0
    for i in range(N):
        if i % 2 == 0:
            if S[i] == '0':
                count += 1
            else:
                count_ += 1
        else:
            if S[i] == '1':
                count += 1
            else:
                count_ += 1
    if count < count_:
        print(N - count_)
    else:
        print(N - count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40944
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(map(str,list(sys.stdin.readline().split()))) for i in range(h)]

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    import collections
    import bisect
    n,m= map(int, sys.stdin.readline().split())
    c = [list(map(int,list(sys.stdin.readline().split()))) for i in range(m)]
    a = collections.defaultdict(list)#
    for x,y in sorted(c):#keyをx、valueをyに当たるものとして取り出す
        a[x] += [y]#[y]で一つのkeyに対して２つのvalueを入れられる。{1: [12, 32], 2: [63]}。a[x]でリストをkeyの数だけ作ってる。
    for x,y in c:#県と年数を一個ずつ取り出しす。
        z = bisect.bisect(a[x],y)#bisect(リスト,値)で値の挿入場所indexを返す。=認識番号を代替する。
        print("%06d%06d"%(x,z))#6桁に左詰め

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

#define inm (int)10e9
using namespace std;
int main()
{	
	int ans=0, i, j, k;
	int N, D;
	cin >> N >> D;

	ans += N / (D * 2 + 1);
	if(N % (D * 2 + 1))
		ans++;
	cout << ans << endl;
	
	return 0;
}

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

int main() {
	int n=0;
	int d[50];
	cin >> n;
	for (int i = 0; i < n; ++i ) {
		cin >> d[i];
	}
	
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			ans += (d[i] * d[j]);
		}
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#pragma warning(disable:4996);
using namespace std;

int main(void)
{
	int n, m, x;
	scanf("%d %d %d", &n, &m, &x);
	//n books,m skills,x level
	int i, j;
	int a[15][15] = {};
	int price[15] = {};
	for (i = 0; i < n; ++i)
	{
		scanf("%d", &price[i]);
		for (j = 0; j < m; ++j)
		{
			scanf("%d", &a[i][j]);
		}
	}
	int buy[15] = {};
	int all = 1 << n;
	int ans = 0x7ffffff;
	for (i = 1; i < all; ++i)
	{
		for (j = 0; j < n; ++j)
		{
			if ((1 << j) & i)
			{
				buy[j] = 1;
			}
			else
			{
				buy[j] = 0;
			}
		}
		int skill[15] = {};
		int pri = 0;
		for (j = 0; j < n; ++j)
		{
			if (buy[j])
			{
				pri += price[j];
				for (int k = 0; k < m; ++k)
				{
					skill[k] += a[j][k];
				}
			}
		}
			int check = 1;
			for (j = 0; j < m; ++j)
			{
				if (skill[j] < x)
				{
					check = 0;
					break;
				}
			}
			if (check)
			{
				if (pri < ans)
				{
					ans = pri;
				}
			}
	}
		if (ans == 0x7ffffff)
		{
			printf("-1");
		}
		else
		{
			printf("%d", ans);
		}
		return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int n, c[112345];
int ans;

int main()
{
	while (true)
	{
		n = 0;
		memset(c, 0, sizeof(c));
		ans = 0;

		in >> n;
		if (n == 0) { break; }
		rep(i, n) { in >> c[i]; }

		rep(i, n)
		{
			int j;
			for (j = i + 1; j < n; ++j)
			{
				if (c[i] != c[j])
				{
					if ((j + 1) % 2 == 0)
					{
						for (int k = j - 1; k >= 0; --k)
						{
							if (c[k] == c[j]) { break; }
							c[k] = c[j];
						}
					}
					else { --j; }
					break;
				}
			}
			i = j;
		}
		rep(i, n) { ans += (c[i] == 0 ? 1 : 0); }

		out << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3524
#include <stdio.h>
#define N 100

 int main(){
   int j,n,l,flag,count=0;

   scanf("%d",&n);

   int A[N];

   for(j=0 ; j<n ; j++){
     scanf("%d",&A[j]);
   }

flag = 1;

   while(flag){
     flag=0;
     for(j=0 ; j<n-1; j++){
       if(A[j]>A[j+1]){
      l=A[j];
      A[j]=A[j+1];
      A[j+1]=l;
      count++;
      flag=1;
    }
  }
}

for(j=0;j<n-1;j++){
    printf("%d ",A[j]);
}

  printf("%d",A[j]);
  printf("\n%d\n",count);
    return 0;
}



Measured memory_bytes: 2144
Q = gets.chomp.to_i
ls, rs = [], []
Q.times do |i|
    ls[i], rs[i] = gets.chomp.split.map(&:to_i)
end
min = ls.min
max = rs.max

is_prime = Array.new(max+1, true)
is_prime[0] = false
is_prime[1] = false

(2..max).each do |i|
    next unless is_prime[i]
    (2..(max/i)).each do |j|
        is_prime[i * j] = false
    end
end

# accum[i]: # of 2017-like num s.t. 1 <= p <= 2i+1
min_i = (ls.min - 1) / 2
max_i = (rs.max - 1) / 2
accum = Array.new(max_i + 1, 0)
(min_i..max_i).each do |i|
    num = 2 * i + 1
    if is_prime[num] && is_prime[(num+1)/2]
        accum[i] = accum[i - 1] + 1
    else
        accum[i] = accum[i - 1]
    end
end

Q.times do |i|
    li = (ls[i] - 1) / 2
    ri = (rs[i] - 1) / 2
    sum = accum[ri]
    sum -= li == 0 ? 0 : accum[li - 1]
    print sum, "\n"
end



Measured memory_bytes: 5104
#include<iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  cin>>H;

  for(int i=1;i<=H;i++) cin>>A[i];
  for(int i=H/2;i>=1;i--) maxHeapify(i);

  for(int i=1;i<=H;i++){
    cout<<" "<<A[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int count=0;
			int n=sc.nextInt();
			for(int a=0;a<10;a++){
				for(int b=0;b<10;b++){
					for(int c=0;c<10;c++){
						for(int d=0;d<10;d++){
							if(a+b+c+d==n)
								count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 17028
import collections

[n,m] = list(map(int, input().strip().split()))

graph = collections.defaultdict(set)
arr = list(map(int, input().strip().split()))

for i in range(m):
	[u, v] = list(map(int, input().strip().split()))
	
	graph[u].add(v)
	graph[v].add(u)
	
ans = 0
	
for i in range(1, n+1):
	ithDex = i-1
	isPossible = True
	
	for j in graph[i]:
		jthDex = j-1
		
		if arr[ithDex] <= arr[jthDex]:
			isPossible = False
			break
			
	ans += int(isPossible)
	
print(ans)

Measured memory_bytes: 51520
fun main(){
    val k = readLine()!!.toInt()
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    var f = false
    for (i in a until b + 1){
        if(i % k == 0){
            f = true
        }
    }
    if(f) println("OK") else println("NG")
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

const int MAX_N = (1<<18);

struct segtree{
    int n, dat[2*MAX_N-1]; //(1<<17) = 130000

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++) dat[i] = 0;
    }

    int search(int k){
        k += n-1;
        int ret = 0;
        ret += dat[k];
        while(k > 0){
            k = (k-1)/2;
            ret += dat[k];
        }
        return ret;
    }

    //(a,b,0,0,seg.n)で呼ぶ
    void add(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) {
            dat[k]++;
        } else{
            add(a,b,k*2+1,l,(l+r)/2);
            add(a,b,k*2+2,(l+r)/2,r);
        }
        return;
    }
} seg;

string s;
bool used[200000];
deque<int> deq[26];

int main(){
    cin >> s;
    while (true) {
        bool end = true;
        rep(i,26) deq[i].clear();
        rep(i,s.size()) {
            deq[(int)(s[i]-'a')].push_back(i);
        }
        bool ki = false;
        rep(i,26) {
            if (deq[i].size()%2 == 1) {
                if (ki) {
                    cout << -1 << endl;
                    return 0;
                }
                ki = true;
                if (deq[i][deq[i].size()/2] > s.size()/2) {
                    end = false;
                    reverse(s.begin(), s.end());
                    break;
                }
            }
        }
        if (end) break;
    }
    seg.init(s.size());
    ll ans = 0;
    int pos = 0;
    bool mid = false;
    for (int i = s.size()-1; i >= 0; i--) {
        if (used[i]) continue;
        if (mid) ans++;
        used[i] = true;
        int ind = s[i]-'a';
        deq[ind].pop_back();
        if (deq[ind].size() == 0) {
            mid = true;
            continue;
        }
        int x = deq[ind].front();
        deq[ind].pop_front();
        used[x] = true;
        int dis = seg.search(x)+x;
        ans += abs(dis-pos);
        seg.add(0,x,0,0,seg.n);
        pos++;
    }
    cout << ans << endl;
}
































Measured memory_bytes: 3588
#include <stdio.h>

int main(void) {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if(A>C)
	printf("%s", "NO");
	else
	{
	if(C-A>B)
	printf("%s", "NO");
	else
	printf("%s", "YES");
	}
	
	return 0;
}


Measured memory_bytes: 128
h, w = [int(x) for x in input().split()]
 
temp_list = []
flag = [False] * w
for _ in range(h):
    a = input()
    if "#" not in a:
        continue
    temp_list.append(a)
    for i in range(w):
        flag[i] = flag[i] or a[i] == "#"

for temp in temp_list:
    print("".join([temp[i] for i in range(w) if flag[i]]))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
n = int(input())
if n // 100 == 7:
    print("Yes")
    sys.exit()
n = n % 100
if n // 10 == 7:
    print("Yes")
    sys.exit()
n = n % 10
if n == 7:
    print("Yes")
    sys.exit()
print("No")


Measured memory_bytes: 9104
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    while(true) {
        auto n = readInt();
        if(n == 0) {
            return;
        }
        int[] t;
        int[] idx;
        foreach(i; iota(n)) {
            auto l = readInts();
            idx ~= l[0];
            int time;
            foreach(j; iota(4)) {
                time += l[2*j+1] * 60 + l[2*j+2];
            }
            t ~= time;
        }
        zip(t, idx).sort();
        writeln(idx[0]);
        writeln(idx[1]);
        writeln(idx[$-2]);
    }
}

Measured memory_bytes: 3464
#include<cstdio>

using namespace std;

int main(){
    int x;
    scanf("%d", &x);
    int ans = x;
    while (true){
        bool flag = true;
        for(int i = 2; i * i <= ans; i++){
            if (ans % i == 0){
                flag = false;
                break;
            }
        }
        if (flag) break;
        ans++;
    }
    printf("%d\n", ans);
}

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

int main() {
  int N,M;
  cin>>N>>M;
  if(N>=M){
    cout<<0<<endl;
    return 0;
  }
  vector<int> x(M);
  for(int j=0;j<M;j++){
    cin>>x[j];
  }
  sort(x.begin(),x.end());
  int all = x[M-1]-x[0];

  //cout<<all<<endl;
  vector<int> l(M-1);
  // 区間を求める
  for(int i=0;i<M-1;i++){
    l[i]= x[i+1]-x[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  //cout<<l[0]<<endl;
  // 駒が通らない区間を選ぶ
  // 区間をN分割→N-1個の切れ目（区間）
  // 切れ目（区間）の総和が最大→駒を動かす区間が最短
  int cutsum=0;
  for(int i=0;i<N-1;i++){
    cutsum += l[i];
  }

  cout<<all-cutsum<<endl;




}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define yes "YES"
#define no "NO"
#define rsort(a) sort(a.rbegin(),a.rend())
const int mod=1000000007;
//void dfs(int i);
long long modular_expo(long long x,long long y);

bool cmp(pair<double,int>p1,pair<double,int>p2)
{
    if(p1.first>p2.first)
        return true;
    else
    {
        if(p1.first<p2.first)
            return false;
        else if(p1.first==p2.first)
        {
            if(p1.second<p2.second)
                return true;
            else
                return false;
        }
    }
}
/*bool cmp1(map<int,int>a,map<int,int>b)
{
    if(a.first<b.first)
        return true;
    else
        return false;
}*/
//ll m;


/*
void bsf(int t)
{
    queue<int>q;
    visited[t]=true;
    q.push(t);
    while(!q.empty())
    {
        int temp=q.front();
        //cout<<temp<<" ";
        if(temp==n)
            {
                vector<int>ans;
    ans.pb(n);
        int tttt=n;
    for(int i=0;i<tttt;i++)
    {
        ans.pb(parent[n]);
        n=parent[n];
        if(n==1)
            break;
    }
    if(n!=1)
    {
        break;
    }
    cout<<ans.size()<<endl;
    for(int i=ans.size()-1;i>=0;i--)
        cout<<ans[i]<<" ";
        f=1;

            }
        q.pop();
        //cout<<temp<<" ";
        for(auto i=l[temp].begin();i!=l[temp].end();i++)
        {
            if(!visited[*i])
            {
                q.push(*i);
                parent[*i]=temp;
                visited[*i]=true;
            }
        }
    }
}
*/
long long modular_expo(long long x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return (modular_expo((x*x),y/2));
    if(y%2==1)
        return ((x)*modular_expo((x*x),(y-1)/2));


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

    int i,cnt=0;
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    if(s[0]=='R')
        a=1;
        if(s[1]=='R')
        b=1;
        if(s[2]=='R')
        c=1;
    if(a&&b&&c)
    {
        cout<<3<<endl;
    }
    else if(a&&b)
    {
        cout<<2;
    }
    else if(b&&c)
    {
        cout<<2;
    }
    else if(a||b||c)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0;
    }



}




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

int main(){
	int n;
	cin >> n;
	string str;
	cin >> str;
	str.push_back('*');
	int ans = 0;
	for (int i=0; i<n; i++){
		if(str[i+1] != str[i]) ans++;
	}
	cout << ans << endl;
}


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

int main()
{
    int n;
    cin>>n;
    vector<vector<int> > v( n , vector<int> (3,0));
    vector<vector<int> > values( n , vector<int> (3,0));
     
    for(int  i = 0; i < n; i++){
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    
    for(int i = 0; i < 3; i++){
        values[0][i] = v[0][i];
    }
    
    for(int i = 1; i <n; i++){
        for(int j = 0; j < 3; j++){
            if(j == 0) values[i][j] = max(v[i][j] + values[i - 1][1], v[i][j] + values[i - 1][2]);
            else if (j == 1) values[i][j] = max(v[i][j] + values[i - 1][0], v[i][j] + values[i - 1][2]);
            else values[i][j] = max(v[i][j] + values[i - 1][0], v[i][j] + values[i - 1][1]);
        }
    }
    
    int maximum = values[n - 1][0];
    if(maximum < values[n - 1][1]) maximum = values[n - 1][1];
    if(maximum < values[n - 1][2]) maximum = values[n - 1][2];
    cout<<maximum;
    return 0;
}


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

int main() {

  int N;
  cin >> N;

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

  // 2個を何通り作れるか
  map<int, long long> count;
  map<int, long long> count2;
  for (int i = 0; i < N; i++) {
    count2[A[i]]++;
    if (2 <= count2[A[i]]) {
      count[A[i]] = count2[A[i]] * (count2[A[i]] - 1) / 2;
    }
  }

  // 2個を何通り作れるかの合計
  long long counts = 0;
  for (auto item:count) {
    counts += item.second;
  }

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

    if (count2[A[i]] == 1) {
      cout << counts << endl;
    } else {
      long long c_ = counts;
      cout << counts - (count2[A[i]] - 1) << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 15360
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;

ll power(ll n, ll k, ll m) {
    ll ans = 1;
    while (k) {
        if (k & 1)ans = (ans * n) % m;
        k /= 2;
        n = (n * n) % m;
    }
    return ans;
}

int main() {
    IOS;
    
    
	
    ll T = 1; //cin >> T;
    while (T--) {
		ll n;cin>>n;
		string s;cin>>s;
		//sort(s.begin(),s.end());
		ll a1[n+1]={0};
		ll a2[n+1]={0};
		ll a3[n+1]={0};
		a1[0]=0;
		a2[0]=0;
		a3[0]=0;
		forn1(i,n+1){
			if(s[i-1]=='R')a1[i]=1+a1[i-1];
			else a1[i]=a1[i-1];
			if(s[i-1]=='G')a2[i]=1+a2[i-1];
			else a2[i]=a2[i-1];
			if(s[i-1]=='B')a3[i]=1+a3[i-1];
			else a3[i]=a3[i-1];
			
		}
		ll ans=0;
		forn1(i,n+1){
			for(ll j=i+1;j<=n;j++){
				set<char> se;
				se.insert(s[i-1]);
				se.insert(s[j-1]);
				if(se.size()!=2)continue;
				ll k=2*j-i;
				
				
				if(se.find('R')==se.end()){
					if(k>=(j+1) && k<=n && s[k-1]=='R'){ans--;}
					ans+=(a1[n]-a1[j]);
				}
				else if(se.find('G')==se.end()){
					if(k>=(j+1) && k<=n && s[k-1]=='G'){ans--;}
					ans+=(a2[n]-a2[j]);
				}
				else{
					if(k>=(j+1) && k<=n && s[k-1]=='B'){ans--;}
					ans+=(a3[n]-a3[j]);
				}
			}
		}
		
		cout<<ans<<endl;
		
		
		
    }
    return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;

ll fac[100010];

void factorial(){
    fac[0] = 1;
    rep(i,100000){
        fac[i+1] = fac[i] * (i+1) % MOD;
    }
}

int main(){
    int N; cin >> N;
    factorial();
    ll ans = fac[N];
    cout << ans << endl;
}



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

using namespace std;

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<int> d(m);
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        d[i] = ((x - p) + n) % n;
    }
    sort(d.begin(), d.end());

    int ret = min(d[m - 1], n - d[0]);
    for (int i = 0; i < m - 1; i++) {
        int a = d[i];
        int b = n - d[i + 1];
        ret = min(ret, min(a * 2 + b, a + b * 2));
    }

    cout << ret * 100 << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  vector<vector<int>> C(3, vector<int>(3));
  for (auto& r : C) {
    for (auto& c : r) {
      cin >> c;
    }
  }

  bool res = false;
  for (int a1 = -200; a1 <= 200; ++a1) {
    for (int a2 = -200; a2 <= 200; ++a2) {
      for (int a3 = -200; a3 <= 200; ++a3) {
        auto b1 = C[0][0] - a1;
        auto b2 = C[1][1] - a2;
        auto b3 = C[2][2] - a3;

        auto q11 = (a1 + b2) == C[0][1];
        auto q12 = (a1 + b3) == C[0][2];
        if (q11 && q12) {
          ;
        } else {
          continue;
        }
        auto q21 = (a2 + b1) == C[1][0];
        auto q22 = (a2 + b3) == C[1][2];
        if (q21 && q22) {
          ;
        } else {
          continue;
        }
        auto q31 = (a3 + b1) == C[2][0];
        auto q32 = (a3 + b2) == C[2][1];
        if (q31 && q32) {
          ;
        } else {
          continue;
        }
        res = true;
        // goto err;
      }
    }
  }
err:
  auto ans = res ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int M0 = (N-1)/2;
    vector<pair<int, int>> ans;
    if(N%2){
        for(int i=1; i<=M0; i++) ans.emplace_back(i, N-i);
    }else{
        for(int i=1; i<=M0; i++){
            if(i <= (M0+1)/2){
                ans.emplace_back(i, N-i+1);
            }else{
                ans.emplace_back(i, N-i);
            }
        }
    }

    for(int i=0; i<M; i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}


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

int main(){
	int n; cin >> n;
	vector<int> unpi;
	unpi.push_back(1);
	for (int i = 1; pow(6, i) <= n; ++i) unpi.push_back((int)pow(6, i));
	for (int i = 1; pow(9, i) <= n; ++i) unpi.push_back((int)pow(9, i));
	sort(unpi.begin(), unpi.end());
	vector<vector<int> > dp(n+1,vector<int>(unpi.size()));
	for (int i = 0; i < unpi.size(); ++i){
		for (int j = 0; j <= n; ++j){
			if (i == 0){
				dp[j][i] = j;
			}
			else{
				if (j - unpi[i] >= 0){
					dp[j][i] = min({ dp[j][i - 1], dp[j - unpi[i]][i - 1] + 1 ,dp[j-unpi[i]][i]+1});
				}
				else{
					dp[j][i] = dp[j][i - 1];
				}
			}
		}
	}
	cout << dp[n][unpi.size() - 1] << endl;
	//for (int i = 0; i < unpi.size(); ++i){
	//	cout << " " << unpi[i];
	//}cout << endl << endl;
	//for (int i = 0; i <= n; ++i){
	//	for (int j = 0; j < unpi.size(); ++j){
	//		cout <<" "<< dp[i][j];
	//	}cout << endl;
	//}
	return 0;
}

Measured memory_bytes: 8832
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N, ans = 500;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        int cnt = 0;
        while (a % 2 == 0) {
            cnt++;
            a /= 2;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin >> N;
    int ans = 0;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) {
            int power = 0;
            while (N % i == 0) {
                N /= i;
                ++power;
            }
            for (int j = 1; power >= j; ++j) {
                power -= j;
                ++ans;
            }
        }
    }
    if (N != 1) {
        ++ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>

using namespace std;

int n;
int digits[3];

void solve()
{
    for (int i = 0; i < 3; i++) {
        digits[i] = n%10;
        n /= 10;
    }

    if (digits[0] == digits[2]) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

int main()
{
    scanf("%d", &n);
    solve();
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	cin>>s;

	for (int i = 0; i < s.size()-1; ++i){
		if(s[i]=='A'&&s[i+1]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;

}

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

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> data(N, vector<int>(2));
 
  for (int i = 0; i < N; i++) {
    cin >> data.at(i).at(0) >> data.at(i).at(1);
  }
  
  int a_max = data.at(0).at(0) + data.at(0).at(1);
  int a_min = data.at(0).at(0) + data.at(0).at(1);
  for (int i = 1; i < N; i++){
    int temp = data.at(i).at(0) + data.at(i).at(1);
    a_max = max(a_max, temp);
    a_min = min(a_min, temp);
  }
  
  int b_max = data.at(0).at(0) - data.at(0).at(1);
  int b_min = data.at(0).at(0) - data.at(0).at(1);
  for (int i = 1; i < N; i++){
    int temp = data.at(i).at(0) - data.at(i).at(1);
    b_max = max(b_max, temp);
    b_min = min(b_min, temp);
  }
  
  cout << max(a_max - a_min , b_max - b_min) << endl;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS

ll  n,i,j,k,count=0,f=0,sum=0;
cin>>n;
ll a[n]={0};
for(i=0;i<n;i++)
{
    cin>>a[i];
}

for(i=0;i<n;i++)
{
    for(j=i+1;j<n;j++)
    {
        for(k=j+1;k<n;k++)
        {
            if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&a[k]+a[j]>a[i]&&a[i]+a[k]>a[j])
            {
                count++;
            }
        }
    }
}


cout<<count;





return 0;
}


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



int main(void)
{
    int a,b,t;
    cin >> a >> b >> t;

    int ans = 0;
    int time = a;
    while(time <= t) {
        ans += b;
        time += a;
    }

    cout << ans << endl;

    return 0;
}

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

#define int long long

map<int, int> mp;

std::vector<pair<int , int >> v;

int32_t main () {
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		int x; cin>>x;
		mp[x]++;
	}
	for(auto b : mp) {
		if(b.second/2 >0 ) v.push_back({b.first, b.second/2});
	}
	int one , two;
	if(v.empty()) {
		cout<<"0"<<endl;
	}
	else {
		one = v.back().first;
		if(v.back().second == 1) {
			v.pop_back();
		}
		if(v.empty()) {
			cout<<"0"<<endl;
		}
		else {
			cout<<v.back().first*one<<endl;
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
using namespace std;

int main(){
    int H,W;
    string str;
    cin >> H >> W;
    for(int i=0;i<H;i++){
        cin >> str;
        cout << str << endl;
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }

int n,a[N],k;

int can(int x)  {
	   int ct=0;	   
	   rep(i,0,n) {
		   ct+=(a[i]+x-1)/x-1;	       
		 }		 
		 return (ct<=k);	
	}
	
	
void solve() {
    cin>>n>>k;
    rep(i,0,n)
      cin>>a[i];
      
    
    int lo=0,hi=*max_element(a,a+n)+1;
    int ans=hi;
    
    while(hi-lo>1) {
		  int mid=(lo+hi)>>1;
		  
		  if(can(mid)) {
			    hi=mid;
			    ans=min(ans,hi); 
			  }
		  else
		    lo=mid;	  
		}
		
		cout<<ans<<endl;
      
	  
 }

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


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

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  int a,b;
  cin>>a>>b;
  int x=1,t=0;
  while(x<b) {
    x+=(a-1);
    t++;
  }
  cout<<t;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int m = Integer.parseInt(in[1]);

        List<Set<Integer>> light = new ArrayList<>();
        for(int i = 0; i < m; i++) {
            in = br.readLine().split(" ");
            int k = Integer.parseInt(in[0]);
            Set<Integer> set = new HashSet<>();
            for(int j = 0; j < k; j++) {
                set.add(Integer.parseInt(in[j + 1]) - 1);
            }
            light.add(set);
        }
        boolean[] p = new boolean[m];
        in = br.readLine().split(" ");
        for(int i = 0; i < m; i++) {
            p[i] = Integer.parseInt(in[i]) == 1;
        }

        int ans = 0;
        for(int i = 0; i < 1 << n; i++) {
            boolean[] odd = new boolean[m];
            for(int j = 0; j < n; j++) {
                if(((i >> j) & 1) == 1) {
                    for(int k = 0; k < m; k++) {
                        if(light.get(k).contains(j)) odd[k] = !odd[k];
                    }
                }
            }
            boolean flag = true;
            for(int j = 0; j < m; j++) {
                if(odd[j] != p[j]) {
                    flag = false;
                    break;
                }
            }
            if(flag) ans++;
        }

        System.out.println(ans);

        br.close();
    }
}

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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#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 = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int K;
ll C[2222][2222];
ll pw[2222];
ll f[2222][2222];
ll sum[2222][2222];

void solve(int casi){
	cin>>n>>K;
	C[0][0] = C[1][0] = C[1][1] = 1;
	for(int i = 2; i <= 2000; i++){
		C[i][0] = C[i][i] = 1;
		for(int j = 1; j < i; j++)
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	}
	pw[0] = 1;
	for(int i = 1; i <= 2000; i++){
		pw[i] = (2 * pw[i-1]) % MM;
	}
	ll ans = 0;//pw[n-K-1];
	f[0][0] = 1;
	for(int i = 0; i <= n; i++)
		sum[0][i] = 1;
	for(int i = 1; i < K; i++){
		for(int j = 0; j <= n - i; j++){
			f[i][j] = sum[i-1][j+1];
		}
		sum[i][0] = f[i][0];
		for(int j = 1; j <= n - i; j++)
			sum[i][j] = (sum[i][j-1] + f[i][j]) % MM;
	}
	for(int i = 0; i <= n - K; i++)
		ans = (ans + f[K-1][i]) % MM;
	cout<<((K!=n)?(ans * pw[n-K-1] % MM):ans)<<endl;
}

void printans(){

}


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




Measured memory_bytes: 70144
function main(input){
  input = input.split(' ');
  var r = parseInt(input[0],10);
  var g = parseInt(input[1],10);
  var b = parseInt(input[2],10);
  var num = (r * 100) + (g * 10) +  b;
  if(num % 4 === 0){
    console.log('YES');
  }else{
    console.log('NO');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29492
#include<bits/stdc++.h>
using namespace std;
//const unsigned long long mod=1000000007;arr[k]>=(arr[i]+arr[j])
int main(){
 int n;
 cin>>n;
 int ans=0;
  long long  arr[n+1];
  arr[0]=0;
 for(int i=1;i<=n;i++)
   cin>>arr[i];
   for(int i=1;i<=n-2;i++){
       for(int j=i+1;j<=n-1;j++){
           for(int k=j+1;k<=n;k++){
               long long l=max(arr[i],max(arr[j],arr[k]));
                long long s=(arr[i]+arr[j]+arr[k])-l;
               if(s>l&&(arr[i]!=arr[j]&&arr[k]!=arr[j]&&arr[k]!=arr[i])){
               ans++;
           }
           }
       }
   }
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = inf;

int n, q;
ll a[maxn], addValue[maxn], ans[maxn];
stack<ll> stk;

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

	cin >> n >> q;
	for (int i = 0; i < q; i++)
	{
		ll val;
		cin >> val;
		while (!stk.empty() && stk.top() > val)
			stk.pop();
		stk.push(val);
	}
	q = stk.size();
	
	int ind = 0;
	while (!stk.empty())
		a[ind++] = stk.top(), stk.pop();
	if (q == 0 || n < a[ind - 1])
		a[ind++] = n;
	reverse(a, a + ind);
	addValue[ind - 1] = 1;

	/*for (int i = 0; i < ind; i++)
		cerr << '_' << a[i];
	cerr << endl;*/

	for (int i = ind - 1; i >= 1; i--)
	{
		if (!addValue[i])
			continue;

		ll now = a[i], mlt = addValue[i];
		while (now > a[0])
		{
			int pos = lower_bound(a, a + ind, now) - a;
			//cerr << '@' << now << ' ' << mlt << ':' << a[pos] << '#' << (now / a[pos]) * mlt << endl;
			pos--;
			//cerr << '@' << now << ' ' << mlt << ':' << a[pos] << '#' << (now / a[pos]) * mlt << endl;
			addValue[pos] = (addValue[pos] + (now / a[pos]) * mlt % mod) % mod;
			now %= a[pos];
		}
		if (now == a[0])
			addValue[0] = (addValue[0] + mlt) % mod;
		else if (now)
		{
			//cerr << "ANS ADDED " << ' ' << now - 1 << ' ' << mlt << endl;
			ans[now - 1] = (ans[now - 1] + mlt) % mod;
		}
	}
	ans[a[0] - 1] = (ans[a[0] - 1] + addValue[0]);
	for (int i = n - 1; i >= 0; i--)
		ans[i] = (ans[i] + ans[i + 1]) % mod;
	for (int i = 0; i < n; i++)
		cout << ans[i] << endl;
}



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

long long n,a,m,b,qq,k;
string ss;
int main() {
    cin>>n>>k;
    long long l[n],l1[n];
    for (int i=0; i<=n; i++){
        l[i]=0;
        l1[i]=0;
    }
    for (int i=0; i<n; i++){
        cin>>l[i];
    }
    for (int i=1; i<n; i++){
        l1[i]=l1[i-1]+abs(l[i-1]-l[i]);
        for (int j=1; j<=min(i*1ll,k); j++){
            l1[i]=min(l1[i], l1[i-j]+abs(l[i-j]-l[i]));
        }
    }
    cout<<max(0*1ll,l1[n-1])<<endl;
}


Measured memory_bytes: 1792
n, a, b = map(int, input().split())
result = 0
if (b - a)%2 == 1:
    temp1 = a - 1
    temp2 = n - b
    work = temp1 if temp1 < temp2 else temp2
    if (b-a)//2 == 1:
        result = work
    else:
        result = work + 1 + (b-a-1)//2
else:
    result = (b - a) // 2
print(result)

Measured memory_bytes: 3060
const main = (arg) => {
    const [N,X,M] = arg.split(" ").map(Number)
    
    let tmp = [...new Array(M)].fill(0)
    let mods = [...new Array(M)].fill(0)
    tmp[0] = X
    mods[0] = X
    // console.log(tmp)
    let i=1, loopStart=0
    for(; i<M; i++) {
        tmp[i] = tmp[i-1]**2 % M
        if(mods[tmp[i]]!==0) {
            // loop detected
            loopStart = mods[tmp[i]]
            break
        } else {
            mods[tmp[i]] = i
        }
    }
    const loopEnd = i
    const loopNum = loopEnd-loopStart
    const loopCount = loopNum===0 ? 0 : Math.floor((N-loopStart)/(loopNum))
    // console.log(`i=${i}, loopStart=${loopStart}, loopEnd=${loopEnd}, loopCount=${loopCount}`)

    let ans = 0
    let sumOfLoop = 0
    for(i=loopStart; i<loopEnd; i++) {
        sumOfLoop += tmp[i]
    }
    ans += sumOfLoop*loopCount
    
    // console.log(`sumOfLoop=${sumOfLoop}`)

    // add first something before loop starts
    for(i=0; i<loopStart; i++) {
        ans += tmp[i]
    }

    // add last something after loop ends
    const restCount = loopNum===0 ? 0 : N-loopStart-(loopNum)*loopCount
    // console.log(`restCount=${restCount}`)
    
    let rest = 0
    for(i=loopStart; i<loopStart+restCount; i++) {
        rest += tmp[i]
    }
    // console.log(`rest=${rest}`)
    ans += rest
    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int h, w;
	cin >> h >> w;
	string s[100];
	rep(i, h) {
		cin >> s[i];
	}
	rep(i, h) {
		cout << s[i] << endl << s[i] << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;

    for(auto& c : in){
        if(c == '1') c = '9';
        else if(c == '9') c = '1';
    }

    cout << in << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
  
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();
        int count=0;
        int a=1,b;
        if(x>=3 && x<=10000){
            for(; count<x; count++){
                 b = a/10;
                    if(a%3==0){
                        sb.append(" ");
                        sb.append(a);
                    }else{
                        b = a;
                        while(b!=0){
                            if(b%10==3){
                                sb.append(" ");
                                sb.append(a);
                                break;
                            }
                            b /= 10;
                        }
                    }
                    a++;
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 25440