akhauriyash/Code-Regression huggingface dataset:
N,M=map(int,input().split())
stu=[]
che=[]
for i in range(N):
    stu.append(list(map(int,input().split())))
for j in range(M):
    che.append(list(map(int,input().split())))
for i in range(N):
    l=abs(stu[i][0]-che[0][0])+abs(stu[i][1]-che[0][1])
    n=0
    for j in range(1,M):
        ll=abs(stu[i][0]-che[j][0])+abs(stu[i][1]-che[j][1])
        if l>ll:
            l=ll
            n=j
    print(n+1)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (i=(x);i<(y);i++)
#define REPJ(x,y)	for (j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
int i,j,N,A[2][100],x,m;

int main() {
	cin >> N;
	
	for (i=0;i<2;i++) for (j=0;j<N;j++) cin >> A[i][j] ;
	
	REPI(0,N) {
		x = 0;
		REPJ(0,i+1) {
			x += A[0][j];
		}
		x += A[1][i];
		REPJ(i+1,N) {
			x += A[1][j];
		}
		m = MAX(x,m);
	}
	
	cout << m << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc161/tasks/abc161_e>
 問題文============================================================
 E - Yutoriaaaaaaa
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,K,C; cin >> N >> K >> C;
    string S; cin >> S;
    
    vector<ll> L,R;
    for(int i = 0; i < N;){
        if(S[i] == 'o'){
            L.emplace_back(i);
            i += C;
        }
        i++;
        if(L.size() == K) break;
    }
    for(int i = N-1; i >= 0;){
        if(S[i] == 'o'){
            R.emplace_back(i);
            i -= C;
        }
        i--;
        if(R.size() == K) break;
    }
    sort(R.begin(),R.end());
    
    if(L.size() < K) return res;
    for(int i = 0; i < K;i++){
        if(L[i] == R[i]){
            cout << L[i]+1 << endl;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 5128
using System;
using System.IO;
using System.Linq;

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();
            string S = sc.Next();
            int aa = int.Parse(S.Substring(0, 2));
            int bb = int.Parse(S.Substring(2, 2));
            if (1 <= aa && aa <= 12)
            {
                if (1 <= bb && bb <= 12)
                {
                    Console.WriteLine("AMBIGUOUS");
                }
                else
                {
                    Console.WriteLine("MMYY");
                }
            }
            else
            {
                if (1 <= bb && bb <= 12)
                {
                    Console.WriteLine("YYMM");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int K = sc.nextInt();

	for(int i=50;i>=0;i--){
	    if((N / Math.pow(K,i)) >= 1){
		System.out.print(i+1);
		break;
	    }
	}
    }
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }


template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while(b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if(u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};

typedef ModInt<1000000007> mint;

vector<mint> fact, factinv;
void nCr_computeFactinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	rer(i, 1, N) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for(int i = N; i >= 1; i --) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if(n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}

int main() {
	int H; int W; int A; int B;
	while(~scanf("%d%d%d%d", &H, &W, &A, &B)) {
		nCr_computeFactinv(H + W);
		mint ans;
		rep(i, H - A)
			ans += nCr((B - 1) + i, i) * nCr((W - 1 - B) + (H - 1 - i), H - 1 - i);
		printf("%d\n", ans.get());
	}
	return 0;
}


Measured memory_bytes: 1792
/* Coached by rainboy */
#include <stdio.h>

#define N 100000

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	static int aa[N];
	int n, m, i;
	long long x;

	scanf("%d%d", &n, &m);
	x = 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		x = lcm(x, aa[i] / 2);
		if (x > m) {
			printf("0\n");
			return 0;
		}
	}
	for (i = 0; i < n; i++)
		if (x % aa[i] == 0) {
			printf("0\n");
			return 0;
		}
	printf("%lld\n", (m / x + 1) / 2);
	return 0;
}


Measured memory_bytes: 512
N, M = map(int, input().split())
H = list(map(int, input().split()))

G = [[] for _ in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  G[A].append(B)
  G[B].append(A)

ans = 0
for i in range(N):
  is_good = True
  for j in G[i]:
    if H[j] >= H[i]:
      is_good = False
      break
  if is_good:
    ans += 1

print(ans)

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

#define lld long long
#define pii pair<int,int>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N; lld ans;
int op[100002],next[100002];
lld a[100002],sum[100002],sum2[100002];

int main(){
	scanf("%d",&N);
	scanf("%lld",&a[1]);
	sum[1] = a[1];
	for(int i=2; i<=N; i++){
		char s[3];
		scanf("%s",s);
		if(s[0]=='-') op[i] = -1;
		else op[i] =1;
		scanf("%lld",&a[i]);
		sum[i] = sum[i-1]+(a[i]*op[i]);
	}
	for(int i=N; i>=1; i--){
		sum2[i] = sum2[i+1]+a[i];
	}
	int tmp = N+1;
	for(int i=N; i>=2; i--){
		if(op[i] == -1){
			next[i] = tmp;
			tmp = i;
		}
	}
	ans = sum[N];
	for(int i=2; i<=N; i++){
		if(op[i] == 1) continue;
		ans = max(ans,sum[i-1]-(sum2[i]-sum2[next[i]])+sum2[next[i]]);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int k;
  for(int i=0;i*i<=2*N;i++)
    k=i+1;
  if(k*(k-1)!=2*N)
    cout<<"No"<<endl;
  else{
     int ans=1;
    vector<vector<int>>A(k);
    for(int i=0;i<k-1;i++){
    for(int j=i+1;j<k;j++){
      A.at(i).push_back(ans);
      A.at(j).push_back(ans);
      ans++;
    
    }
    }cout<<"Yes"<<endl;
    cout<<k<<endl;
    for(int i=0;i<k;i++){
      cout<<k-1<<" ";
      for(int j=0;j<k-1;j++)
        cout<<A.at(i).at(j)<<" ";
      cout<<endl;
    
    
    }
  }
   return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
int n;
vint a(10000);
bool solve(int i, int m){
	  if (m == 0)
   		 return true;
	  if (i >= n)
	   	  return false;
	   int res = solve(i + 1, m) || solve(i + 1, m - a[i]);
	   return res;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  	cin>>n;
  	rep(i,n){
      	cin>>a[i];
    }
  	int q,m;
  	cin>>q;	
  	rep(i,q){
      	bool flag=false;
      	cin>>m;
  		flag=solve(0,m);
    	if(flag){
          	cout<<"yes"<<'\n';
        }
      	else{
          	cout<<"no"<<'\n';
        }
    }        	
    return(0);
}


Measured memory_bytes: 3252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>

using namespace std;

class FForkInTheRoad {
    vector<vector<bool>> graph;
    vector<double> P;

    double solve(int n) {
        P[n - 1] = 0;
        for (int u = n - 2; u >= 0; u--) {
            int c = 0;
            double s = 0;
            for (int v = u + 1; v < n; v++) {
                if (graph[u][v]) {
                    c++;
                    s += P[v];
                }
            }
            P[u] = s / c + 1;
        }
        return P[0];
    }

public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;
        in >> n >> m;
        graph.assign(n, vector<bool>(n));
        for (int i = 0; i < m; i++) {
            int s, t;
            in >> s >> t;
            s--, t--;
            graph[s][t] = true;
        }
        P.resize(n);
        double res = solve(n);
        vector<double> orig = P;
        for (int i = 0; i < n; i++) {
            if (count(graph[i].begin(), graph[i].end(), true) > 1) {
                int to = -1;
                for (int j = i + 1; j < n; j++) {
                    if (graph[i][j] and (to == -1 or orig[j] > orig[to])) {
                        to = j;
                    }
                }
                graph[i][to] = false;
                res = min(res, solve(n));
                graph[i][to] = true;
            }
        }
        out << fixed << setprecision(10) << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    FForkInTheRoad solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t X;
  cin >> X;
  
  int64_t A = 100;
  int ans = 0;
  while (true) {
    A += A / 100;
    ans++;
    
    if (A >= X) {
      break;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3636
n,m=map(int,input().split())
def mfact(n,mod):
    f=[1]
    for i in range(1,n+1):
        f.append(f[-1]*i%mod)
    return f
if abs(n-m)>1:
    print(0)
else:
    f = mfact(max(m, n),10**9+7)
    if n==m:
        print(pow(f[n],2)*2%(10**9+7))
    else:
        print(f[n]*f[m]%(10**9+7))
        

Measured memory_bytes: 7060
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
cnt = 0
for i in range(N):
    cnt += B[A[i]-1]
    if (A[i] + 1) <= N and i < N-1 and A[i+1] == A[i] + 1:
        cnt += C[A[i]-1]
print(cnt)

Measured memory_bytes: 3064
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

# Yes or Noを返却する
def yes_no(bool, y = "YES", n = "NO")
  bool ? y : n
end

A, B, C = gets_i_list

count = 1
mod_list = []
while true
  mod = A * count % B
  if mod == C
    puts "YES"
    exit
  end
  if mod_list.include?(mod)
    puts "NO"
    exit
  end
  mod_list.push(mod)
  count += 1
end


Measured memory_bytes: 2044
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n, m;
  cin >> n >> m;
  vector<vector<int>> in(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      in[i].push_back(--x);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      int c = 0;
      for (int k : in[j]) {
        if ((1 << k) & i) c++;
      }
      if (c % 2 == p[j]) cnt++;
    }
    if (cnt == m) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
set<int> s;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		s.insert(a);
	}
	if(s.size()==n) cout<<"YES";
	else cout<<"NO";
	return 0; 
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=4009;
int main()
{
    int n,len;
    ll ans=0,sum[N][3];
    char a[N];
    map<char,int>ma;
    ma['R']=0,ma['G']=1,ma['B']=2;
    scanf("%d%s",&n,a+1);
    for(int i=1; i<=n; i++)
        for(int j=0; j<3; j++)
            sum[i][j]=sum[i-1][j]+(ma[a[i]]==j?1:0);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<i; j++)
        {
            if(a[i]==a[j])
                continue;
            for(int k=0; k<3; k++)
                if(k!=ma[a[i]]&&k!=ma[a[j]])
                {
                    ans+=sum[j-1][k];
                    if(2*j-i>=1&&ma[a[2*j-i]]==k)
                        ans--;
                }
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3872
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  print(b / x - (a == 0 ? -1 : (a - 1) / x));
  return 0;
}

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 = sc.nextInt();
        int b = sc.nextInt();

        StringBuffer sb = new StringBuffer();
        if (a < b) {
            sb.append("a < b");
        } else if (a == b) {
            sb.append("a == b");
        } else {
            sb.append("a > b");
        }

        System.out.println(sb);
    }
}

Measured memory_bytes: 17160
#include <stdio.h>

int main()
{
    int h, w;
    int i, j;

   while(1){
       scanf("%d %d", &h, &w);
       if (h == 0 && w == 0) break;
       for (i = 0; i < h; i++){
           if (i % 2 == 0){
              for (j = 0; j < w; j++){
                  if (j % 2) printf(".");
                  else       printf("#");
              }
           }
           else{
              for (j = 0; j < w; j++){
                  if (j % 2) printf("#");
                  else       printf(".");
              }
           }
           putchar('\n');
        }
        putchar('\n');
    }

    return 0;
}

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

int main()
{ 
	int a, b;
		cin >> a>>b; 
	if (a < b){
		cout << "a < b\n";
	}
	else if(a > b){
		cout << "a > b\n";
	}
	else if (a = b){
		cout << "a == b\n";
	}

	return 0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n;

int main(){
	while(cin>>n&&n){
		int p,prv,l=0;
		while(n--){
			cin>>p;
			if(!l||p==prv+1){prv=p;l++;}
			else{
				if(l==1)cout<<prv<<" ";
				else cout<<prv-l+1<<"-"<<prv<<" ";
				prv=p;l=1;
			}
		}
		if(l==1)cout<<prv<<"\n";
		else cout<<prv-l+1<<"-"<<prv<<"\n";
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int m[]={2189,89,1232,866,1796,2603},a,b,c,d,r;char s[9];int main(){for(s[87]=1,s[78]=4,s[69]=3,s[83]=2;~scanf("%s",s);d=s[*s],*s<60?printf(r?"%d\n":0,r),a=c=r=0,b=1:d?d=d+c&3,a=m[a]>>3*d&7,b=m[b]>>3*d&7:c+=*s-76?1:3,r+=a%3?b%3?(b+6-a)%6<3?2:5:3+!b:a?6:1);}

Measured memory_bytes: 0
boin = set(['a', 'i', 'u', 'e', 'o'])

def convert(name):
    s = name[0]
    for i, c in enumerate(name[1:], 1):
        if name[i - 1] in boin:
            s += name[i]
    return s

while True:
    n = int(input())
    if n == 0:
        break
    names = [input() for _ in range(n)]
    conv = [convert(n) for n in names]
    l = sum([len(c) for c in conv])

    ans = -1
    for k in range(1, l + 1):
        short = set([c[:k] for c in conv])
        if len(short) == n:
            ans = k
            break

    print(ans)



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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    string s;
    cin>>s;
    
    if(s<="2019/04/30")cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;

    return 0;
}




Measured memory_bytes: 764
using System;
using System.Collections.Generic;

namespace Dice
{
    class Program
    {
        private static bool Eql(string[] x, string[] y)
        {
            var g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }

        private static bool Check(string[] x, string[] y)
        {
            if (Eql(x, y)) return true;
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    var a = x[0]; var b = x[1]; var c = x[2];
                    var d = x[3]; var e = x[4]; var f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b } :
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return true;
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        var i = h[0]; var j = h[1]; var k = h[2];
                        var l = h[3]; var m = h[4]; var n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return true;
                    }
                }
            }
            return false;
        }

        static void Main()
        {
            int s = int.Parse(Console.ReadLine());
            var t = new List<string[]>();
            for(int u = 0; u < s; u++)
                t.Add(Console.ReadLine().Split(' '));
            for (int v = 0; v < s; v++)
                for (int w = v + 1; w < s; w++)
                    if (Check(t[v], t[w]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 9448
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
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/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se>b.se;
}
ll cmp(ll a,ll b){
    return abs(a)<abs(b);
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(i%2==0&&a[i]%2!=0)ans++;
    }
    cout<<ans<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------







































Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

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

    int N,M; cin >> N >> M;
    WeightedGraph<LL> g(N);

    REP(i,M){
        LL L,R,C; cin >> L >> R>>C;
        L--; R--;
        g[L].eb(R,C);
    }
    for(int i = 1; i < N; i++){
        g[i].eb(i-1,0);
    }
    auto dist = dijkstra(g,0);
    LL ans = dist[N-1];
    if(ans > LINF){
        cout << -1 << endl;
    }else{
        cout << dist[N-1] << endl;
    }

}


Measured memory_bytes: 9336
fun main(args: Array<String>) {
        val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
        solve(sc)
    }

    fun solve(sc: java.util.Scanner) {
        val N = sc.nextInt()
        val M = sc.nextInt()
        val n = when (N) {
            1 -> arrayOf(1)
            2 -> arrayOf(2, 2)
            else -> arrayOf(2, 3, 2)
        }
        val m = when (M) {
            1 -> arrayOf(1)
            2 -> arrayOf(2, 2)
            else -> arrayOf(2, 3, 2)
        }
        val nm = n.flatMap { nn -> m.map { mm -> mm * nn } }
//        println(nm)
        val inside = nm[nm.count() / 2]
        var ans = nm.count { it % 2 == 1 }.toLong()
        if (inside % 2 == 1) {
            ans += (if (N > 2) N - 2 else 1).toLong() * (if (M > 2) M - 2 else 1).toLong() - 1
        }
        println(ans)
    }


Measured memory_bytes: 29468
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

int main() {
	LL k, a, b;
	cin >> k >> a >> b;
	if(a+1 < b) {
		if(k+1 < a) cout << k+1 << endl;
		else {
			LL d = k+1-a;
			cout << (d/2)*(b-a) + a + d%2 << endl;
		} 
	} 
	else cout << k+1 << endl;
	return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list.emplace_back(v);
  }
  sort(list.begin(), list.end());

  ll sum = 0;
  for (ll i = 0; i < K; i++) {
    sum += list[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 3684
n, a, b = map(int, input().strip().split())
MOD=10**9+7

if n==2:
    print(0)
    exit()

def modpow(x, n, m):
    if n == 0:
        return 1
    res = modpow(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

# a*a**(p-2) mod p (Fermat's little theorem)
def modInv(x,m):
    return modpow(x,m-2,m)

def nCr(n,r):
    if r > n-r:
        r=n-r
    denom=1
    numer=1
    for i in range(r):
        denom=(n-i)*denom%MOD
        numer=(i+1)*numer%MOD
    return modInv(numer, MOD)*denom%MOD

ans=modpow(2,n,MOD)-1-nCr(n,a)-nCr(n,b)
print(ans%MOD)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int ret = 2*n;
    rep(i, n) {
        int comp = s.compare(i, n-i, t, 0, n-i);
        if (comp==0) {
            ret -= n-i;
            break; 
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * author:    Ziel
 * created:   12.04.2020 18:03:09
**/

// ~zaletaet~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans;
	
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    
    int init = 100;
    double rate = 1.01;
    lli x;
    cin >> x;
    lli curr = init ;
    lli ans = 0;
    while(curr < x){
        curr = (lli)curr * rate;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1001001001;

int dp[50100];

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> c(m+1);
  c[0] = 0;
  REP(i, 1, m) cin >> c[i];

  REP(j, 0, n) dp[j] = INF;
  dp[0] = 0;
  REP(i, 1, m){
    REP(j, 0, n-c[i]){
      chmin(dp[j+c[i]], dp[j]+1);
    }
  }

  cout << dp[n] << endl;

  return 0;

}




Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  vector<ll> A(N), B(N), C(N);
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<N; i++) cin >> B[i];
  for (int i=0; i<N; i++) cin >> C[i];

  sort(A.begin(), A.end()); sort(C.begin(), C.end());

  ll result = 0;
  for (auto i: B) {
    ll num_a = lower_bound(A.begin(), A.end(), i) - A.begin();
    ll num_c = N - ( upper_bound(C.begin(), C.end(), i) - C.begin() );
    result += num_a * num_c;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n;
    cin >> n;
    int i, j, k;
    int ans = 0;
    vector<int> l(n);

    rep(i, 0, n)
    {
        cin >> l[i];
    }

    sort(l.begin(), l.end());

    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            rep(k, j + 1, n)
            {
                if (l[i] < l[j] + l[k] && l[k] < l[j] + l[i] && l[j] < l[i] + l[k])
                {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
if N %2 == 1:
    print(0)
    exit()

# print(N//10)

# result = 0
# for i in range(19):
#     print(N//(10**(i+1)))
#     result += N//(10**(i+1))

# print(result)

result = 0
for i in range(100):
    # print(N//((5**(i+1))*2))
    result += N//((5**(i+1))*2)
print(result)


Measured memory_bytes: 38384
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

const ll mod = 1e9+7;
int s;
vector<vector<ll>> dp;

ll solve(int p, int rem) {
	if (rem == 0) return 1;
	if (p == s) return 0;
	if (dp[p][rem] != -1) return dp[p][rem];
	
	ll ans = 0;
	for_(i, 3, rem+1) {
		ans += solve(p+1, rem-i);
		if (ans >= mod) ans -= mod;
	}
	
	dp[p][rem] = ans;
	return ans;
}

int main() {
	#ifdef shiven
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> s;
	dp.resize(s+1, vector<ll> (s+1, -1));
	
	//for_(i, 1, s+1) for_(j, 0, s+1) dp[i][j] = 1;
	
	//for (int i = s-1; i >= 0; i--) {
		//for_(rem, 3, s+1) dp[i][rem] = dp[i+1][rem-3];
		
		//if (i) for_(rem, 1, s+1) {
			//dp[i][rem] += dp[i][rem-1];
			//if (dp[i][rem] >= mod) dp[i][rem] -= mod;
		//}
	//}
	
	//cout << dp[0][s] << endl;
	
	cout << solve(0, s) << endl;
	return 0;
}


Measured memory_bytes: 34488
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,flag,tot,hh,dep[500001],a[500001],e[500001],nt[500001],hd[500001],v[500001],l[500001],r[500001];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void dfs(int x,int fa){
	int i;
	dep[x]=dep[fa]+1;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		dfs(e[i],x);
	}
}
void get(int x,int fa){
	int i;
	if(v[x])l[x]=r[x]=a[x];
	 else l[x]=-1e9,r[x]=1e9;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		get(e[i],x);
		l[x]=max(l[x],l[e[i]]-1);
		r[x]=min(r[x],r[e[i]]+1);
	}
	if(l[x]>r[x])flag=1;
}
void ha(int x,int fa){
	int i;
	if(!v[x]){
		if(a[fa]+1>=l[x]&&a[fa]+1<=r[x])a[x]=a[fa]+1;
		 else a[x]=a[fa]-1;
	}
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		ha(e[i],x);
	}
}
int main(){
	int i,x,y,m;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		build(x,y);build(y,x);
	}
	dfs(1,0);
	scanf("%d",&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a[x]=y;v[x]=1;
		if(i==1)hh=(y&1)^(dep[x]&1);
		 else if(((y&1)^(dep[x]&1))!=hh)return puts("No"),0;
	}
	get(1,0);
	if(flag)return puts("No"),0;
	if(!v[1])v[1]=1,a[1]=l[1];
	ha(1,0);
	puts("Yes");
	for(i=1;i<=n;i++)printf("%d\n",a[i]);
}
/*
考虑不合法的情况就是距离为偶数的点权奇偶不同或为奇数的奇偶相同。
判掉之后每个点的取值范围可从其儿子节点递推过来 
*/

Measured memory_bytes: 18432
#include<iostream>
#include<string>
#include<math.h>
#include<vector>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  int score[3];
  for (int i = 0; i < 3; i++)
  {
    cin >> score[i];
  }
  string s;
  cin >> s;
  vector<int> ctoi(256);
  ctoi['r'] = 2;
  ctoi['s'] = 0;
  ctoi['p'] = 1;
  int ans = 0;
  for (int i = 0; i < k; i++)
  {
    vector<int> x;
    for (int j = i; j < n; j += k)
    {
      x.push_back(ctoi[s[j]]);
    }
    vector<int> dp(2);//最新の勝負で、dp[0]:まけ　dp[1]:かち　の時の最大スコア
    int pre = -1;
    for(int nx : x)
    {
      vector<int> p(2);
      swap(dp, p);
      dp[0] = max(p[0], p[1]);//負ける場合
      if(pre == nx)//勝つ場合
      {
        //一手前の勝ち手と今の勝ち手が同じとき
        dp[1] = p[0] /*一手前は負け*/ + score[nx]/*今は勝ち*/;
      }
      else
      {
        //違う時
        dp[1] = max(p[0], p[1])/*一手前で勝った時と負けた時のスコアの高い方*/ + score[nx]/*今は勝ち*/;
      }
      pre = nx;
    }
    ans += max(dp[0], dp[1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i=0;i<(n);++i)


using namespace std;

typedef long long ll;

int main(){
    int N,Q,l,r;
    scanf("%d %d",&N,&Q);

    char str[N+1];
    int str_num[N+1];
    rep(i,N)str_num[i]=0;
     scanf("%s",str); 
     int q=0;  

    for(int i=1;i!=N;++i){
        if(str[i-1]=='A'&&str[i]=='C'){
            ++q;
            
        }
        str_num[i]=q;
    }
    //rep(i,N)cout<<str_num[i]<<" ";
    //cout<<endl;

    int count;

    rep(i,Q){

        count=0;

        scanf("%d",&l);
        l-=1;
        scanf("%d",&r);
        r-=1;
        count=str_num[r]-str_num[l];

        cout<<count<<endl;

    }
}

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

A = []

for i in range(n):
    A.append(int(input()))

A = sorted(A)



s = A

A = []
t = 1
for i in range(1, len(s)):
    if s[i - 1] != s[i]:
        A.append(s[i-1])
        A.append(str(t))
        t = 1
    else:
        t += 1
    if i == len(s) - 1:
        if s[i-1] == s[i]:
            A.append(s[i-1])
            A.append(str(t))
        else:
            A.append(s[i])
            A.append("1")
# print("".join(A))
t = 0
for i in range(len(A)):
    if i % 2 == 1:
        if int(A[i]) % 2 == 1:
            t += 1
print(t)

Measured memory_bytes: 70744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  cin >> N;
  vector<int> l(N);
  vector<int> r(N);
  for (int i=0; i<N ; i++){
  	cin >> l.at(i) >> r.at(i);
  }
  int sum=0;
  for (int i=0; i<N; i++){
  	sum += r.at(i) -l.at(i)+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256