akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

class Shop{
  private:
  int value;
  int number;
  
  public:
  Shop(int value, int number): value(value), number(number){}
  int getValue(){
    return value;
  }
  int getNumber(){
    return number;
  }
  void buy(){
    number--;
  }
};

signed main(){
  int n, m;
  cin >> n >> m;

  vector<Shop*> shops;
  for(int i = 0; i < n; i++){
    int value, number;
    cin >> value >> number;
    shops.push_back(new Shop(value, number));
  }

  auto compere = [](Shop* a, Shop* b) -> bool{
    return a->getValue() < b->getValue();
  };

  sort(shops.begin(), shops.end(), compere);

  int itr = 0;
  long prise = 0;
  for(int i = 0; i < m; i++){
    shops[itr]->buy();
    prise += shops[itr]->getValue();
    if(shops[itr]->getNumber() <= 0)
      itr++;
  }
  cout << prise << endl;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> after(n+2, 0);
	for(int i=0; i<m; i++){
		int c,d;
		cin >> c >> d;
		after[c] = max(after[c], d);
	}
	int ans = 0;
	int farthest = 0;
	for(int i=0; i<=n; i++){
		farthest = max(farthest, after[i]);
		if(farthest > i){
			ans += 3;
		}else{
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}


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

long long gcd(long long a,long long b){ return b ? gcd(b,a%b) : a; } 
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
 
int main(){
    int A,B;
    cin >> A >> B;
    cout << lcm(A,B) << endl;

    return 0;
}

Measured memory_bytes: 256
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


template <typename integer>
int gcd(integer a, integer b) {
    return b ? gcd(b, a%b) : a;
}

template<typename integer>
integer lcm(integer a, integer b) {
    return (a * b) / gcd(a, b);
}


int main() {
    long long a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;   
    return 0;
}



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

int main() {
    string s, ss;
    long long num_A = 0, ans = 0;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'B' && s[i+1] == 'C') {
            ss += 'D';
            i++;
        } else {
            ss += s[i];
        }
    }
    for(int i = 0; i < ss.size(); ++i) {
        if(ss[i] == 'A') {
            num_A++;
        } else if(ss[i] == 'D') {
            ans += num_A;
        } else {
            num_A = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 776
module type Segtree = sig
    type s
    type t

    val create   : int -> t
    val of_array : s array -> t
    val set      : t -> int -> s -> unit
    val get      : t -> int -> s
    val prod     : t -> int -> int -> s
    val all_prod : t -> s
end

module type SegtreeParam = sig
    type t

    val op : t -> t -> t
    val e  : t
end 

module Segtree = struct
    module Make(STP: SegtreeParam) : Segtree with type s = STP.t = struct
        type t = int * int * int * STP.t array
        type s = STP.t

        let ceil_pow2 n =
            let rec loop x =
                if 1 lsl x < n then loop (x + 1) else x
            in
            loop 0

        let update d k =
            d.(k) <- STP.op d.(2 * k) d.(2 * k + 1)

        let of_array v =
            let n = Array.length v in
            let log = ceil_pow2 n in
            let size = 1 lsl log in
            let d = Array.make (2 * size) STP.e in
            for i = 0 to n - 1 do d.(size + i) <- v.(i) done;
            for i = size - 1 downto 1 do update d i done;
            n, size, log, d

        let create n =
            of_array (Array.make n STP.e)

        let set (n, size, log, d) p x =
            let p = p + size in
            d.(p) <- x;
            for i = 1 to log do update d (p lsr i) done

        let get (_, size, _, d) p = d.(p + size)

        let prod (n, size, log, d) l r =
            let rec loop l r sml smr =
                if l >= r then STP.op sml smr else
                    let sml, l = if l land 1 = 0 then sml, l else STP.op sml d.(l),     l + 1 in
                    let smr, r = if r land 1 = 0 then smr, r else STP.op d.(r - 1) smr, r - 1 in
                    loop (l lsr 1) (r lsr 1) sml smr
            in
            loop (l + size) (r + size) STP.e STP.e

        let all_prod (_, _, _, d) = d.(1)
    end
end;;
Scanf.scanf "%d %d" (fun n k ->
    let module ST = Segtree.Make (struct type t = int let op = max let e = 0 end) in

    let seg = ST.create 600001 in
    for i = 0 to n - 1 do
        Scanf.scanf " %d" (fun a ->
            let l = max 0 (a - k) in
            let r = min 600000 (a + k + 1) in
            let v = ST.prod seg l r in
            ST.set seg a (v + 1)
        )
    done;
    Printf.printf "%d\n" @@ ST.all_prod seg
)

Measured memory_bytes: 27368
#include <iostream>
#include <vector>
using namespace std;
#define endl '\n'

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double input1, input2 ,total=0,temp,count=0,i;
    vector<double> x;
    vector<double>::iterator iter;
    
    cin >> input1 >> input2;
    for (i = 0; i < input1;i++){
        cin >> temp;
        x.push_back(temp);
        total += temp;
    }
    double k = total/(4*input2);
    for (iter = x.begin(); iter != x.end();iter++){
        if(*iter >= k){
            count++;
        }
    }
    if(count>=input2){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

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

int main() {
	long long n;
	long long a, b;
	
	scanf("%lld %lld %lld", &n, &a, &b);
	
	long long sum = n/(a+b);
	sum *= a;
	n %= (a+b);
	
	if(n > a)
		sum += a;
	else
		sum += n;
		
	printf("%lld\n", sum);
	
	return 0;
}


Measured memory_bytes: 256
n　= gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i)
while true do
  as.sort!.reverse!
  min = as.min
  asm = as.map{|a| a % min == 0 ? a : a % min }
  break if as == asm
  as = asm
end
puts as.last


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string x;
    cin >> x;

    ll ans = 0;
    ll temp = 0;
    ll n = x.length();
    rep(i, n) {
        if (x[i] == 'S') {
            if (temp > 0) {
                ans += temp;
                temp = -1;
            } else {
                temp--;
            }
        }
        if (x[i] == 'T') {
            temp++;
        }
    }
    cout << ans * 2 << endl;
    return 0;
}



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

int main() {

  int n, m, l, i, j, k;
  long long A[100][100]={}, B[100][100]={}, C[100][100]={};
  //
  
  cin >> n >> m >> l;

  //???????????????
  for(i = 0; i < n; i++)
    for(j = 0; j < m; j++) cin >> A[i][j];
  for(i = 0; i < m; i++)
    for(j = 0; j < l; j++) cin >> B[i][j];

  //???????¨????
  for(i = 0; i < n; i++)
    for(j = 0; j < l; j++)
      for(k = 0; k < m; k++) C[i][j] += A[i][k] * B[k][j];

  for(i = 0; i < n; i++){
    for(j = 0; j < l; j++){
      if( j ) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 1404
#include<stdio.h>
int main(){
  int i,r=0,a=0;
  char s[100010],d[100010];
  scanf("%s",s);
  for(i=0;s[i];i++){
    if(r&&d[r-1]-s[i]){
      a+=2;
      r--;
    }
    else d[r++]=s[i];
  }
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 384
s = int(input())
MOD = 10 ** 9 + 7
ans = 0
fact = [0] * 10000
fact[0], fact[1] = 1, 1
for i in range(2, 10000):
    fact[i] = (fact[i-1] * i) % MOD

def f(n, r):
    return fact[n] * pow(fact[n-r], -1, MOD) * pow(fact[r], -1, MOD)

for i in range(1, s//3+1):
    if i == 1:
        ans += 1
    else:
        m = s - i * 3
        ans += f(m+i-1, m)
        ans %= MOD
print(ans%MOD)

Measured memory_bytes: 9400
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# 集合[a1, a2...an]内で以下２つの条件を満たす部分集合の組(T, U)はいくつあるか問題
# 1: U ⊆ Tである
# 2: Uがある条件を満たす

# Tの中にUがいくつか含まれる
# ①iが進むごとにTの候補がn倍ずつ増えていく
# ②その後、Uを組むためのカウントを進める

''' ABC104 D - We Love ABC
S = '????C?????B??????A???????'
N = len(S)
# dp[i][j]: i番目にjまで丸をつけ終えている通り
dp = [[0] * 4 for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    # 通りの数を増やす
    for j in range(4):
        if S[i] != '?':
            dp[i + 1][j] += dp[i][j]
            dp[i + 1][j] %= mod
        else:
            dp[i + 1][j] += 3 * dp[i][j]
            dp[i + 1][j] %= mod
    # カウントが進むものを加える
    if S[i] == 'A' or S[i] == '?':
        dp[i + 1][1] += dp[i][0]
        dp[i + 1][1] %= mod
    if S[i] == 'B' or S[i] == '?':
        dp[i + 1][2] += dp[i][1]
        dp[i + 1][2] %= mod
    if S[i] == 'C' or S[i] == '?':
        dp[i + 1][3] += dp[i][2]
        dp[i + 1][3] %= mod
print(dp[N][3] % mod)
'''

# ABC169 F - Knapsack for All Subsets
N, S = getNM()
A = getList()
MOD = 998244353

dp = [[0] * (S + 1) for i in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    # 通りの数を増やす
    for j in range(S + 1):
        dp[i + 1][j] += dp[i][j] * 2
        dp[i + 1][j] %= MOD
    # カウントが進むものを加える
    for j in range(S + 1):
        if j - A[i] >= 0:
            dp[i + 1][j] += dp[i][j - A[i]]
            dp[i + 1][j] %= MOD
print(dp[N][S] % MOD)

Measured memory_bytes: 152452
#include<iostream>
#include<algorithm>
using namespace std;
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for(int i = (a); i >=(b); --i)
typedef long long ll;
const ll limit=1e6;

ll a[limit],b[limit];
ll ans=0,res=0,sum=0;
ll n,m;

int main()
{
    cin >> n >> m;
    For(i, 1, m){
        cin >> a[i];
        sum += a[i];
    }
    res = n - sum;
    if(res < 0){
        cout << - 1;
        return 0;
    }
    cout << res;
}
    

Measured memory_bytes: 3672
N=int(input())
matrix=[[-1 for _ in range(N+1)] for _ in range(N+1)]
for i in range(1, N+1):
    Ai=int(input())
    for j in range(Ai):
        x, y=map(int, input().split())
        matrix[i][x]=y
ans=0
for i in range(1, 2**N):
    honests=[]
    tmp=i
    j=1
    while tmp>0:
        if tmp%2==1:
            honests.append(j)
        tmp=tmp//2
        j+=1
    flag=True
    for j in honests:
        for k in range(1, N+1):
            if (matrix[j][k]==1 and k not in honests) or (matrix[j][k]==0 and k in honests):
                flag=False
                break
        if not flag:
            break
    if flag:
        ans=max(ans, len(honests))
print(ans)

Measured memory_bytes: 46060
import datetime

H1,M1,H2,M2,K=map(int,input().split())

GetUpTime=datetime.datetime(2020, 5, 30, H1, M1)
GoToBedTime=datetime.datetime(2020, 5, 30, H2, M2)

DayTime=GoToBedTime-GetUpTime

TimeRange = int(DayTime.seconds)/60 - K
print(int(TimeRange))

Measured memory_bytes: 9440
#include <stdio.h>
int main() {
	int k,a,b,flag = 0;
	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	
	for (int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			flag = 1;
			break;
		}
	}
	
	flag ? printf("OK\n") : printf("NG\n");
	return 0;
}


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

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    long long int N,M;
    COMinit();
    cin >> N >> M;
    cout << COM(N,2) + COM(M,2) << endl;
}

Measured memory_bytes: 12288
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
   vector<int> menu(5);
  vector<int> dev(5);
  int ans=0;
  rep(i,0,5) cin>>menu[i];
  rep(i,0,5){
    dev[i]=10-menu[i]%10;
    if(dev[i]==10) dev[i]=0;
  }
  sort(dev.begin(),dev.end());
  rep(i,0,5) ans+=menu[i]+dev[i];
  cout<<ans-dev[4];



}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int N; cin >> N;
	vector<long long> A(N + 1);
	rep(i, N + 1)cin >> A[i];
	vector<long long> B(N);
	rep(i, N)cin >> B[i];

	long long ans = 0;
	rep(i, N) {
		ans += min(A[i] + A[i + 1], B[i]);
		A[i + 1] -= max(B[i] - A[i], 0LL);
		if (A[i + 1] < 0)A[i + 1] = 0;
		A[i] = max(A[i] - B[i], 0LL);
	}
	cout << ans;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int i = 0, len = s.length(), count = 0;
        while (i < len) {
            if (s.charAt(i) != t.charAt(i)) {
                count++;
            }
            i++;
        }
        System.out.println(count);
    }
}

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

int main()
{
	int N,a[100];

	cin >> N;

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

	sort(a, a+N, greater<int>());

	int j=1;
	for(i=0;i<N-1;i+=j)
	{
		j=1;
		while(a[i] == a[i+j])
		{
			a[i+j] = 0;
			j++;
			if(i+j == N) break;
		}

	}

	int count=0;
	for(i=0;i<N;i++)
	{
		if(a[i]>0)
		{
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
bool field[100][100];
int n,m;
int func(int x,int y,int cnt){
    if(x < 0 || y < 0 || field[y][x] == 0 || x >= n || y >= m)return cnt-1;
    field[y][x] = 0;
    int ret = max(max(func(x,y-1,cnt+1),func(x+1,y,cnt+1)),max(func(x,y+1,cnt+1),func(x-1,y,cnt+1)));
    field[y][x] = 1;
    return ret;
}
int main(){
	while(cin >> n >> m,n,m){
	    memset(field,0,sizeof(field));
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                cin >> field[i][j];
            }
        }
        int ans = -1;
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                ans = max(ans,func(j,i,1));
            }
        }
        cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	using P = pair<int, int>;
	vector<P> a, b;
	a.emplace_back(0, 0);
	b.emplace_back(0, 0);
	rep(i, 0, N / 2) {
		int n = a.size();
		rep(j, 0, n) {
			a.emplace_back(a[j].first + w[i], a[j].second + v[i]);
		}
	}
	rep(i, N / 2, N) {
		int n = b.size();
		rep(j, 0, n) {
			b.emplace_back(b[j].first + w[i], b[j].second + v[i]);
		}
	}
	sort(all(a));
	sort(all(b));
	rep(i, 0, b.size() - 1) {
		chmax(b[i + 1].second, b[i].second);
	}
	dump(a, b);
	int ans = 0;
	for (auto &e : a) {
		if (W - e.first <= 0)continue;
		P p{ W - e.first,INF };
		auto l = lower_bound(all(b), p);
		chmax(ans, e.second + (*(l - 1)).second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 43776
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <chrono>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s, t;
    cin >> s >> t;

    cout << t << s << endl;
    return 0;
}


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

int main()
{
	int n,a,b,s1=0,s2=0,c,d;
	cin>>n>>a>>b;
	
	for(int i=1;i<=n;i++)
	{
		d=i;
		s1=0;
		while(d!=0){
			c=d%10;
			s1+=c;
			d/=10;
		}
		if(s1>=a && s1<=b) s2+=i;
	}
	
	cout<<s2;
	return 0;
}

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

int main(){
	long long f[200005]={0},a[200005],n,i,ans=0;
	cin>>n;
	for(i=0;i<n;i++) {
		cin>>a[i];
		f[a[i]]++;
	}
	for(i=1;i<=200005;i++) {
		if(f[i]>=2) ans+=((f[i]*(f[i]-1))/2);
	}
	for(i=0;i<n;i++) {
		if(f[a[i]]>=2)
			cout<<ans-((f[a[i]]*(f[a[i]]-1))/2)+(((f[a[i]]-1)*(f[a[i]]-2))/2)<<"\n";
		else cout<<ans<<"\n";
	}
}





Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
from pprint import pprint
import itertools
N, M = map(int, input().split())
xyzn = [list(map(int, input().split())) for _ in range(N)]

ans = []
ope = [1,-1]
for sx, sy, sz in itertools.product(ope, repeat=3):
    xyzn.sort(key=lambda x:-(sx*x[0]+sy*x[1]+sz*x[2]))
    ans.append(sum([sx*x+sy*y+sz*z for x,y,z in xyzn[:M]]))

print(max(ans))


Measured memory_bytes: 42096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
int dp[3002][3002];

int main()
{
    string s,t,r;
    int i,j,k,x,y;
    cin>>s>>t;
    x=s.length();
    y=t.length();
    fo(i,1,x+1)
    {
        fo(j,1,y+1)
        {
            if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    r="";
    i=x; j=y; k=dp[x][y];
    while(k>0)
    {
        if(s[i-1]==t[j-1]) {
            r+=s[i-1];
            i--; j--; k--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(r.begin(),r.end());
    cout<<r<<endl;

}


Measured memory_bytes: 35456
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int H, W;
vector<vector<char>> S;
vector<vector<int>> d;

void warshall_floyd(int n) {			// nは頂点数
	for (int i = 0; i < n; i++)			// 経由する頂点
		for (int j = 0; j < n; j++)		// 開始頂点
			for (int k = 0; k < n; k++) // 終端
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	cin >> H >> W;
	S.resize(H);
	for (auto &&s : S) {
		s.resize(W);
	}

	for (size_t i = 0; i < H; i++) {
		for (size_t j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	int n = H * W;
	d = vector<vector<int>>(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				d[i][j] = 0;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		int y = i / W;
		int x = i % W;
		if (S[y][x] == '.') {
			if (y > 0) {
				if (S[y - 1][x] == '.') {
					d[i][i - W] = 1;
				}
			}
			if (x > 0) {
				if (S[y][x - 1] == '.') {
					d[i][i - 1] = 1;
				}
			}
			if (y < H - 1) {
				if (S[y + 1][x] == '.') {
					d[i][i + W] = 1;
				}
			}
			if (x < W - 1) {
				if (S[y][x + 1] == '.') {
					d[i][i + 1] = 1;
				}
			}
		}
	}

	warshall_floyd(n);
	int max_d = -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j && d[i][j] != INF) {
				max_d = max(max_d, d[i][j]);
			}
		}
	}
	cout << max_d << endl;

	return 0;
}

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

int main()
{
	long long n, k, x, y,res=0;
	cin >> n >> k >> x >> y;

	if (n - k > 0) {
		res = (n - k)*y;
		res += k*x;
	}
	else 
		res = n*x;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
// ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,sum,a,b,c,d,e,h,q,p;
ll w, ans;
ll k;
ll x[500005], y[500005], z[500005];
string s, t;

void solve(){
    cin >> n;
    p((n / 500) * 1000 + ((n % 500) / 5) * 5);
    return;
}

int main(){
    // init();
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    ll q;
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        solve();
    }
    return 0;

}


















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

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

	long long int ans=0;

	long long int p1 = n*(n-1)/2;
	long long int p2 = m*(m-1)/2;

	ans=p1+p2;

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int a[]=new int[5];
    for(int s=0;s<5;s++){
      a[s]=sc.nextInt();
    }
    int count=0;
    int k=sc.nextInt();
    for(int s=0;s<4;s++){
      for(int l=s+1;l<5;l++){
        if(a[l]-a[s]>k){
          count++;
        }
      }
    }
    if(count>0){
      System.out.println(":(");
    }else{
      System.out.println("Yay!");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	vector<Int> b(n+1);
	for(auto i:a) ++b[i];
	Int s = 0;
	for(auto i:b) s += i * (i-1) / 2;
	for(auto i:a) cout << s - b[i] * (b[i]-1) / 2 + (b[i]-1) * (b[i]-2) / 2 << "\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B, long long K){
  ll rA=max(0LL,A-K);
  ll rB=max(0LL,min(B,B-(K-A)));
  cout<<rA<<" "<<rB<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc157/submissions/10442571
class UnionFind
  #attr_accessor :parent, :size
  def initialize(n)
    @parent = Array.new(n)
    @size = Array.new(n)
    n.times do |i|
      @parent[i] = i
      @size[i] = 1
    end
  end
  
  def root(x)
    if @parent[x] == x
      return x 
    else
      return @parent[x] = root(@parent[x])
    end
  end
  
  def unite(x,y)
    x, y = root(x), root(y)
    return if x == y
    x, y = y, x if @size[x] < @size[y]
    @size[x] += @size[y]
    @parent[y] = x
  end
  
  def same(x, y)
    root(x) == root(y)
  end
  
  def size(x)
    @size[root(x)]
  end
end

N, M, K = gets.split.map(&:to_i)
uf = UnionFind.new(N)
friendCnt = Array.new(N, 0)
blockCnt = Array.new(N, 0)
M.times do
  a, b = gets.split.map{|x| x.to_i - 1}
  uf.unite(a, b)
  friendCnt[a] += 1
  friendCnt[b] += 1
end
K.times do
  c, d = gets.split.map{|x| x.to_i - 1}
  if uf.same(c, d)
    blockCnt[c] += 1
    blockCnt[d] += 1
  end
end
 
ans = Array.new(N, 0)
N.times { |i| ans[i] = uf.size(i) - friendCnt[i] - blockCnt[i] - 1 }
puts ans.join(" ")

Measured memory_bytes: 8188
def Sieve_of_Eratosthenes(N,mode=False):
    """Nまでのエラトステネスの篩を実行

    N:自然数
    mode:False->素数のリスト,True->素数かどうかのリスト
    (False->[2,3,5,...],True->[False,False,True,True,False,True,...])
    """

    T=[True]*(N+1)
    T[0]=T[1]=0
    a=2
    while a*a<=N:
        if T[a]:
            b=a*a
            while b<=N:
                T[b]=False
                b+=a
        a+=1

    if mode:
        return T
    else:
        return [k for k in range(N+1) if T[k]]
#=====================================================
N_max=10**5
Q=int(input())

P=Sieve_of_Eratosthenes(N_max,True)
Y=[0]*(N_max+1)
for a in range(1,N_max+1):
    Y[a]=Y[a-1]+((a%2==1) and P[a] and P[(a+1)//2])

X=[0]*Q
for k in range(Q):
    l,r=map(int,input().split())
    X[k]=Y[r]-Y[l-1]

print("\n".join(map(str,X)))

Measured memory_bytes: 84444
N=int(input())
Slist=list()
Plist=list()
tmp=list()
for i in range(N):
    S,P=input().split()
    Slist.append(S)
    Plist.append(int(P))
    tmp.append(int(P))
change = True
while change:
    change = False
    for i in range(len(Plist) - 1):
        if Plist[i] < Plist[i + 1]:
            Plist[i], Plist[i + 1] = Plist[i + 1], Plist[i]
            Slist[i], Slist[i + 1] = Slist[i + 1], Slist[i]
            change = True
change = True
while change:
    change = False
    for i in range(len(Slist) - 1):
        if Slist[i] > Slist[i + 1]:
            Slist[i], Slist[i + 1] = Slist[i + 1], Slist[i]
            Plist[i], Plist[i + 1] = Plist[i + 1], Plist[i]
            change = True
ans=list()
for i in range(N):
    ans.append(tmp.index(Plist[i]))
for i in range(N):
    print(ans[i]+1)


Measured memory_bytes: 3064
n,y = map(int,input().split())
 
price = 0
ok = 0

n_1 = range(n+1)
 
for i in n_1:
    for j in range(n+1-i):
            k = n - i - j
            if k < 0:
                k = 0
 
            price = 10000 * i + 5000 * j + 1000 * k   
            
            if price == y and i+j+k == n and ok == 0:
                print(i, j, k)
                ok = 1
                break
 
    else:
        continue
    break
 
if ok == 0:
    print(-1, -1, -1 )

Measured memory_bytes: 3064
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=""

for i in range(4):
    if i==2:
        ans+="L"
        dx+=1
        dy+=1
    elif i==3:
        ans+="DR"
    if dy>=0:
        ans+="U"*dy
        dy=dy*(-1)
    else:
        ans+="D"*(dy*(-1))
        dy=dy*(-1)
    if dx>=0:
        ans+="R"*dx
        dx=dx*(-1)
    else:
        ans+="L"*(dx*(-1))
        dx=dx*(-1)
ans+="U"
print(ans)

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as M
import Data.List
 
main = do
  [n, k] <- map read . words <$> getLine
  as <- B.words <$> B.getLine
  let dict = mkDict as
  print $ solve k dict
 
mkDict = foldr (\x y -> M.insertWith (+) x 1 y) M.empty
 
solve k dict = sum . drop k . sortOn negate $ M.elems dict

Measured memory_bytes: 55932
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <complex>
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef vector<vector<string> > vss;
typedef pair<int, int> pii;
#define INF 0x7fffffff
//#define INFLL 0x7fffffffffffffff
#define INFLL LLONG_MAX
#define SIZE(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
#define FOR(i,x) for(int i=0;i<x;i++)
#define FORic(i,y,x) for(int i=y;i<=x;i++)
#define FORdc(i,y,x) for(int i=y;i>=x;i--)
#define FILL(a,v) memset(a, v, sizeof(a))
#define PI 3.14159265358979323846

const double EPS = 1e-7;
typedef complex<double> P; /* _ */
struct L {                 /* üª */
	double angle; // deleteSameLineðgpµÈ¢Àèsv
	P p, q;
	L(P p, P q) : p(p), q(q), angle(arg(q-p)) {}
	bool operator < (const L &l) const {  // deleteSameLineðgpµÈ¢Àèsv
		return angle < l.angle;
    }
};
typedef vector<P> G;


// complexÉå¬ÖWªKvÈê
bool operator < (const P &a, const P &b) {
	return make_pair(real(a),imag(a)) < make_pair(real(b),imag(b));
}

// àÏEOÏEpx(xNga,bÌZ)
double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }
double angle(P a, P b) { return arg(conj(a)*b); }

// _pÆ_qÌ¼ñªüðÔ·
L pointBisector(P p, P q) {
	P cen = (p+q)*0.5;
	return L(cen, cen+(q-p)*P(0,1));
}

// Ê½p`gðC2_p, qðÔüªÅØf·é
G convexCut(G g, P p, P q){
	G res;
	int n = g.size();
	for(int i=0;i<n;i++){
		P A(g[i]), B(g[(i+1)%n]);
		double p1 = cross(q-p,A-p);
		double p2 = cross(q-p,B-p);
		if(p1 > -EPS) res.push_back(A);
		if(p1*p2 < -EPS)
			res.push_back(A+cross(q-p,q-A)/cross(q-p,B-A)*(B-A));
	}
	return res;
}

// ½p`gÌÊÏðßé
double polygonArea(G g){
	double res = 0.0;
	for(int i=0;i<g.size();i++)
		res += cross(g[i],g[(i+1)%g.size()]);
	return abs(0.5*res);
}

int main(){
	int n, m;
	while(cin>>n>>m){
		if(!n&&!m) break;
		G island;
		vector<P> cas;
		FOR(i, n){
			int a, b;
			cin>>a>>b;
			island.push_back(P(a,b));
		}
		FOR(i, m){
			int a, b;
			cin>>a>>b;
			cas.push_back(P(a,b));
		}
		FOR(i, m){
			G temp = island;
			FOR(j, m){
				if(j==i) continue;
				L nitou = pointBisector(cas[i],cas[j]);
				if(cross(nitou.q-nitou.p, cas[i]-nitou.p)>0){
					temp = convexCut(temp, nitou.p, nitou.q);
				} else {
					temp = convexCut(temp, nitou.q, nitou.p);
				}
			}
			double s = polygonArea(temp);
			printf("%.6f\n", s);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b;cin>>a>>b;
    if(a%2==1 && b%2==1)cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 256
#coding: UTF-8

def Circle(W,H,x,y,r):
    if x <= W - r and x >= r and y <= H-r and y >= r:
        return "Yes"
    else:
        return "No"

if __name__=="__main__":
    a = input().split(" ")
    ans = Circle(int(a[0]),int(a[1]),int(a[2]),int(a[3]),int(a[4]))
    print(ans)

Measured memory_bytes: 7708
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;

    vector<int> res;
    int i = n;
    while (i > 0) {
        bool ok = false;
        for (int j = m; j > 0; j--) {
            if (i-j >= 0 && s[i-j] == '0') {
                ok = true;
                i -= j;
                res.push_back(j);
                break;
            }
        }
        if (!ok) {
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(all(res));
    for (auto &x: res) cout << x << " ";
}


Measured memory_bytes: 3944
a = gets.split.map(&:to_i)
a.sort!
cnt = 0
if (a[2] - a[1]) % 2 == 0
    cnt += (a[2] - a[1]) / 2
else
    cnt += (a[2]- a[1]) / 2 + 1
    a[0] += 1
end
if(a[2] - a[0]) %2 == 0
    cnt += (a[2] - a[0]) / 2
else
    cnt += (a[2] - a[0]) / 2
    cnt += 2
end
puts cnt

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

#define ll long long
#define db double
#define pb push_back
#define mk make_pair
ll a[5][105],cu[2][105];
int main()
{
    ll i,j,k,n,m;
    cin>>m;
    for(i=0; i<2; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }
    cu[1][m-1]=a[1][m-1];
    for(j=m-2; j>=0; j--)
    {
        cu[1][j]=cu[1][j+1]+a[1][j];
    }
    cu[0][0]=a[0][0];
    for(j=1;j<m;j++)
    {
        cu[0][j]=cu[0][j-1]+a[0][j];
    }
    ll mxx=0;
    for(i=0; i<m; i++)
    {
        mxx=max(mxx,cu[0][i]+cu[1][i]);
    }
    cout<<mxx<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;
ll L[123];

int main() {

	cin >> N;
	rep(i, N) cin >> L[i];
	sort(L, L + N);

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int k = j + 1; k < N; ++k) {
				if (L[i] != L[j] && L[j] != L[k])
					if (L[i] + L[j] > L[k]) ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;


struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;

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


int N;
vector<bool> arr(mod,true);
void Eratosthenes(int N){
  arr[0] = false;
  arr[1] = false;
  for(int i=2; i*i<=N; i++){
    if(arr[i]){
      for(int j=2; i*j<=N; j++){
        arr[i*j] = false;
      }
    }
  }
}


int main(){
  int N;
  cin >> N;
  Eratosthenes(N);
  vector<int> P;
  for(int i=1; i<=N; i++){
    int count = 0;
    if(arr[i]){
      for(int j=1; j<=N; j++){
        int k=j;
        while(k%i == 0){
          count++;
          k = (k/i);
        }
      }
      P.push_back(count);
    }
  }
  ll ans=1;
  for(int p: P){
    ans = (ans*(p+1)%mod)%mod;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n, r = 0, g = 0, b = 0, c;
  string s;
  cin >> n >> s;
  REP(i, n) {
    if (s[i] == 'R') r++;
    else if (s[i] == 'G') g++;
    else  b++;
  }

  c = r * g * b;

  REP(i, n) FOR(j, i + 1, n) {
    ll k = 2 * j - i;
    if (k >= n || s[i] == s[j] || s[i] == s[k] || s[j] == s[k]) continue;
    c--;
  }

  OUT(c);

  return 0;
}

Measured memory_bytes: 3656
n = int(input())
i1 = list(map(int, input().split()))
i2 = list(map(int, input().split()))

max = 0
for i in range(1,n+1):
  tempmax = 0
  tempmax += sum(i1[:i])
  tempmax += sum(i2[i-1:])
  
  if tempmax > max:
    max = tempmax
    
print(max)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector< pair <int,pair <int,int> > > n;
  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      n.push_back(make_pair(i*i+j*j,make_pair(i,j)));
    }
  }
  sort(n.begin(),n.end());
  int h,w;
  while(cin>>h>>w,h){
    for(int i=0;i<n.size();i++){
      if(h*h+w*w==n[i].first&&h==n[i].second.first&&n[i].second.second){
	cout<<n[i+1].second.first<<" "<<n[i+1].second.second<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3212
def main():
    N=int(input())
    A=[int(n) for n in input().split()]
    p = 1
    ov = False
    for i in range(N):
        if not ov:
            np = p * A[i]
        if np > 10**18:
            ov = True
        if A[i] == 0:
            print(0)
            return
        p = np
    if ov:
        print(-1)
    else:
        print(np)
main()

Measured memory_bytes: 21828
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, n, a[102] = {}, b, y = 328, z = 0;
    cin >> x >> n;
    for (int i = 0; i < n; i++) cin >> b, a[b] = 1;
    for (int i = 0; i < 102; i++) {
        if (!a[i]) {
            if (abs(x - i) < y) y = abs(x - i), z = i;
        }
    }
    cout << z;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

const int maxn = 29;

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

	int n, m, c, b[maxn], a[maxn][maxn];
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		if (sum + c > 0) cnt++;
	}
	cout << cnt << '\n';



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)





int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int count = 0;
    for (int i = l; i < r+1; i++) {
        if (i % d == 0) {
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

 int imos[100010];

int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int l,r;
    cin >> l >> r;
    r++;
    imos[l]++,imos[r]--;
  }
  rep(i,100010) imos[i+1]+=imos[i];
  int ans=0;
  rep(i,100010) if(imos[i]==m) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
def factorial(n):
  ans = 1
  for i in range(n):
    ans *= i+1
    ans %= mod
  return ans

n,m = map(int, input().split())
mod = 10**9 + 7
diff = abs(n-m)
if diff == 0:
  print((((factorial(n)**2)%mod)*2)%mod)
elif diff == 1:
  print((factorial(n)*factorial(m))%mod)
else:
  print(0)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	long long int a,b,c;
	scanf("%lld %lld",&a,&b);
	if(a<=5)
	{
		c=0;
	}
	else if(a>=6 && a<=12)
	{
		c=b/2;
	}
	else if(a>=13)
	{
		c=b;
	}
	printf("%lld",c);
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

  string s;
  int index = 0, ci = 0;
  int ans = 0;
  int c[2000000];

int main(){

  cin >> s;
  while(index < s.length()){
    for(int i = 0; i < 3; i++){
      char ct;
      if(i == 0)
	ct = 'J';
      else if(i == 1)
	ct = 'O';
      else if(i == 2)
 	ct = 'I';
      int cnt;
      for(cnt = 0; ct == s[index + cnt]; cnt++);
      index += cnt;
      c[ci] = cnt;
      ci++;
    }
  }
  //Oを探索
  for(int i = 1; i < ci; i += 3){
    int oi = c[i];
    int ji = c[i - 1];
    int ii = c[i + 1];
    if(oi > ji || oi > ii)
      continue;
    else if(ans < oi)
      ans = oi;
  }

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

Measured memory_bytes: 8252