akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int func(int n){
  int sum =1;
  rep1(i,n+1){sum *= i;}
  return sum;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
	string s,mae,usiro,rmae,rusiro;
  	cin >> s;
  	if(s.size()%2 == 0){No return 0; }
	string rs = s;
  	
	reverse(rs.begin(), rs.end());
  
	if(s == rs){
    mae = s.substr(0,(s.size()-1)/2);
    rmae = mae;
    reverse(rmae.begin(), rmae.end());
    if(mae != rmae){No return 0;}
	usiro = s.substr((s.size()+3)/2-1);
    rusiro = usiro;
    reverse(rusiro.begin(), rusiro.end());
    if(usiro != rusiro){No return 0;}
    Yes
    }
	else{No}
	

return 0;

  
  
}

Measured memory_bytes: 384
n, m = map(int, input().split())

ac = 0
wa = 0
dwa = {}
d = {}

for i in range(m):
  p, s = input().split()
  if d.get(p) == "AC":
    continue
  if p not in dwa:
    dwa[p] = 0
  if s == "WA":
    dwa[p] += 1
  else:
    ac += 1
    wa += dwa[p]
  d[p] = s
  
print(ac, wa)

Measured memory_bytes: 28436
#include <stdio.h>

int main(void) {
	long i, n, val, tmin, trange, tmp;
	
	scanf("%ld\n", &n);
	scanf("%ld\n", &tmin);
	scanf("%ld\n", &tmp);
	trange = tmp - tmin;
	if(tmin > tmp) {
		tmin = tmp;
	}
	for(i=2;i<n;i++) {
		scanf("%ld\n", &val);
		if(tmin > val) {
			tmin = val;
		} else if(trange < val-tmin) {
			trange = val - tmin;
		}
	}

	printf("%ld\n", trange);

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int N;
    cin>>N;
    int a[N]={};
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int A=0,B=0,count=0;
    sort(a,a+N);
    for(int i=N-1;i>=0;i--,count++){
        if(count%2==0)A+=a[i];
        else B+=a[i];
    }
    cout<<abs(A-B)<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
graph = []
for i in range(n):
    graph.append([])
    for j in range(n):
        graph[i].append(0)

for i in range(m):
    a, b = map(int,input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

def adjacent(g, v):
    adj = []    
    for i in range(n):
        if g[v-1][i] == 1:
            adj.append(i+1)
    return adj


def dfs(g, v):
    visited = []
    stack = []
    
    stack.append(v)
    
    while stack:
        node = stack.pop()
        if node not in visited:
            visited.append(node)
            for w in adjacent(g, node):
                if w not in visited:
                    stack.append(w)
    return visited
            

def cut(g):
    bridge = 0
    for i in range(n):
        for j in range(n):
            if g[i][j] == 1:
                g[i][j] = 0
                g[j][i] = 0
                if len(dfs(g,i+1)) < n:
                    bridge = bridge + 1
                g[i][j] = 1
                g[j][i] = 1
    bridge = bridge // 2
    return bridge

print(cut(graph))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long d[n];
  for(int i = 0; i < n; i++) cin >> d[i];
  long long ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// ayy
// ' lamo
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld; //CARE
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;
const int P=1e9+7;





const int N=200<<10;
char s[N];
int n,dp[N];



int ps[N];
const int NN=1<<26;
int bes[NN];


int32_t main() {
	scanf("%s",s);
	n=(int)strlen(s);
	for(int i=0;i<n;i++) {
		ps[i+1]=ps[i];
		ps[i+1] ^= 1<<int(s[i]-'a');
	}
	for(int i=0;i<NN;i++) bes[i]=inf;
	bes[0]=0;
	for(int i=1;i<=n;i++) {
		// dp[i]=1+dp[i-1];
		dp[i]=inf;
		for(int c=0;c<=26;c++) {
			int bit=1<<c;
			if(c==26) bit=0;
			dp[i]=min(dp[i], 1+bes[ps[i] ^ bit]);
		}
		assert(dp[i]<inf);
		bes[ps[i]]=min(bes[ps[i]],dp[i]);
	}
	cout<<dp[n]<<endl;
}













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


int main()
{
	int n, x; cin >> n >> x;
	int minval = 1e9;
	for (int i = 0; i < n; ++i)
	{
		int m; cin >> m;
		x -= m; 
		minval = min(minval, m);
	}
	cout << n + x / minval << endl;
}


Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n = int(input())

    S = list(str(n))
    h = 0
    for s in S:
        h += int(s)
    if n%h == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61804
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 16
#define lowbit(x) ((x) & -(x))
int f[1 << N], g[N][1 << N], mul[N * N];
int n, m;
int main()
{
	scanf("%d%d", &n, &m);
	mul[0] = 1;
	for (int i = 1; i <= m; i++)
		mul[i] = mul[i - 1] * 2ll % mod;
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		g[x - 1][1 << (y - 1)]++;
	}
	for (int i = 0; i < n; i++)
		for (int j = 1; j < (1 << n); j++)
			g[i][j] = g[i][j - lowbit(j)] + g[i][lowbit(j)];
	for (int s = 1; s < (1 << n); s++)
	{
		if ((s & 1) && !(s & 2))continue;
		if (!(s & 1) && (s & 2))continue;
		f[s] = 1;
		for (int t = s; t; t = (t - 1) & s)
		{
			if ((t & 1) && !(t & 2))continue;
			if (!(t & 1) && (t & 2))continue;
			int u = s - t;
			int w = f[u];
			for (int i = 0; i < n; i++)
			{
				if (u & (1 << i))
					w = (ll)(mul[g[i][t]] - 1) * w % mod;
				if (t & (1 << i))
					w = (ll)mul[g[i][u]] * w % mod;
			}
			f[s] = (f[s] + w) % mod;
		}
	}
	int ans = (mul[m] - f[(1 << n) - 1]) % mod;
	if (ans < 0)
		ans += mod;
	printf("%d\n", ans);
}


Measured memory_bytes: 3456
object Main extends App {
//	require(func("EEE") == 0)
//	require(func("EE") == 0)
//	require(func("WWW") == 0)
//	require(func("WW") == 0)
//	require(func("WWWWW") == 0)
//	require(func("EEEEE") == 0)
//	require(func("WE") == 1)
//	require(func("EW") == 0)
//	require(func("WEEWW") == 1)
//	require(func("WEWEWEEEWWWE") == 4)
//	require(func("WWWWWEEE") == 3)
//	println((0 to 30).map(_ => 'E').mkString(""))
//	val start = System.currentTimeMillis()
//	require(func((0 to 3000000).map(_ => 'E').mkString("")) == 0)
//	println("E elapsed:" + (System.currentTimeMillis() - start))
//	require(func((0 to 3000000).map(_ => 'W').mkString("")) == 0)
//	println("W elapsed:" + (System.currentTimeMillis() - start))

	private def func(input: String): Int = {
		val bits = new java.util.BitSet(400000)
		input.foldLeft(0) { (i, e) =>
			bits.set(i, e == 'W')
			i + 1
		}
		subbb(input.length, bits)
	}

	private def subbb(len: Int, bits: java.util.BitSet) = {
		@inline def count(s: Int, e: Int): Int = {
			bits.get(s, e).cardinality
		}

		val init = len - 1 - count(1, len)
		var min = init
		(1 until len).foldLeft(init) { (prev, i) =>
			val cur = prev + (if (bits.get(i - 1)) 1 else 0) + (if (bits.get(i)) 0 else -1)
			//println(prev, cur)
			min = Math.min(min, cur)
			cur
		}
		//println(min)
		min
	}

	println(func(scala.io.Source.stdin.getLines().toArray.apply(1)))
}


Measured memory_bytes: 41944
import java.util.*;

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

        Main instance = new Main();

        int res = (int) instance.solve(K, D);

        System.out.println(res);
    }

    public long solve(String K, int D) {
        int n = K.length();
        long[][][] dp = new long[n + 1][2][D + 1]; // 0 : 0 - 9   1 : ch
        int mod  = (int) 1e9 + 7;

        dp[0][0][0] = 1;

        for (int i = 0; i < n; i++) {
            int ch = K.charAt(i) - '0';
            for (int d = 0; d < D; d++) {
                for (int j = 0; j < 10; j++) {
                    dp[i + 1][1][(d + j) % D] += dp[i][1][d];
                    dp[i + 1][1][(d + j) % D] %= mod;
                }

                for (int j = 0; j <= ch; j++) {
                    if (j == ch) {
                        dp[i + 1][0][(d + j) % D] += dp[i][0][d];
                        dp[i + 1][0][(d + j) % D] %= mod;
                    } else {
                        dp[i + 1][1][(d + j) % D] += dp[i][0][d];
                        dp[i + 1][1][(d + j) % D] %= mod;
                    }
                }
            }
        }

        long res = ((dp[n][0][0] % mod ) + (dp[n][1][0] % mod)) % mod;


        return (res + mod - 1) % mod;
    }
}


Measured memory_bytes: 69468
#最終日から見る，残り日数条件を満たす中で最大収入のものを選ぶ

import heapq

N,M=map(int,input().split())
AB=[[0,0] for _ in range(N)]

for i in range(N):
    AB[i][0],AB[i][1] = map(int,input().split())

AB.sort()

ans=0
q=[]
heapq.heapify(q)
ne=0
#dは残り日数
for d in range(1,M+1):
    for i in range(ne,N):
        if AB[i][0]<=d:
            heapq.heappush(q,AB[i][1]*-1)
            ne=i+1
        else:
            break
    if len(q)!=0:
        a=heapq.heappop(q)
        ans-=a
    
print(ans)

Measured memory_bytes: 71456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,s=0,j;
  cin>>n;
  int A[n];
  for(i=0;i<n;i++)cin>>A[i];
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++)s+=(A[i]*A[j]);
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
import kotlin.*


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val a = sc.longList()
        val b = sc.longArray()
        var ans = 0L
        for (i in 28 downTo 0) {
            // i桁が1になるか0になるか
            // 1になるペアの個数
            val p = 1L shl i
            for (j in 0 until n) {
                b[j] = b[j] % (2 * p)
            }

            b.sort()

            var cnt = 0L
            for (j in 0 until n) {
                val m = a[j] % (2 * p)
                // 足して 3p以上になる
                var ok = n
                var ng = -1
                while (ok - ng > 1) {
                    val mid = (ok + ng) / 2
                    if (m + b[mid] >= 3 * p) ok = mid
                    else ng = mid
                }
                cnt += n - ok

                // 足して 1p以上 2p未満になるペア
                ok = n
                ng = -1
                while (ok - ng > 1) {
                    val mid = (ok + ng) / 2
                    if (m + b[mid] >= 2 * p) ok = mid
                    else ng = mid
                }
                cnt -= n - ok

                ok = n
                ng = -1
                while (ok - ng > 1) {
                    val mid = (ok + ng) / 2
                    if (m + b[mid] >= p) ok = mid
                    else ng = mid
                }

                cnt += n - ok
            }
            if (cnt % 2 != 0L) ans += p
        }

        println(ans)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 92028
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

LL p = 1E9+7;

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

    vector<LL> ans(S+1, 0);
    
    REP(i, S+1){
        if(i==0){ans[0] = 1; continue;}
        if(i<=2){ans[i] = 0; continue;}

        ans[i] = (ans[i-3] + ans[i-1])%p;
    }

    cout << ans[S] << endl;
    return 0;
}

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

//Math/ModInt
template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	modint &operator++(){ return (*this) += 1; }
	modint &operator--(){ return (*this) -= 1; }
	modint &operator++(int){
		modint tmp = *this;
		(*this) += 1;
		return tmp;
	}
	modint &operator--(int){
		modint tmp = *this;
		(*this) -= 1;
		return tmp;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

//Math/PartitionTable2D
template<class T>
vector<vector<T>> partitionTable2D(int n,int k){
	vector<vector<T>> dp(n + 1,vector<T>(k + 1));
	dp[0][0] = 1;
	for(int i = 0;i <= n;i++){
		for(int j = 1;j <= k;j++){
			dp[i][j] = dp[i][j - 1] + (i >= j ? dp[i - j][j] : T(0));
		}
	}
	return dp;
}

signed main(){
	int n,k;
	cin >> n >> k;
	auto table = partitionTable2D<modint<>>(n,k);
	cout << table[n][k] << endl;
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int K;
    cin>>K;
    vi Mod(1000001, 0);
    int mod = 0;
    REP(i, 1, K + 1){
        mod = (mod * 10 + 7) % K;
        if(mod == 0){
            cout << i << endl;
            return 0;
        }else if(Mod[mod] == 1){
            break;
        }else{
            Mod[mod] = 1;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7212
import numpy as np

N = 5
A = np.array([int(input()) for i in range(N)])
k = int(input())

xx, yy = np.meshgrid(A, A)
comb = np.c_[xx.flatten(), yy.flatten()]

diff_ = np.abs(comb[:, 0] - comb[:, 1])
max_diff = np.max(diff_)

if max_diff <= k:
    print('Yay!')
else:
    print(':(')



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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
int ctoi(char c) {return c-'0';}

const int MOD=1e9+7;
const int mxn=1005;
char a[mxn][mxn];
ll dp[mxn][mxn];
int N,M;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

cin>>N>>M;
forn(i,N) {
  forn(j,M) {
    cin>>a[i][j];
  }
}
dp[0][0]=1;
forn(i,N) {
  forn(j,M) {
    if(a[i][j]!='.')
      continue;
    if(j+1<M)
      dp[i][j+1]=(dp[i][j+1]%MOD+dp[i][j]%MOD)%MOD;
    if(i+1<N)
      dp[i+1][j]=(dp[i+1][j]%MOD+dp[i][j]%MOD)%MOD;
  }
}
cout<<dp[N-1][M-1]<<endl;
return 0;
}


Measured memory_bytes: 12464
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.print(lcm(a,b));     
    }
    public static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    public static long lcm (long a, long b) {return a*b/gcd(a,b);}
}


Measured memory_bytes: 21844
# AAA -> A
# AABB -> AB
# 基本的に超過分から2枚を自由に消せる

from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]
x = len(set(A))

# N-x枚が超過分

if (N-x)&1:
  answer = x-1
else:
  answer = x

print(answer)

Measured memory_bytes: 14948
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0; i<s.size(); i+=1){
    if(s[i]!=t[i]){ans++;}
  }
  cout<<ans;


  return 0;
}


Measured memory_bytes: 3856
#include<iostream>
#include<stdlib.h>

int main()
{
	using namespace std;
	int b1,b2,b3;
	cin>>b1>>b2>>b3;
	
	if(b1 && b2)
	{
		cout<<"Open"<<endl;
	}
	else if(b3)
	{
		cout<<"Open"<<endl;
	}
	else
	{
		cout<<"Close"<<endl;
	}
	
	return 0;
}

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

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

Measured memory_bytes: 256
n = int(input())
a = [[0] * n for i in range(2)]


for i in range(2):
    arr = input().split()
    arr = list(map(int,arr))
    for j in range(n):
        a[i][j] = arr[j]

m = 0
for i in range(n):
    l = 0
    r = 0
    for k in range(i+1):
        l += a[0][k]
    for k in range(i,n):
        r += a[1][k]

    if m <= l + r:
        m = l + r

print(m)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
using namespace std;
int main(){
    long long int n, k; scanf("%lld", &n);
    k = n;
    int cnt = 0; long long int j = 1LL, suma = 1LL;
    int ans = 0;
    if(k == 1) cout << 0 << "\n";
    else{
        for(long long int i = 2; i <= k; i++){
            cnt = 0; j = 1LL ; suma = 1LL;
            while(k % i == 0){
                cnt++;
                k = 1LL*k/i;
                if(cnt >= suma){
                    ans++; j++;
                    suma = 1LL*(j)*(j + 1)/2;
                }
            }
            if(i*i > k && k > 1000){
                cout<< ans + 1 << "\n";
                return 0;
            }
        }
        cout<< ans << "\n";
    }
        
    
    return 0;
}

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

const int MAX = 100005;

int main() {
	int n;
	cin >> n;
	vector<int> x(MAX);
	rep(i, n) {
		int a;
		cin >> a;
		if (a > 0) x[a - 1]++;
		x[a]++;
		x[a + 1]++;
	}
	int mx = 0;
	rep(i, MAX) mx = max(mx, x[i]);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

	int r;
	cin>>r;

	int ar = 3 * r * r;

	cout<<ar<<endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << hypot(x1 - x2, y1 - y2) << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int main(){
    long long ans = 0;
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        int x = i;
        int fi = -1, la = -1;
        while(x){
            fi = x%10;
            if(la == -1) la = x%10;
            x/=10;
        }
        if(fi == 0 || la == 0) continue;
        dp[fi][la]++;
    }
    for(int i=1;i<=n;i++){
        int x = i;
        int fi = -1, la = -1;
        while(x){
            fi = x%10;
            if(la == -1) la = x%10;
            x/=10;
        }
        if(fi == 0 || la == 0) continue;
        ans += dp[la][fi];
    }   
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var a string
	fmt.Scanf("%s", &a)

	r := regexp.MustCompile(`[A-Z]`)
	if r.MatchString(a) {
		fmt.Println("A")
	}else{
		fmt.Println("a")
	}	
}


Measured memory_bytes: 2064
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

int main()
{
    int k;scanf("%d",&k);
    printf("%d",a[k-1]);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long ll;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a > 0 && b > 0) cout << "Positive" << endl;
    else if ((a >= 0 && b <= 0) || (a <= 0 && b >= 0)) cout << "Zero" << endl;
    else {
        if (abs(a - b) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
}


Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    int H, W, c[10][10];

    cin >> H >> W;
    rep(y, 10)rep(x, 10)cin >> c[y][x];

    rep(k, 10)rep(i, 10)rep(j, 10) {
        smin(c[i][j], c[i][k] + c[k][j]);
    }

    int ans = 0;
    vector<vi> A(H, vi(W));
    rep(y, H)rep(x, W) {
        cin >> A[y][x];
        if (A[y][x] != -1)ans += c[A[y][x]][1];
    }
    cout << ans << endl;
}


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

int main()
{
    int n;

    cin >> n;

    cout << n / 25 + ( n % 25 ) / 10 + ( n % 25 % 10 ) / 5 + (n % 25 % 10 % 5 ) << endl;
    
    return 0;
}


Measured memory_bytes: 3124
s = input()
abc = []
for i in range(len(s)):
    if not s[i] in abc:
        abc.append(s[i])
ans = []
for c in abc:
    count = 0
    x = s
    y = ""
    while True:
        if x.count(x[0]) == len(x):
            break
        for i in range(len(x)-1):
            if x[i] == c or x[i+1] == c:
                y+=c
            else:
                y+=x[i]
        x = y
        y = ""
        count += 1
    ans.append(count)
print(min(ans))

Measured memory_bytes: 41324
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    int n, x;
    cin >> n >> x;
    vi m(n);
    REP(i, n) cin >> m[i];
    int ans = n;
    x -= accumulate(m.begin(), m.end(), 0);
    sort(m.begin(), m.end());
    ans += x/m[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n, k;
	char s[11];
	int i;

	scanf("%d", &n);
	scanf("%s", s);
	scanf("%d", &k);
	for (i = 0; s[i] != '\0'; i++) {
		if (s[k-1] != s[i]) {
			s[i] = '*';
		}
	}
	printf("%s\n", s);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll c = 1e6;
int main(){
 ll N; cin >> N;
 ll ans = 1LL << 60;
  for(ll i = 1LL; i <= min(c,N); i++){ 
    if( N%i == 0){ ans = min(ans, i+(N/i));}
    
  }
  
  cout << ans-2 << endl; return 0;
}

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

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

    char s[10001];
    scanf("%s", s);

    for(int i = 0; s[i] != '\0'; i++)
    {
        if(s[i] + n > 'Z')
        {
            printf("%c" , s[i] + n -26);
        }
        else
        {
            printf("%c", s[i]+n);
        }
    }

}


Measured memory_bytes: 1648
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();

    int taro = 0;
    int hanako = 0;

    for (int i = 0; i < n; i++) {
      
      String taros = scan.next();
      String hanakos = scan.next();

      int result = taros.compareTo(hanakos);
      if (result > 0) {
        taro += 3;
      } else if (result < 0) {
        hanako += 3;
      } else {
        taro++;
        hanako++;
      }

    }
    
    System.out.println(taro + " " + hanako);

  }

}



Measured memory_bytes: 29972
#include<bits/stdc++.h>
using namespace std;
int vis[100005],red[100005];
int main()
{
    for(int i=1;i<=100000;i++)
        vis[i]=1;
    red[1]=1;
    int n,m,res=0;
    cin>>n>>m;
    int x[m],y[m];
    for(int i=0;i<m;i++)
    {
        cin>>x[i]>>y[i];
        if(red[x[i]]==1)
            red[y[i]]=1;
        vis[x[i]]--;
        vis[y[i]]++;
        if(vis[x[i]]==0&&red[x[i]]>0)
            red[x[i]]=0;
    }
    for(int i=0;i<100001;i++)
    {
        if(red[i]>0)
            res++;
    }
    cout<<res;
}

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

typedef long long LL;
typedef unsigned long long LONG;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MAXINT = 2147483647;
const int mod = 1000000007;
const long long MAXLONG = 9223372036854775807;
using namespace std;
typedef pair<int, int> PII;
#define ft fisrt
#define sd second
#define eb emplace_back
#define END '\n'

template <class T>
inline bool Read(T &ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), Write(x);
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}
void change(vector<int>&cur){
	sort(cur.begin(),cur.end());
	reverse(cur.begin(),cur.end());
}

int main()
{
    unsigned int x, y, a, b, c,k;
    cin>>x>>y>>a>>b>>c;
    vector<int> r(a+1),g(b+1),temp;
    for(int i=0;i<a;++i) Read(r[i]);
    for(int i=0;i<b;++i) Read(g[i]);
    change(r);change(g);
    for(int i=0;i<x;++i) temp.emplace_back(r[i]);
    for(int i=0;i<y;++i) temp.emplace_back(g[i]);
    for(int i=0;i<c;++i) cin>>k,temp.emplace_back(k);
    change(temp);
    LONG ans=0;
    for(int i=0;i<x+y;++i) ans+=temp[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 3188
// AOJ1-23.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include<cmath>
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;

int main()
{
    int b; //棟番号
    int f; //階数
    int r; //部屋番号
    int v; //入退出人数
    int n; //情報

    int count[4][3][10] = {}; //マンションの配列と初期化

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        count[b - 1][f - 1][r - 1] += v;
    }

    for (int x = 0; x < 4; x++) {
        for (int y = 0; y < 3; y++) {
            for (int z = 0; z < 10; z++) {
                cout << ' ' << count[x][y][z];
            }
            cout << endl;
        }
        if (x < 3) {
            cout << "####################" << endl;
;        }
    }






}




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

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)
#define inf LLONG_MAX
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}


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

	int n,res=0,mx=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		if(x==y)
			mx++;
		else
			res=max(res,mx),mx=0;
	}
	res=max(res,mx);
	cout<<(res>2?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007,MAX=200005,INF=1<<30;
 
ll inv[MAX],fac[MAX],finv[MAX];
 
ll modpow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}
  
ll comb(ll a,ll b){
    ll ans=1;
    for(ll i=a;i>a-b;i--){
        ans=ans*i%mod;
    }
    for(ll i=1;i<=b;i++){
        ans=(ans*modpow(i,mod-2))%mod;
    }
    return ans;
}
 
int main(){
  
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans=modpow(2,n);
  ans--;
  
  ans-=comb(n, a);
  ans-=comb(n,b);
  
  cout << (ans+2*mod)%mod << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static final int MAX_N = 100;
    private static final int INF = 1 << 21;
    private static final int WHITE = 0;
    private static final int GRAY = 1;
    private static final int BLACK = 2;

    static int n;
    static int[][] M = new int[MAX_N][MAX_N];


    private static int prim() {
        // initialize
        int[] color = new int[MAX_N]; // visited or not
        int[] d = new int[MAX_N]; // min edge
        int[] p = new int[MAX_N]; // MST parent node

        for (int i = 0; i < n; i++) {
            color[i] = WHITE;
            d[i] = INF;
            p[i] = -1;
        }

        // start node
        d[0] = 0;

        while (true){
            int u = -1;
            int minv = INF;

            // find minimum value vertex
            for (int i = 0; i < n; i++) {
                if (color[i] != BLACK && d[i] < minv){
                    minv = d[i];
                    u = i;
                }
            }

            // didn't find any vertex
            if (u == -1)
                break;
            color[u] = BLACK;

            // add new edges
            for (int v = 0; v < n; v++) {
                if (color[v] != BLACK && M[v][u] != INF){
                    if (d[v] > M[v][u]) {
                        d[v] = M[v][u];
                        color[v] = GRAY;
                        p[v] = u;
                    }
                }

            }

        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] != -1)
                sum += M[p[i]][i];
        }

        return sum;
    }

    private static void input() {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int e = scanner.nextInt();
                if (e == -1)
                    M[i][j] = INF;
                else
                    M[i][j] = e;
            }
        }
    }

    public static void main(String[] args){
        input();
        System.out.println(prim());
    }
}

Measured memory_bytes: 40444
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int n;
    cin >> n;
    vector<pair<int, int>> arr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i].first;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i].second;
    }
    int sol = 0;
    for(int i= 0;i<n;i++)
    {
        if(arr[i].first > arr[i].second)
        sol += arr[i].first - arr[i].second;
    }
    cout << sol;
    return 0;
}

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

using namespace std;

int main() {

    int n;
    cin >> n;
    multiset<int>m;
    for(int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        m.insert(x);
    }
    for (int i = 0; i < n; i++) {
        int z = i +1;
        cout << m.count(z) << endl;
    }
    return 0;
}


Measured memory_bytes: 13012
import re

S = raw_input()

array = []
prev = None
for i in S:
    if prev is None:
        prev = i
        duplicate_count = 1
        continue
    if prev == i:
        duplicate_count += 1
    else:
        array.append((prev, duplicate_count))
        duplicate_count = 1
    prev = i
array.append((prev, duplicate_count))

array = [(k, range(v + 1)) for k, v in array]

for i in range(len(array) - 1):
    if array[i][0] == '<' and array[i + 1][0] == '>':
        if array[i][1][-1] < array[i + 1][1][-1]:
            array[i] = array[i][0], array[i][1][:-1]
        else:
            array[i + 1] = array[i + 1][0], array[i + 1][1][:-1]
print sum(sum(v) for k, v in array)


Measured memory_bytes: 69608
S = input()

words = ["dream", "dreamer", "erase", "eraser"]
S_rv = S[::-1]
words_rv = [word[::-1] for word in words]

for i in range(len(S_rv)):
    for word_rv in words_rv:
        if S_rv[: len(word_rv)] == word_rv:
            S_rv = S_rv[len(word_rv) :]

if len(S_rv) == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9160
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#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++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


ll exp_mod(ll a, ll b, ll m) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

int main() {
    int N, X;
    cin >> N >> X;
    vint S(N);
    rep(i, N) cin >> S[i];
    sort(S.begin(), S.end(), greater<int>());
    v2ll dp(N + 1, vll(X + 1, 0));
    ll p = 1000000007;
    dp[0][X] = 1;
    REP(i, 0, N) {
        ll Pmod = ll(exp_mod(N - i, p - 2, p));
        REP(j, 0, X + 1) {
            auto x = j % S[i];
            dp[i + 1][x] += (dp[i][j] * Pmod) % p;
            dp[i + 1][x] %= p;
            dp[i + 1][j] += ((ll(N - i - 1) * dp[i][j])%p * Pmod) % p;
            dp[i + 1][j] %= p;
        }
    }
    ll ans = 0;
    rep(x, X + 1) {
        ans += (dp[N][x] * ll(x)) % p;
        ans %= p;
    }
    ll frac = 1;
    REP(i,1, N + 1) {
        frac *= ll(i);
        frac %= p;
    }
    cout << (frac * ans) % p << endl;
    return 0;
}

Measured memory_bytes: 158592
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  string s;
  cin >> s;
  sort(all(s));
  if (s[0]==s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi l(n);
	rep(i, n) cin >> l[i];
	sort(all(l));
	
	ll ans = 0;
	rep(i, n) for(int j = i + 1; j < n; j++){
		int k = lower_bound(l.begin() + i + 1, l.begin() + j, l[j] - l[i] + 1) - l.begin();
		ans += j - k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int main(){
    ll n;
    cin >> n;
    ll mx=0;
    ll i;
    for(i=1;i*i<=n;i++){
        if(n%i==0)mx=i;
    }
    ll t=n/mx;
    ll cnt=0;
    while(t>0){
        t=t/10;
        cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		/*
		 * ケツからたどればよさそう（ケツは情報量が少ないので）
		 * ケツからだと情報が把握できる
		 * いま連結かどうかを何度も判定するので、高速なアルゴリズムが必要
		 * UnionFndで共通祖先を連結か何かに応用できないか？
		 */
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[][] data=new int[M][2];
		long[] res=new long[M+1];
		long fumando=((long)N)*((long)N-1)/2L;
		res[0]=fumando;
		for(int i=M-1; i>=0; i--) {
			data[i][0]=sc.nextInt();
			data[i][1]=sc.nextInt();
		}
		UnionFind UFT=new UnionFind(N+1);
		for(int i=0; i<M; i++) {
			int AR=UFT.find(data[i][0]);
			int BR=UFT.find(data[i][1]);
			long a=(long)UFT.size(AR);
			long b=(long)UFT.size(BR);
			//pl(AR+" "+BR+" "+a+" "+b);
			UFT.union(data[i][0], data[i][1]);
			if(AR!=BR) {
				res[i+1]=res[i]-a*b;
			}
			else {
				res[i+1]=res[i];
			}
		}
		for(int i=M-1; i>=0; i--) {
			pl(res[i]);
		}
	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	public static class UnionFind{
		int[] par; //
		public UnionFind(int n){
			par = new int[n];
			for(int i = 0; i < n; i++){ par[i] = -1; }
		}

		public int find(int x){
			if(par[x] < 0){
				return x;
			}else{
				return par[x] = find(par[x]);
			}
		}

		public boolean union(int x, int y){
			x = find(x);
			y = find(y);

			if(x != y){
				if(par[y] < par[x]) {  // 多い方が根になるようにスワップする.
					int tmp = x; x = y; y = tmp;
				}
				par[x] += par[y];
				par[y] = x;
				return true;
			}else{
				return false;
			}
		}

		public boolean same(int x, int y){
			return find(x) == find(y);
		}

		public int size(int x){
			return -par[find(x)];
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 53252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>

using namespace std;

#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()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

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


LL twodiv(LL a)
{
	LL ans = 0;
	while(a%2 == 0)
	{
		a = a/2;
		ans++;
	}
	return ans;
}
 

//ここから書き始める
int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	LL a[N];
	REP(i,N)
	{
		cin >> a[i];
	}

	LL ans = 0;
	REP(i, N)
	{
		ans += twodiv(a[i]);
	}

	cout << ans << endl;


}


Measured memory_bytes: 384
// abc122_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  int sSize = (int)s.size(), ans=0,cnt;
  for (int i = 0; i < sSize; ++i) {
    cnt=0;
    for (int j = i; j < sSize; ++j) {
      if ((s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')) {
        cnt++;
      } else {
        break;
      }
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(vector<int> &p,vector<vector<int>> &v)
{
  for(int i=0;i<p.size()-1;i++)
    if(v[p[i]][p[i+1]]==0)
      return false;
 /* for(auto i:p)
    cout<<i<<" ";
  cout<<"\n";  */
  return true;
}
int main()
{
  int n,m;
  cin>>n>>m;
  vector<vector<int>> v(n,vector<int>(n,0));
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    v[a-1][b-1]=1;
    v[b-1][a-1]=1;
  }
  vector<int> p(n);
  for(int i=0;i<n;i++)
    p[i]=i;
  int ans=0;
  do
  {
    if(p[0]!=0) break;
    if(check(p,v))
      ans++;
  }while(next_permutation(p.begin(),p.end()));
  
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256