akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int p,q,r; cin>>p>>q>>r;
  int ans = 10000;
  if (ans > p+q) ans = p+q;
  if (ans > p+r) ans = p+r;
  if (ans > q+r) ans = q+r;
  cout << ans << endl;
}


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

using namespace std;

const int maxn = 1000 + 10;

int mp[maxn][maxn], a[maxn * maxn];

int main(){
    ios_base::sync_with_stdio(false);
    int h, w, n;
    cin>>h>>w>>n;
    for(int i = 1; i <= n; i++) cin>>a[i];
    int row = 1, col = 1, cur = 1;
    bool flag = 1;
    while(cur <= n){
        while(a[cur] == 0 && cur <= n) cur++;
        if(cur > n) break;
        mp[row][col] = cur;
        if(flag) col++;
        else col--;
        a[cur]--;
        if(col > w || col < 1){
            row++;
            col = col > w ? w : 1;
            flag = !flag;
        }
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(j != 1) cout<<" ";
            cout<<mp[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<vector>
//#include<queue>
//#include<sstream>
//#include<cmath>
//#include<set>
//#include<algorithm>
//#include<map>
#define mp make_pair
#define pii pair<int,int>
#pragma GCC optimize ("O3")
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 2e5+9;
const double pi=acos(-1.0);
const int inf = 1e9+9;
const int mod = 10007;
ll op[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<n;++i) cin>>op[i];
    sort(op,op+n);
    ll ans=op[n-1],la=n-2;
    for(int i=n-2;i>=0;--i){
        ans+=op[i]*min(la,2ll);
        la-=min(la,2ll);
        if(!la) break;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5220
n, y = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i)
            print(j)
            print(n - i - j)
            exit(0)
print(-1)
print(-1)
print(-1)


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

int n, k, ans;
int main()
{
    int i;
    cin >> n >> k;
    ans = k;
    for (i = 2; i <= n; i++) {
        ans *= (k - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
//const int 1001001001;
const int NMAX=8;
const ll MOD=1000000007;
const ll INF=1e18;
const int mod = 998244353;

int main(){
	ll k,q;
	cin>>k>>q;
	vector<ll> d(k);
	rep(i,k)cin>>d[i];
	rep(i,q){
		ll n1,x1,m1;
		cin>>n1>>x1>>m1;
		vector<ll> d1(k);
		ll sumd=0;
		ll sum0=0;

		vector<ll> d0(k,0);
		rep(i,k){
			d1[i]=d[i]%m1;
			sumd+=d1[i];
			if (d1[i]==0){
				d0[i]=1;
				sum0++;
			}
		}
		ll tot=n1-1;
		ll s=(n1-1)/k;
		ll a=(n1-1)%k;
		ll cnt=0;
		cnt+=s*sumd;
		rep(i,a){
			cnt+=d1[i];
		}
		cnt+=x1%m1;
		tot-=cnt/m1;
		//ここまでで繰り上がり処理、以下d=0のもの
		ll cnt0=0;
		cnt0+=sum0*s;
		rep(i,a){
			cnt0+=d0[i];
		}
		tot-=cnt0;
		cout<<tot<<endl;
	//	cout<<cnt<<'c'<<sum0<<'s'<<tot<<endl;

	}

}


Measured memory_bytes: 384
//A
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int M, d;
bool used[102];
int main() {
    M = read(), d = read(); int ans = 0;
    for (reg int m = 1; m <= M; m++) {
        memset(used, 0, sizeof(used));
        for (int i = 2; i <= sqrt(m); i++) {
            if (m % i == 0) {
                if (i + 10 * (m / i) <= d && i < 10 && (m / i) < 10) used[i + 10 * (m / i)] = true;
                if (m / i + 10 * i <= d && i < 10 && (m / i) < 10) used[m / i + 10 * i] = true;
            }
        }
        for (reg int i = 1; i <= d; i++) ans += used[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.mini = [i for i in range(n+1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        mini = min(self.mini[x],self.mini[y])
        self.mini[x]=mini
        self.mini[y]=mini
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

def main():
    N ,M = ints_raw()
    days = [0]*M
    uft = UnionFind(M)
    ABs = [ints_raw() for _ in range(N)]
    ABs.sort(key=lambda x:x[1],reverse=True)
    ans = 0
    for AB in ABs:
        A,B = AB
        if A > M:
            continue
        else:
            C = M-A
            par = uft.mini[uft.find(C)]

            if days[par] == 0:
                days[par]=1
                ans += B
                #uft.union(par,C)
                if par > 0:
                    uft.union(par-1,par)

            #while days[C]==1 and C>=0:
            #    C-=1
            #if C>=0:
            #    days[C]=1
            #    ans+=B
    return ans

    
print(main())


Measured memory_bytes: 108336
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;


void solve()
{
     float A,B,S;
 
    cin>>A;
    cin>>B;
    S=(B-1)/(A-1);
    float result=ceil(S);
    cout<<result;
    
}

int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3728
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		int cnt = 0;
		String cf2016 = "CODEFESTIVAL2016";
		String s;
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		for (int i = 0; i < cf2016.length(); ++i) {
			if(s.charAt(i) != cf2016.charAt(i)){
				++cnt;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        long sum = 0;
        for (int i = 1; i < n; i++) {
            if (array[i] > array[i - 1]) {
                continue;
            }

            sum += array[i - 1] - array[i];
            array[i] = array[i - 1];
        }
        System.out.println(sum);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 54752
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stack>
using namespace std;

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

    int q, k, sum = 0;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> k;
        // lower_bound
        if (*lower_bound(a, a + n, k) == k) sum++;
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

int main(){
  int n,c;
  cin >> n >> c;
  int p,sum=0;
  for(int i=0;i<c;++i){
    cin >> p;
    sum += p;
  }
  int moood=0;
  if(sum%(n+1)!=0) moood =1;
  cout << sum/(n+1) + moood << endl;
  
  
  return 0;
}




Measured memory_bytes: 3084
import numpy as np

def run():
  A = [list(map(int, input().split())) for n in range(3)]
  A = np.array(A)
  N = int(input())
  for n in range(N):
    b = int(input())
    for i in range(3):
      for j in range(3):
        a = A[i][j]
        if a == b:
          A[i][j] = 0
  ans = 1
  left = 0
  right = 0
  for i in range(3):
    ans = min(ans, np.sum(A, axis=0)[i])
    ans = min(ans, np.sum(A, axis=1)[i])
    left += A[i][i]
    right += A[i][2-i]
  ans = min(ans, left, right)
  if ans == 0:
    print('Yes')
  else:
    print('No')
    

if __name__ == '__main__':
  run()


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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (n == 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = n;
    if(s[0] == 'L') ans--;
    if(s[n-1] == 'R') ans--;
    rep(i, n - 1){
        if(s[i] == 'R' && s[i + 1] == 'L') ans-=2;
    }
    ans += 2 * k;
    if(ans >= n - 1) ans = n - 1;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> rui(n);
    rui[0] = 0;
    for (int i = 1; i < n; i++) {
      if (s[i-1] == 'A' && s[i] == 'C') rui[i] = rui[i-1] + 1;
      else rui[i] = rui[i-1];
    }
    rep(i,q) {
      int l, r;
      cin >> l >> r;
      l--; r--;
      int ans = rui[r]-rui[l];
      cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3792
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int[] a = new int[N]; 
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
 
    sc.close();

    int answer = 2001000;

    for (int i = -100; i <= 100; i++) {
      
      int cost = 0;
      
      for (int j = 0; j < N; j++) {
        cost += Math.pow(Math.abs(i - a[j]),2);
      }

      answer = Math.min(answer, cost);

    }

    System.out.println(answer);

  }

}

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

int m, n;
int cnt[20];
bool used[20];
std::vector<int> v[20];

int main()
{
	std::cin >> m >> n;
	for( int i = 0; i != n; ++i )
	{
		int x, y;
		std::cin >> x >> y;
		++cnt[y-1];
		v[x-1].push_back( y - 1 );
	}

	for( int i = 0; i != m - 1; ++i )
	{
		int idx;
		for( idx = 0; idx != m; ++idx )
			if( !used[idx] && !cnt[idx] )
				break;

		std::cout << idx + 1 << std::endl;

		used[idx] = true;
		for( int j = 0; j != v[idx].size(); ++j )
			--cnt[v[idx][j]];
	}

	std::cout << 2 << std::endl;

	return 0;
}

Measured memory_bytes: 1216
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    ll ans = 0, cnt = n - 2;
    ans = a[0];
    for(int i = 1; i < n; i++)
    {
        if(!cnt)
            break;
        ans += a[i];
        cnt--;
        if(cnt)
        {
            ans += a[i];
            cnt--;
        }
        //cout << cnt << " " << ans << endl;
    }
    cout << ans << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    double w,h,x,y;
    cin >> w >> h >> x >> y;

    double ans = w*h/2;

    if (2*x==w && 2*y==h) {
        cout << fixed << setprecision(10) << ans << " " << 1 << endl;
    }
    else {
        cout << fixed << setprecision(10) << ans << " " << 0 << endl;
    }

}





Measured memory_bytes: 256
#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>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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 argc, char const *argv[]) {
  string s;
  cin >> s;
  if (s[sz(s) - 1] == 's') cout << s + "es" << endl;
  else
    cout << s + "s" << endl;
  return 0;
}

Measured memory_bytes: 3540
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
	int a, b;
	cin >> a >> b;
	int c = a * b;
	if (c % 2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;

}



Measured memory_bytes: 256
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
#define debug(x) cout << #x << " => " << x << endl
typedef long long ll;
typedef long double ld;
const ll oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
//const int _p = 1007;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

int n,a[300005]; 
ll S=0,s[300005],ans=oo*oo;

int main() {
    //file_put();
    
    scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	for (int i=1; i<=n; i++) {
		S+=a[i];
		s[i]=S;
	}
	for (int i=1; i<=n-1; i++) ans=min(ans,abs(s[i]-(S-s[i])));
	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2560
def mod_inverse(x, mod):
    return pow(x, mod - 2, mod)


# return nCk % mod
# it takes O(k)
def mod_comb(n, k, mod):
    numer, denom = 1, 1
    for i in range(k):
        numer = numer * ((n - i) % mod) % mod
        denom = denom * ((i + 1) % mod) % mod

    return numer * mod_inverse(denom, mod) % mod


mod = 10**9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n, mod) - 1
ans = (ans - mod_comb(n, a, mod)) % mod
ans = (ans - mod_comb(n, b, mod)) % mod
ans = (ans + mod) % mod

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

char ring[100][11];
char str[11];
int num;

int ringstr(int n, int m)
{
	int i;
	int flag;
	int len;
	
	len = strlen(str);
	flag = 1;
	for (i = 0; i < len; i++){
		if (ring[n][m] != str[i]){
			flag = 0;
			break;
		}
		if (m == 9){
			m = 0;
		}
		else {
			m++;
		}
	}
	
	return (flag);
}

int main(void)
{
	int i, j;
	int count;
	
	scanf("%s", str);
	scanf("%d", &num);
	
	for (i = 0; i < num; i++){
		scanf("%s", ring[i]);
	}
	
	count = 0;
	for (i = 0; i < num; i++){
		for (j = 0; j < 10; j++){
			if (str[0] == ring[i][j] && ringstr(i, j)){
				count++;
				break;
			}
		}
	}
	
	printf("%d\n", count);
	
	return (0);
}

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

int main(){
  int h;//高さ
  int w;//横
  int k;//最後の個数
  char field[6][6];
  for(int i = 0;i < 6;i++){
    for(int j = 0;j < 6;j++){
      field[i][j] = '.';
    }
  }

  scanf("%d %d %d",&h,&w,&k);
  for(int i = 0;i < h;i++){
    scanf("%s",*&field[i]);
  }
  int count = 0;
  int h_max = pow(2,h) - 1;
  int w_max = pow(2,w) - 1;
  int b_count;
  char d_field[6][6];
  for(int i = 0;i < h_max;i++){
    for(int j = 0;j < w_max;j++){
      for(int di = 0;di < 6;di++){
        for(int dj = 0;dj < 6;dj++){
          d_field[di][dj] = field[di][dj];
        }
      }
      int ni = i;
      int nj = j;
      for(int li = 0;li < h + 1;li++){
        if(ni % 2 == 1){
          for(int ri = 0;ri < w;ri++){
            d_field[h - 1 - li][ri] = 'r';
          }
        }
        ni = ni / 2;
      }
      for(int lj = 0;lj < w + 1;lj++){
        if(nj % 2 == 1){
          for(int rj = 0;rj < h;rj++){
            d_field[rj][w - 1 - lj] = 'r';
          }
        }
        nj = nj / 2;
      }
      b_count = 0;
      for(int bi = 0;bi < h;bi++){
        for(int bj = 0;bj < w;bj++){
          if(d_field[bi][bj] == '#'){
            b_count++;
          }
        }
      }
      if(b_count == k){
        count++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 2596
#include<iostream>

#define MAX 10000
#define NIL -1

using namespace std;

int n;
struct Node {int p, l, r;};
struct Node T[MAX];

void preParse (int u) {

    if (u == NIL) {
        return ;
    }

    cout << " " << u;

    preParse (T[u].l);
    preParse (T[u].r);

}

void inParse (int u) {

    if (u == NIL) {
        return ;
    }

    inParse (T[u].l);

    cout << " " << u;

    inParse (T[u].r);

}

void postParse (int u) {

    if (u == NIL) {
        return ;
    }

    postParse (T[u].l);
    postParse (T[u].r);

    cout << " " << u;


}

int main () {

    int i, v, l, r, root;

    cin >> n;
    for (i = 0; i < n; i++) {
        T[i].p = NIL;
    }

    for (i = 0; i < n; i++) {
        cin >> v >> l >> r;

        T[v].l = l;
        T[v].r = r;

        if (l != NIL) {
            T[l].p = v;
        }
        if (r != NIL) {
            T[r].p = v;
        }

    }

    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) {
            root = i;
        }
    }

    cout << "Preorder" << endl;
    preParse (root);
    cout << endl;

    cout << "Inorder" << endl;
    inParse (root);
    cout << endl;

    cout << "Postorder" << endl;
    postParse (root);
    cout << endl;

    return 0;

}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long K, std::vector<long long> t, std::vector<long long> d){
  vector<vector<long long>> V(N, vector<long long>());
  vector<long long> top;
  vector<long long> rest;
  for (int i = 0; i < N; ++i) {
    V[t[i]-1].push_back(d[i]);
  }
  for (int i = 0; i < N; ++i) {
    if (V[i].size() > 0) {
      sort(V[i].begin(), V[i].end());
      top.push_back(V[i].back());
      for (int j = 0; j < V[i].size()-1; ++j) {
        rest.push_back(V[i][j]);
      }
    }
  }
  sort(top.begin(), top.end());
  sort(rest.begin(), rest.end());
  vector<long long> cumtop(top.size()+1, 0LL);
  vector<long long> cumrest(rest.size()+1, 0LL);
  for (int i = 0; i < top.size(); ++i) {
    cumtop[i+1] = cumtop[i] + top[i];
  }
  for (int i = 0; i < rest.size(); ++i) {
    cumrest[i+1] = cumrest[i] + rest[i];
  }
  long long ret = 0;
  long long max_t = static_cast<long long>(top.size());
  long long max_r = static_cast<long long>(rest.size());
  long long tmp;
  for (long long i = 0; i <= min(max_t, K); ++i) {
    tmp = i*i;
    tmp += cumtop.back() - cumtop[max_t-i];
    if (max_r-(K-i) < 0) continue;
    tmp += cumrest.back() - cumrest[max_r-(K-i)];
    ret = max(ret, tmp);
  }
  std::cout << ret << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> t(N);
  std::vector<long long> d(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&t[i]);
    scanf("%lld",&d[i]);
  }
  solve(N, K, std::move(t), std::move(d));
  return 0;
}


Measured memory_bytes: 8948
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}
func lcm(a, b int64) int64 {
	return a * b / (gcd(a, b))
}

func main() {
	scanner := makeScanner(1024)
	abcd := eGetInts(scanner)
	a, b, c, d := abcd[0], abcd[1], abcd[2], abcd[3]

	countc := (b / c) - ((a - 1) / c)
	countd := (b / d) - ((a - 1) / d)

	l := lcm(c, d)
	countl := (b / l) - ((a - 1) / l)
	fmt.Println((b - a + 1) - countc - countd + countl)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

// func eGetInt(r *bufio.Scanner) int {
// 	line := eGetLine(r)
// 	return eAtoi(line)
// }
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long dp[2020][2020];
int main() {
	int n; cin >> n;
	int a[n]; for (int &i : a) cin >> i;
	int p[n]; iota(p, p + n, 0);
	sort(p, p + n, [&] (int x, int y) {
		return a[x] > a[y];
	});
	for (int i = 0; i < n; i++) {
		for (int j = 0; j + i < n; j++) {
			int k = i + j;
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 1LL * a[p[k]] * abs(p[k] - i));
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + 1LL * a[p[k]] * abs(p[k] - (n - 1 - j)));
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) 
		ans = max(ans, dp[i][n - i]);
	cout << ans;
}

Measured memory_bytes: 26324
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll total = 1000000000LL;
    for(int i = 0;i<=100000;i++) {
         ll temp = 2*c*i+max(0LL,(x-i))*a+max(0LL,(y-i))*b; 
         total = min(total,temp);
    }
    cout << total << endl;
}


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

int main() {
  int sum = 0;
  int n;
  cin >> n;
  int y[n];
  for ( int i = 0; i < n; i++ ) { cin >> y[i]; }
  for ( int i = 0; i < n; i++ ) {
    for ( int j = i+1; j < n; j++ ) {
      sum += y[i]*y[j];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void)
{
    int s;
    scanf("%d", &s);
 
    int index = 1;
    if (3 <= s){
        while(1){
        if (s == 4) break;
        index++;
        if (s%2 == 0) s /= 2;
        else s = 3*s + 1;
        }
    }
    else index = 1;
    printf("%d\n", index+3);
    return 0;
} 

Measured memory_bytes: 128
def main():
    n = int(input())
    As = list(map(int, input().split()))
    As_Count = [0] * (10**5+1)
    q = int(input())
    bcs = [list(map(int, input().split())) for _ in range(q)]
    for A in As:
        As_Count[A] += 1
    ans = sum(As)
    for b, c in bcs:
        ans -= As_Count[b] * b
        ans += c * As_Count[b]
        As_Count[c] += As_Count[b]
        As_Count[b] = 0
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32668
N, H, W = [int(i) for i in input().strip().split()]
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = [int(j) for j in input().strip().split()]
num = 0
    
for i in range(N):
    if (A[i] >= H) and (B[i] >= W):
        num += 1
print(num)

Measured memory_bytes: 3064
// 2020-08-30 20:18:19
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int MX = 200020;
void answer() {
  int n, cz;
  cin >> n >> cz;
  vector<int> s(n), t(n), c(n);
  rep(i, n) cin >> s[i] >> t[i] >> c[i];
  vector<int> sum(MX + 10, 0);
  REPC(ci, 1, cz) {
    vector<int> u(MX + 10, 0);
    rep(i, n) if (c[i] == ci) {
      u[s[i] * 2 - 1]++;
      u[t[i] * 2]--;
    }
    rep(i, MX) u[i + 1] += u[i];
    rep(i, MX) sum[i] += (u[i] > 0);
  }
  int ans = 0;
  rep(i, MX) chmax(ans, sum[i]);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6112
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  if(s=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}


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

using namespace std;

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long ans = a * c;
	ans = max(ans,a*c);
	ans = max(ans, a*d);
	ans = max(ans, b*c);
	ans = max(ans, b*d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<set>
#include<iostream>
#include<string>

using namespace std;

int N;
string s;
set<string> set_;

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> s;
        set_.insert(s);
    }
    cout << set_.size();
	return 0;
}

Measured memory_bytes: 19260
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    if (n % i == 0) {
      if ((n / i) <= 9) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    vector<vector<int>> grid(3,vector<int>(3));
    rep(i,3){
        rep(j,3) cin>>grid.at(i).at(j);
    }
    rep(i,2){
        int a=grid.at(i+1).at(0)-grid.at(i).at(0),b=grid.at(i+1).at(1)-grid.at(i).at(1),c=grid.at(i+1).at(2)-grid.at(i).at(2);
        if(!(a==b and b==c)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(j,2){
        int a=grid.at(0).at(j+1)-grid.at(0).at(j),b=grid.at(1).at(j+1)-grid.at(1).at(j),c=grid.at(2).at(j+1)-grid.at(2).at(j);
        if(!(a==b and b==c)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import sys
s=input()
#check for 'xx' type substring
flag=False
ans=[]
for i in range(len(s)):
  if i+1<len(s) and (s[i]==s[i+1]):
    ans=[i,i+1]
    flag=True
    break
if flag:
  print(ans[0]+1,ans[1]+1)
  sys.exit()
for i in range(len(s)):
  if i+2<len(s) and (s[i]==s[i+2]):
    ans=[i,i+2]
    flag=True
    break
print(ans[0]+1,ans[1]+1) if flag==True else print("-1 -1")


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 1;
  for (int i = 0; i < N; ++i) {
    if (ans*2 <= ans+K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }
  cout << ans << endl;
}

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

const int Max_N = 101; // 3 <= N <= 100
const int Max_ans = 21; // 0 <= answer <= 20
bool memo[Max_N][Max_ans]; // memo for dp
long long int dp[Max_N][Max_ans] = {0};
std::vector<int> seq;

// memo[0][seq[0]] = true;
// memo[i][j] : caliculated up to i+1 and the num of result is j
void format(){
	for(u_int i = 0; i < Max_N; ++i){
		for(u_int j = 0; j < Max_ans; ++j){
			memo[i][j] = false;
			dp[i][j] = 0;
		}
	}
	memo[0][seq[0]] = true;
	dp[0][seq[0]] = 1;
}
/*
term - 1 ?????§????????????num??§???????????°???= term - 2?????§????????????num - seq[num - 1]??§???????????°???+???term - 2?????§????????????num + seq[num - 1]??§???????????°
*/
long long int calcEq(int term, int num){ // term-1?????§????????????number(term)??§???????????°?????????
	if(num < 0 || num > 20){
		return 0;
	}
	else if(term == 3){
		int count = 0;
		if(seq[0] + seq[1] == num){
			count += 1;
		}
		if(seq[0] - seq[1] == num){
			count += 1;
		}
		memo[1][num] = true;
		dp[1][num] = count;
		return dp[1][num];
	}
	else{ //?¨???????????????????????????????????????´???
		if(!memo[term - 2][num]){
			//dp[term - 2][num] = dp[term - 3][num - seq[num - 1]] + dp[term - 3][num + seq[num - 1]];
			dp[term - 2][num] = calcEq(term - 1, num - seq[term - 2]) + calcEq(term - 1, num + seq[term - 2]);
			memo[term - 2][num] = true;
		}
		return dp[term - 2][num];
	}
}
   
int main(void) {
    u_int N;    // the number of integer
    
	// input
    std::cin >> N;
    seq.reserve(N);
    for (u_int i = 0; i < N; ++i) {
        u_int tmp;
        std::cin >> tmp;
        seq.push_back(tmp);
    }
    
	// bounding condition
	format();
    // solve by dp
    std::cout << calcEq(N, seq[N - 1]) << std::endl;
    return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;
import java.util.Stack;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			String str[]=in.nextLine().split(" ");
			Stack <Double>sta=new Stack<Double>();
			for(int i=0;i<str.length;i++)
			{
				if(str[i].equals("+"))
				{
					double a=sta.pop();
					double b=sta.pop();
					sta.push(a+b);
				}
				else if(str[i].equals("-"))
				{
					double a=sta.pop();
					double b=sta.pop();
					sta.push(b-a);
				}
				else if(str[i].equals("*"))
				{
					double a=sta.pop();
					double b=sta.pop();
					sta.push(a*b);
				}
				else if(str[i].equals("/"))
				{
					double a=sta.pop();
					double b=sta.pop();
					sta.push(b/a);
				}
				else
					sta.push(Double.valueOf(str[i]));
			}
			System.out.printf("%.6f",sta.pop());
			System.out.println();
		}
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
#define sz 10010
#define MOD 1000000007
#define ll long long

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


	ll n; cin >> n;
	vector<ll>a(n);
	vector<ll>b(n);
	if (n % 2)
	{
		for (ll i = 0; i < n; i++)
		{
			cin >> a[i] >> b[i];
		}
		sort(a.begin(), a.end());
		sort(b.begin(), b.end());
		ll k = n / 2;
		cout << (b[k] - a[k] + 1);
	}
	else
	{
		for (ll i = 0; i < n; i++)
		{
			cin >> a[i] >> b[i];
		}
		sort(a.begin(), a.end());
		sort(b.begin(), b.end());
		ll k = n / 2 - 1;
		ll cnt = 0;
		if ((a[k] + a[k + 1]) % 2)
			cnt--;
		if ((b[k] + b[k + 1]) % 2)
			cnt++;
		ll start = (a[k + 1] + a[k]) / 2;
		ll end = (b[k + 1] + b[k]) / 2;
		// cout << start << " " << end << "\n";
		cnt += (end - start + 1);
		// 0.5
		cnt += (end - start);
		cout << cnt;
	}
	return 0;
}

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

const int mod = 1000000007;

int frac(int n){
  if (!n) return 1;
  int64_t ret = (int64_t) n * frac(n - 1);
  return ret % mod;
}
int modinv(int i){
  int64_t x = 1, y = 0, z = 0, w = 1;
  int m = mod;
  while (m > 0){
    int q = i / m, r = i % m;
    int64_t temp1 = x, temp2 = y;
    x = z; z = temp1 - q * z;
    y = w; w = temp2 - q * w;
    i = m; m = r;
  }
  while (x < 0) x += mod;
  return x;
}

int comb(int n, int i){
  int a = frac(n), b = frac(i), c = frac(n - i);
  int d = (int64_t) b * c % mod;
  int ret = (int64_t) a * modinv(d) % mod;
  return ret;
}

int main(){
  int x, y; cin >> x >> y;
  if ((x + y) % 3){
    cout << 0 << endl;
    return 0;
  }
  int m = (2 * x - y) / 3;
  int n = (2 * y - x) / 3;
  if (m < 0 || n < 0){
    cout << 0 << endl;
    return 0;
  }
  cout << comb(m + n, m) << endl;
}


Measured memory_bytes: 10624
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	a := make([]map[int]int, n)
	for i := 0; i < n; i++ {
		m := nextInt()
		a[i] = make(map[int]int, m)
		for j := 0; j < m; j++ {
			x, y := nextInt(), nextInt()
			a[i][x-1] = y
		}
	}

	result := 0
	comment := make([]int, n)
	for i := 1; i < 1<<n; i++ {
		for j := 0; j < n; j++ {
			comment[j] = -1
		}
		ok := true
		num := 0
		for j := 0; j < n; j++ {
			if (1<<j)&i == 0 {
				continue
			}
			num++
			for x, y := range a[j] {
				if comment[x] != -1 && comment[x] != y {
					ok = false
					break
				}
				comment[x] = y
				if comment[x] == 1 {
					if y2, exist := a[x][j]; exist && y2 == 0 {
						ok = false
						break
					}
					if (1<<x)&i == 0 {
						ok = false
						break
					}
				}
				if comment[x] == 0 && (1<<x)&i > 0 {
					ok = false
					break
				}
			}
			if !ok {
				break
			}
		}
		if ok {
			result = intMax(result, num)
		}
	}

	fmt.Fprintln(out, result)

}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func intMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 1832
N=int(input())
L=list(map(int,input().split()))
L.sort()
i=0
for a in range(len(L)):
    for b in range(a+1,len(L)):
        for c in range(b+1,len(L)):
            if L[a]==L[b] or L[a]==L[c] or L[b]==L[c]:
                continue
            if L[a]+L[b]>L[c]:
             
                i+=1

print(i)

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define pb push_back

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
	freopen ("cpp.in", "r", stdin);
	freopen ("cpp.out", "w", stdout);
}

const int N = 1e5 + 1e3;

vector<int> G[N], E[N];

int n, deg[N], root;

int Get(int u) {
	int Last = 0, pos;
	for (int v : G[u]) if ((pos = Get(v))) {
		if (Last) E[pos].pb(Last), E[Last].pb(pos), Last = 0;
		else Last = pos;
	}
	return Last ? Last : u;
}

void Get_Graph() {
	For (i, 1, n) G[i].clear();
	For (i, 1, n) {
		int fa = read(); G[fa].pb(i);
		if (~fa) deg[fa] ^= 1; else root = i;
	}
	Get(root);
}

int val[N];

void Dfs(int u) {
	for (int v : E[u]) if (val[v] == -2)
		val[v] = -val[u], Dfs(v);
}

int main () {

	n = read();

	Get_Graph(); 
	For (i, 1, n) 
		if (!deg[i]) val[i] = -2;
	Get_Graph();

	For (i, 1, n)
		if (deg[i]) return puts("IMPOSSIBLE"), 0;

	puts("POSSIBLE");

	For (i, 1, n) if (val[i] == -2)
		val[i] = -1, Dfs(i);

	For (i, 1, n)
		printf ("%d%c", val[i], i == iend ? '\n' : ' ');

	return 0;

}


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

string S;
int K;

int main() {
    cin >> S >> K;

    vector<string> substring;
    
    for (int i = 0; i < S.size(); ++i) {
        for (int j = 1; j <= 5 && i + j <= S.size(); j++) {
            substring.push_back(S.substr(i, j));
        }
    }


    sort(substring.begin(), substring.end());
    unique(substring.begin(), substring.end());

    cout << substring[K-1] << endl;

    return 0;
}


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

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    for (int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    double root;
    int distance, ans = 0;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            distance = 0;

            for(int k = 0; k < D; k++){
                distance += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
            }

            root = sqrt(distance);

            if(ceil(root) == floor(root)){
                ans ++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a, b, C;
    cin >> a >> b >> C;
    double rad = C * M_PI / 180;
    double h = sin(rad) * b;
    double S = a * h / 2;
    double L = a + b + (sqrt(a * a + b * b - (2 * a * b * cos(rad))));
    printf("%f\n%f\n%f\n", S, L, h);
}


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

int main() {
  int x;
  cin >> x;
  
  int n;
  cin >> n;
  
  int ans = x;
  int count = 0;
  
  if(n == 0) cout << x << endl;
  else{
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    
    for(int i=0; i<=1000; i++){
      
      if(i%2 == 0) ans = x + i/2;
      if(i%2 == 1) ans = x - (i+1)/2;
    
      for(int i=0; i<n; i++){
        if(a[i] == ans) count++;
      }
      
      if(count == 0){
        cout << ans << endl;
        break;
      }
      else count = 0;
      
    }
  }
  
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
 //-119<=A<=119;
 lli a,b;
 lli x;
 cin>>x;
 for(lli i=-119;i<120;i++){
     for(lli j=-119;j<120;j++){
         if(pow(i,5)-pow(j,5)==x){
             a=i;b=j;break;
         }
     }
 }
 cout<<a<<" "<<b;
}

Measured memory_bytes: 4104
H,W = gets.split.map(&:to_i)

A = []
q = []
H.times do |y|
  s = gets.chomp
  A << Array.new(W) do |x|
    if s[x] == '#'
      q << [x,y]
      0
    else
      -1
    end
  end
end

ans = 0
while q.size > 0
  x,y = q.shift

  ans = A[y][x] + 1

  q << [x-1, y] if x-1 >= 0 && A[y][x-1] < 0 && A[y][x-1] = ans
  q << [x+1, y] if x+1 < W  && A[y][x+1] < 0 && A[y][x+1] = ans
  q << [x, y-1] if y-1 >= 0 && A[y-1][x] < 0 && A[y-1][x] = ans
  q << [x, y+1] if y+1 < H  && A[y+1][x] < 0 && A[y+1][x] = ans
end
puts ans - 1


Measured memory_bytes: 87164
use strict;
use warnings;
use utf8;
use Data::Dumper;

use feature qw(say);

my $n = <STDIN>;
chomp $n;

my $list = <STDIN>;
chomp $list;

my $list_array = [split//, $list];
my $r_count = scalar grep { $_ eq 'R' } @$list_array;

my $count = 0;
for (my $i = 0; $i < $r_count; $i++) {
    if ($list_array->[$i] eq 'W') {
        $count++;
    }
}

say $count;

Measured memory_bytes: 39164
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/

typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u)
{
  int i, c;
  
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  
  if(T[u].p==NIL)
    {
      printf("root, ");
    }
  
  else if(T[u].l==NIL)
    {
      printf("leaf, ");
    }
  
  else
    {
      printf("internal node, ");
    }
  
  printf("[");
  
  for(i=0,c =T[u].l;c!=NIL;i++,c=T[c].r)
    {
      if(i)
	{printf(", ");
	}
    
      printf("%d", c);
    }
  
  printf("]\n");
}

void calcDepth(int u, int p){
  
  D[u] = p;
  if(T[u].r!=NIL)
    {
      calcDepth(T[u].r,p);
    }
  if(T[u].l!=NIL)
    {
      calcDepth(T[u].l,p+1);
    }
  
}

int main(void)
{
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++)
    {
      T[i].p = T[i].l = T[i].r = NIL;
    }
  
  for(i=0; i<n; i++)
    {
      scanf("%d %d", &id, &k);
      for(j = 0, sib = NIL; j<k; j++)
	{
	  //子を入力する (input children)
	  scanf("%d", &child);
	  
	  T[child].p = id;
	  
	  if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
	  else
	    {
	      T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
	    }
	  
	  sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
	}
      
    }

  //根を求める (find the root)
  for(i=0; i<n; i++)
    {
      if(T[i].p == -1) root = i;
    }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 6484
def main():
    N = int(input())
    di = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

    for _ in range(N):
        di[input()] += 1

    for k, v in di.items():
        print(f"{k} x {v}")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172