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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define bk back()
#define pb push_back

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(x,a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
    // cin.exceptions(cin.failbit);
    // throws exception when do smth illegal
    // ex. try to read letter into int
    if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int32_t main() {

    setIO();

    int N,K; cin >> N >> K;

    vi arr(N);
    trav(x,arr) cin >> x;

    while(K--) {
        vi b(N);
        F0R(i,N) {
            int R = min(N-1,i+arr[i]), L = max(0,i-arr[i]);
            b[L]++; 
            if (R+1 < N) b[R+1]--;       
        }

        F0R(i,N) {
            if (i > 0) b[i] += b[i-1];
        }

        if (arr == b) break;
        arr = b;
    }

    trav(x,arr) cout << x << " ";
}


Measured memory_bytes: 4996
K = 32
P = 998244353
m = int(("1" * 2 + "0" * 30) * 3001, 2)
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
pa = (1 << 30) - ((1 << 30) % P)

M = []
N, S = map(int, input().split())
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
    s += 1
    s += s << a * K
    s &= mm
    s -= ((s & m) >> 30) * pa
    ans += (s >> S * K) & mmm

print(ans % P)

Measured memory_bytes: 3316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] cnt = new int[26];
		foreach(var c in W) cnt[ c -'a' ]++;
		
		bool chk = true;
		foreach(var n in cnt) chk &= (n % 2 == 0);
		Console.WriteLine(chk ? "Yes":"No");
		
	}
	String W;
	public Sol(){
		W = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, B,C;
	string S, T;
	VI A(N);
	cin >> N >> M;
	int sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	rSORT(A);
	int ans = 0;
	REP(i, N) {
		if (A[i] >= (double)sum / (4 * M))ans++;
	}
	if (ans >= M)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


ll lcm(ll x, ll y){
  	if(x == y){return x;}
  	// x > y とする.
	if(x<y){
		ll temp = x;
      	x = y;
      	y = temp;
    }
  	ll X = x;
  	ll Y = y;  
	ll r;
  	while(y != 0){	
	  	r = x%y;
      	x = y;
      	y = r;
    }
  	// gcd = x
  	return X*(Y/x);
}

void Main()
{
	ll N;
  	cin >> N;
  	vector<ll> T(N);
  	rep(i,N) cin >> T[i];
  	
  	ll ans = 1;
  	rep(i,N) {
		ans = lcm(ans,T[i]);
    }
	cout << ans << endl;
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s.size() < 4) cout << "No\n";
  else {
    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
import math
import statistics

while(1):
    n=int(input())
    if(not n):
        break
    S=list(map(int,input().split(" ")))
    mean=statistics.mean(S)
    #print(mean)
    S=list(map(lambda x: (x-mean)**2, S))
    #print(S)
    print(math.sqrt(sum(S)/n))



Measured memory_bytes: 7100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	ll o[100000][3];
	ll a[100000], b[100000], c[100000];
	for(ll i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
		o[i][0]=max(o[i-1][1],o[i-1][2])+a[i];
		o[i][1]=max(o[i-1][0],o[i-1][2])+b[i];
		o[i][2]=max(o[i-1][0],o[i-1][1])+c[i];
	}
	ll ams=max(o[n][0],o[n][1]);
	ll ans=max(ams,o[n][2]);
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) (v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        ll ah,am,sh,sm,k;
        cin>>ah>>am>>sh>>sm>>k;
        ll tt=(sh-ah)*60;
        if(sm>=am)tt+=sm-am;
        else tt-=am-sm;
        cout<<tt-k<<endl;


return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//

int main(){
  int N;cin>>N;
  bool flag =false;
  rep(i,26){
    rep(j,15){
      if(N==(4*i)+(7*j)){
        flag=true;
        break;
      }
    }
  }
   if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3600
// E - Virus Tree 2

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

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct ModInt {
	long long val;
	constexpr ModInt(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr ModInt operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr ModInt operator + (const ModInt& r) const noexcept { return ModInt(*this) += r; }
	constexpr ModInt operator - (const ModInt& r) const noexcept { return ModInt(*this) -= r; }
	constexpr ModInt operator * (const ModInt& r) const noexcept { return ModInt(*this) *= r; }
	constexpr ModInt operator / (const ModInt& r) const noexcept { return ModInt(*this) /= r; }
	constexpr ModInt& operator += (const ModInt& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr ModInt& operator -= (const ModInt& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr ModInt& operator *= (const ModInt& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr ModInt& operator /= (const ModInt& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const ModInt& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const ModInt& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const ModInt<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr ModInt<MOD> modpow(const ModInt<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

const int MOD = 1000000007;
using mint = ModInt<MOD>;

struct Node {
	vector<int> neighbors;
	bool visited = false;
};

int N, K;
mint ans;
vector<Node> nodes;

void dfs(int node_idx) {
	nodes[node_idx].visited = true;
	int i = 0;
	for (int next_node_idx :nodes[node_idx].neighbors) {
		if (nodes[next_node_idx].visited == false) {
			//cout << "K=" << K << " i=" << i << endl; // **** debug ****
			ans *= K - 2 - i;
			//cout << ans << endl; // **** debug ****
			dfs(next_node_idx);
			i++;
		}
	}
}

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

	nodes = vector<Node>(N);

	int a, b;
	for (int i=0; i<N-1; i++) {
		cin >> a >> b;
		a--;
		b--;
		nodes[a].neighbors.push_back(b);
		nodes[b].neighbors.push_back(a);
	}

	if (K == 1) {
		if (N == 1) cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}

	if (K == 2) {
		if (N <= 2) cout << 2 << endl;
		else cout << 0 << endl;
		return 0;
	}

	ans = K;
	nodes[0].visited = true;
	for (int i=0; i<nodes[0].neighbors.size(); i++) {
		ans *= K - 1 - i;
		dfs(nodes[0].neighbors[i]);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    unordered_set<string> us;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        us.insert(s);
    }
    cout << us.size() << endl;
}

Measured memory_bytes: 17704
#include <iostream>                                                                                    
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
int main () {
 int a, b, c;
 cin >> a >> b >> c;
 if (a + b + c >= 22) {
   cout << "bust" << endl;
 } else  {
   cout << "win" << endl;
 }
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
  	cin >> a >> b >> c;
  	string s;
 	if((a < c && b > c)||(a > c && b < c)){
     	 s = "Yes";
    }else{
     	s = "No"; 
    }
  
  	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define ll long long
#define x 100010

using namespace std;

int main(){
	cin.tie(0);
	
	int n,m;cin >> n >> m;

	int h[x],c[x];
	for(int i=1;i<=n;i++){
		cin >> h[i];
		c[i]=0;
	}

	rep(i, m){
		int a,b;cin >> a >> b;
		c[a]=max(c[a],h[b]);
		c[b]=max(c[b],h[a]);
	}

	int sum=0;
	for(int i=1;i<=n;i++){
		if(h[i] > c[i]){
			sum++;
		}
	}
	cout << sum << endl;

}


Measured memory_bytes: 4408
import sys
from heapq import *
I=sys.stdin.readlines()
N,M,S=map(int,I[0].split())
S=min(S,2499)
G=[[] for i in range(2500*N)]
u,v,a,b=0,0,0,0
for i in range(M):
  u,v,a,b=map(int,I[i+1].split())
  u,v=u-1,v-1
  for j in range(a,2500):
    G[u+j*N].append((v+(j-a)*N,b))
    G[v+j*N].append((u+(j-a)*N,b))
for i in range(N):
  a,b=map(int,I[M+i+1].split())
  for j in range(a,2500):
    G[i+(j-a)*N].append((i+j*N,b))
D=[0]*(2500*N)
INF=10**15
def ijk(s):
  global D,INF,G
  for i in range(len(G)):
    D[i]=INF
  D[s]=0
  Q=[]
  heapify(Q)
  heappush(Q,(0,s))
  p,v,e=0,0,0
  while len(Q):
    p=heappop(Q)
    v=p[1]
    if D[v]<p[0]:
      continue
    for i in range(len(G[v])):
      e=G[v][i]
      if D[e[0]]>D[v]+e[1]:
        D[e[0]]=D[v]+e[1]
        heappush(Q,(D[e[0]],e[0]))

ijk(S*N)
for i in range(1,N):
  print(min(D[i::N]))

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int x, y;
    cin >> x >> y;
    REP(i, x+1) {
        if(i*2+(x-i)*4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3608
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var res = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var buf = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            for (int i = 1; i < num; i++)
                res[i] += res[i - 1];

            for (int i = num - 2; 0 <= i; i--)
                buf[i] += buf[i + 1];

            var ans = 0;

            for (int i = 0; i < num; i++)
                if (ans < res[i] + buf[i])
                    ans = res[i] + buf[i];

            Console.WriteLine(ans);

        }

    }

}


Measured memory_bytes: 11348
w = input()
cnt = 0
while True:
    line = input()
    if line == 'END_OF_TEXT':
        break

    line = line.lower()
    pos = 0
    start = 0
    inWord = False
    while pos < len(line):
        if line[pos] == ' ':
            if inWord:
                if w == line[start:pos]:
                    cnt += 1
                inWord = False
        else:
            if not inWord:
                start = pos
                inWord = True
        pos += 1
    if inWord and w == line[start:]:
        cnt += 1

print(cnt)



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

using namespace std;
#define int long long
int mat[3005][3005];
int dp[3005][3005][4];
signed main() {
    int r, c, k;
    cin >> r >> c >> k;
    int i, j;
    for(i=1;i<=k;i++)
    {
        int x, y, w;
        cin >> x >> y >> w;
        mat[x][y] = w;
    }
    for(i=1;i<=r;i++)
        for(j=1;j<=c;j++)
        {
            if(mat[i][j] == 0)
            {
                dp[i][j][0] = max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3]});
                dp[i][j][1] = dp[i][j-1][1];
                dp[i][j][2] = dp[i][j-1][2];
                dp[i][j][3] = dp[i][j-1][3];
            }
            else
            {
                dp[i][j][0] = 0;
                dp[i][j][1] = max(dp[i][j-1][1], mat[i][j] + max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3]}));
                dp[i][j][2] = max(dp[i][j-1][2], mat[i][j] + dp[i][j-1][1]);
                dp[i][j][3] = max(dp[i][j-1][3], mat[i][j] + dp[i][j-1][2]);
            }
        }
    cout << max({dp[r][c][0], dp[r][c][1], dp[r][c][2], dp[r][c][3]});
}

Measured memory_bytes: 355796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	//0002
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			String str = br.readLine();
			while(true){
				if(str == null){
					break;
				}
				String[] st = str.split(" ",0);
				int a =  Integer.parseInt(st[0]);
				int b = Integer.parseInt(st[1]);
				int sum = a+b;
				System.out.println(String.valueOf(sum).length());
				str = br.readLine();
			}
		}catch(Exception ex){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 24072
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←


#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/
struct Timer {
    int64_t start;
    const int64_t CYCLES_PER_SEC = 2800000000;
    Timer() { reset(); }
    void reset() { start = getCycle(); }
    inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
    inline int64_t getCycle() {
        uint32_t low, high;
        __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((int64_t)low) | ((int64_t)high << 32);
    }
};


bool multicase = false;

ll n, m, k, w, num, a, b, c, d, e, h, q, ans, sum, l;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

void solve(){
    cin >> n;
    vec x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if (x[i] < x[j] && x[j] < x[k] && x[i] + x[j] > x[k]) ans ++;
            }
        }
    }
    p(ans);
    return;
}

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



Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

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

        try {
            while ((line = br.readLine()) != null) {
                int numOfCards = Integer.parseInt(line);
                if (numOfCards == 0) {
                    break;
                }

                List<Integer> aCards = new ArrayList<>();
                List<Integer> bCards = new ArrayList<>();
                for (int i = 0; i < numOfCards; i++) {
                    line = br.readLine();
                    String[] cardsStr = line.split(" ");
                    aCards.add(Integer.parseInt(cardsStr[0]));
                    bCards.add(Integer.parseInt(cardsStr[1]));
                }
                List<Integer> result = calcScore(aCards, bCards);
                System.out.println(String.format("%d %d", result.get(0), result.get(1)));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static List<Integer> calcScore(List<Integer> aCards, List<Integer> bCards) {
        Integer aScore = 0;
        Integer bScore = 0;

        if (aCards.size() != bCards.size()) {
            throw new IllegalArgumentException("??????????????°?????°??????");
        }

        Iterator<Integer> aCardsIter = aCards.iterator();
        Iterator<Integer> bCardsIter = bCards.iterator();
        while (aCardsIter.hasNext() && bCardsIter.hasNext()) {
            Integer aCard = aCardsIter.next();
            Integer bCard = bCardsIter.next();
            if (aCard > bCard) {
                aScore += aCard + bCard;
            } else if (aCard < bCard) {
                bScore += aCard + bCard;
            } else {
                aScore += aCard;
                bScore += bCard;
            }
        }

        List<Integer> score = Arrays.asList(aScore, bScore);
        return score;
    }
}

Measured memory_bytes: 37064
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	cout<<a[n]-a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    map<ll,ll> mp;
    ll i,j,k;
    rep(i,n) mp[v[i]]++;
    set<ll> s;
    rep(i,n) s.insert(v[i]);
    vector<ll> w;
    for(auto itr=s.begin();itr!=s.end();++itr) w.push_back(*itr);
    //rep(i,w.size()) cout<<w[i]<<" ";
    for(i=0;i<w.size();i++){
        for(j=i+1;j<w.size();j++){
            for(k=j+1;k<w.size();k++){
                //cout<<w[i]<<" "<<w[j]<<" "<<w[k]<<endl;
              if(w[i]<w[j]+w[k]&&w[j]<w[i]+w[k]&&w[k]<w[j]+w[i]) {
                  sum+=mp[w[i]]*mp[w[j]]*mp[w[k]];
              }
            }
        }
    }
    cout<<sum<<endl;

    return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int n, q;
  string s;
  cin >> n >> s >> q;

  while (q--) {
    int k;
    cin >> k;

    ll ans = 0, a = 0, b = 0, m = 0;
    for (int i = 0; i < k; i++) {
      if (s[i] == 'D') a++;
      else if (s[i] == 'M') {
        m++;
        b += a;
      } else if (s[i] == 'C') ans += b;
    }

    for (int i = 1; i <= n - k; i++) {
      if (s[i - 1] == 'D') {
        a--;
        b -= m;
      } else if (s[i - 1] == 'M') m--;

      if (s[i + k - 1] == 'D') a++;
      else if (s[i + k - 1] == 'M') {
        m++;
        b += a;
      } else if (s[i + k - 1] == 'C') ans += b;
    }

    cout << ans << '\n';
  }
}


Measured memory_bytes: 1948
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    ans = []
    for i in range(1,N):
        for j in range(i+1,N+1):
            if not j == (N - i + (N%2==0)):
                ans.append((i,j))
    print(len(ans))
    for x in ans:
        print(x[0],x[1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 44652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		int a[] = new int[n];

		long sum = 0;
		long min = Long.MAX_VALUE;
		long count = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
			sum += Math.abs(a[i]);
			min = Math.min(min, Math.abs(a[i]));
			if (a[i] < 0)
				count++;
		}

		if (count % 2 == 0)
			System.out.println(sum);
		else
			System.out.println(sum - 2 * min);
	}
}

Measured memory_bytes: 45780
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n; cin >> n;
	vector<long long>L(n+1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i < n+1; i++){
		L[i] = L[i - 2] + L[i - 1];
	}
	cout << L[n] << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
while True:
    n, m = list(map(int, input().split()))
    if n == 0 and m == 0: break

    taro = []
    hanako = []
    for i in range(n):
        taro.append(int(input()))
    for i in range(m):
        hanako.append(int(input()))

    sum_taro = sum(taro)
    sum_hana = sum(hanako)
    dif = sum_taro - sum_hana
#    print("taro:",taro)
#    print("hana:",hanako)
#    print("dif:",dif)

    ans_t, ans_h = 101, 101 # 0 <= point <= 100
    for t in taro:
        for h in hanako:
            if (sum_taro - t + h) == (sum_hana - h + t) \
                    and (t + h) < (ans_t + ans_h):
                        ans_t, ans_h = t, h
    if (ans_t + ans_h) == 202:
        print(-1)
    else:
        print(ans_t, ans_h)

#    sign_t = 1
#    sign_h = 1
#    if sum_taro < sum_hana:
#        sign_h = -1
#    elif sum_taro > sum_hana:
#        sign_t = -1
#    #if dif = 0 do nothing
#
#    print("signs(t,h):",sign_t, sign_h) 
#    for t in taro:
#        for h in hanako:
#            t *= sign_h
#            h *= sign_t
#            if (sum_taro + h) == (sum_hana + t):
#                print(abs(t), abs(h))
#                break
#        else:
#            continue
#        break
#    else:
#        print(-1)

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

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

    vector<int> black_cnt(N + 1);
    vector<int> white_cnt(N + 1);
    rep(i, N) {
        int black = (S[i] == '#') ? 1 : 0;
        black_cnt[i + 1] = black_cnt[i] + black;

        int white = (S[i] == '.') ? 1 : 0;
        white_cnt[i + 1] = white_cnt[i] + white;
    }

    int ans = N;
    rep(i, N + 1) { // i番目以降をblackにする
        int cnt = black_cnt[i] + white_cnt[N] - white_cnt[i];
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2180
#include <cstdio>
int main() {
	for (int ix=1;;ix++) {
		int n; scanf("%d",&n);
		if (n==0) break;
		printf("Case %d:\n",ix);
		int f[n][n];
		int nx=0,ny=0;
		if (n%2==0) {
			for (int i=1; i<=n*n; i++) {
				f[nx][ny]=i;
				if (nx==n-1&&ny%2==0) ny++;
				else if (nx==n-1) {
					nx--;
					ny++;
				}
				else if (ny==n-1&&nx%2!=0) nx++;
				else if (ny==n-1) {
					nx++;
					ny--;
				}
				else if (nx==0&&ny%2==0) ny++;
				else if (nx==0) {
					nx++;
					ny--;
				}
				else if (ny==0&&nx%2!=0) nx++;
				else if (ny==0) {
					nx--;
					ny++;
				} 
				else if ((nx+ny)%2==0) {
					nx--;
					ny++;
				}
				else {
					nx++;
					ny--;
				}
			}
		} else {
			for (int i=1; i<=n*n; i++) {
				f[nx][ny]=i;
				if (nx==n-1&&ny%2!=0) ny++;
				else if (nx==n-1) {
					nx--;
					ny++;
				}
				else if (ny==n-1&&nx%2==0) nx++;
				else if (ny==n-1) {
					nx++;
					ny--;
				}
				else if (nx==0&&ny%2==0) ny++;
				else if (nx==0) {
					nx++;
					ny--;
				}
				else if (ny==0&&nx%2!=0) nx++;
				else if (ny==0) {
					nx--;
					ny++;
				} 
				else if ((nx+ny)%2==0) {
					nx--;
					ny++;
				}
				else {
					nx++;
					ny--;
				}
			}
		}
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				printf("%3d",f[i][j]);
			}
			printf("\n");
		}
	}
}

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

int main()
{
    int n;
    int Min,Max;
    string src;
    
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> src;
        sort(begin(src),end(src));
        Min = stoi(src);
        sort(begin(src),end(src),greater<char>());
        Max = stoi(src);
        cout << Max - Min << endl;
    }
}

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

int main(){
  ll x;
  cin >> x;
  ll n = 100;
  ll ans = 0;
  while(1){
    n *= 1.01;
    ++ans;
    if(n >= x){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    vector<char> vc;
    long long int n;
    long long int k;
    long long int p = 1;
    long long int in = 1;
    long long int m=0;
    cin >> n;
    for(int  i = 0; i < 12; i++ ){
        m++;
        in *=26;
        p = in +p;
        if(n <= p-1){
            k = n- (p-in-1);
            break;
        }
    }
    k--;
    //cout << k  << endl;
    rep(i,m){
        vc.push_back(k%26 +'a');
        k/=26;
    }
    reverse(vc.begin(),vc.end());
    for(auto c:vc){
        cout << c;
    }
    cout << endl;
}

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

int main() {
    string s;
    cin >> s;
    string ans="Yes";
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-1-i]){
            ans="No";
        }
    }
    int m=(n-1)/2;
    string s1=s.substr(0,m);
    for(int i=0;i<m;i++){
        if(s1[i]!=s1[m-1-i]){
            ans="No";
        }
    }
    string s2=s.substr((n+3)/2-1);
    for(int i=0;i<m;i++){
        if(s2[i]!=s2[m-1-i]){
            ans="No";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        string[] number = ReadLine().Split(' ');
        long wa = 0;
        long count1 = 0;
        long ans = 0;
        for(int i=0;i<kazu;i++){
            long numi = int.Parse(number[i]);
            long temp = wa + numi;
            if(i%2==0){
                if(temp > 0){
                    wa = temp;
                }else{
                    count1 += Abs(temp) +1;
                    wa = 1;
                }
            }else{
                if(temp < 0){
                    wa = temp;
                }else{
                    count1 += Abs(temp) +1;
                    wa = -1;
                }
            }
        }
        
        long count2 = 0;
        wa = 0;
        for(int i=0;i<kazu;i++){
            long numi = int.Parse(number[i]);
            long temp = wa + numi;
            if(i%2==1){
                if(temp > 0){
                    wa = temp;
                }else{
                    count2 += Abs(temp) +1;
                    wa = 1;
                }
            }else{
                if(temp < 0){
                    wa = temp;
                }else{
                    count2 += Abs(temp) +1;
                    wa = -1;
                }
            }
        }
        
        WriteLine(Min(count1,count2));
    }
}


Measured memory_bytes: 26332
#include<iostream>

int _gcd(int x, int y){
  if(x == 0){
    return y;
  }else{
    return _gcd(y % x, x);
  }
}
int gcd(int x, int y){
  // if(x < y){
  //   return _gcd(x, y);
  // }else{
  //   return _gcd(y, x);
  // }

  if(x < y){
    int t = x; x = y; y = t;
  }
  while(y > 0){
    int r = x % y;
    x = y;
    y = r;
  }

  return x;
}

int main(){
  int x, y;
  std::cin >> x;
  std::cin >> y;

  std::cout << gcd(x, y) << std::endl;
 
  return 0;
}



Measured memory_bytes: 3100
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val cs = LongArray(n - 1)
    val ss = LongArray(n - 1)
    val fs = LongArray(n - 1)
    repeat(n - 1) {
        val (c, s, f) = readLongList()
        cs[it] = c
        ss[it] = s
        fs[it] = f
    }

    for (i in 0 until (n - 1)) {
        var x = ss[i] + cs[i]
        for (j in (i + 1) until (n - 1)) {
            x = if (x <= ss[j]) {
                ss[j] + cs[j]
            } else {
                val w = (x - ss[j] + fs[j] - 1) / fs[j]
                ss[j] + fs[j] * w + cs[j]
            }
        }
        out.println(x)
    }
    out.println(0)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 37144
/*
 *  Author : Jun_SH
 *  Solution for sumitrust2019 146 E
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int maxn=1e5+10;
int a[maxn];
int cnt[3];
map<int,int>mp;
const int mod=1000000007;
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int ans=1;
    mp[-1]=1;
    int tp=0;
    for(int i=1;i<=n;++i){
        ans*=mp[a[i]-1];
        mp[a[i]]++;
        if(a[i]) mp[a[i]-1]--;
        else tp++;
        ans%=mod;
    }
    if(tp==1){
        ans*=3;
        ans%=mod;
    }
    else if(tp==2||tp==3){
        ans*=6;
        ans%=mod;
    }
    else ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 7296
import numpy as np

(N,M) = map(int,input().split())
A = list(map(int,input().split()))
costs = [0,2,5,5,4,5,6,3,7,6]

match = [-1]*(N+1)
match[0] = 0
for i in range(1,N+1):
  for a in A:
    if i < costs[a]:
      continue
    else:
      match[i] = max(match[i],match[i-costs[a]]*10+a)

print(match[N])

Measured memory_bytes: 23352
using System;
using System.Linq;

namespace AOJ01
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string ans = "Close";
            if ((d[0] == 1 && d[1] == 1 && d[2] == 0) || (d[0] == 0 && d[1] == 0 && d[2] == 1)) { ans = "Open"; }
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 9324
h,w,k=map(int,input().split())
mod=10**9+7
dp=[[0]*w for _ in range(h)]
D=[[0]*w for _ in range(w)]
for i in range(2**(w-1)):
    s='0'+bin(i)[2:].rjust(w-1,'0')+'0'
    if '11' in s:continue
    for i in range(w-1):
        if s[i+1]=='1':
            D[i][i+1]+=1
            D[i+1][i]+=1
    for i in range(w):
        if s[i:i+2]=='00':
            D[i][i]+=1
dp[0]=D[0]
for i in range(1,h):
    for j in range(1,w):
        dp[i][j]+=dp[i-1][j-1]*D[j-1][j]
    for j in range(w-1):
        dp[i][j]+=dp[i-1][j+1]*D[j+1][j]
    for j in range(w):
        dp[i][j]+=dp[i-1][j]*D[j][j]
        dp[i][j]%=mod
print(dp[-1][k-1])

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int A,B;
  cin >> A >> B;
  vector<int> k(A);
  froop1(0,A){
    cin >> k.at(i);
  }
  sort(k.begin(),k.end());
  int c = 0;
  froop1(0,B){
    c += k.at(i);
  }
  cout << c << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

int w[1<<18], v[1<<18], dp[520][N];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> v[i] >> w[i];
	}
	int m = min(n, 512);
	for(int i = 1; i <= m; i++) {
		for(int j = 0; j < N; j++) {
			if(j - w[i] >= 0)
				dp[i][j] = max(dp[i/2][j], dp[i/2][j-w[i]] + v[i]);
			else
				dp[i][j] = dp[i/2][j];
		}
	}
	int q;
	cin >> q;
	while(q--) {
		int x, l;
		cin >> x >> l;
		vi tt;
		while(x > m) {
			tt.PB(x);
			x /= 2;
		}
		int mx = 0;
		for(int mask = 0; mask < (1 << (tt.size())); mask++) {
			int w_tot = 0, v_tot = 0;
			for(int i = 0; i < tt.size(); i++) {
				if(mask >> i & 1) {
					w_tot += w[tt[i]];
					v_tot += v[tt[i]];
				}
			}
			if(w_tot <= l) {
				mx = max(mx, v_tot + dp[x][l - w_tot]);
			}
		}
		cout << mx << '\n';
	}
	
}





Measured memory_bytes: 205664
#include<bits/stdc++.h>
using namespace std;
string s;
int n,sum=0,maxn=0;
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='D') sum--;
		else sum++;
		maxn=max(maxn,sum);
	}
	cout<<maxn<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>

using namespace std;
int main(void){
    int a,b;
    double X;
    cin >> a >> b;
    X=a*b/ 3.305785;
    cout << fixed << setprecision(8) << X << endl;
    
    
}



Measured memory_bytes: 3292
n,k = gets.chomp.split.map &:to_i
p = 10 ** 9 + 7
counter = 0

$cum_sum = [0]
(1..n+1).each do |i|
  $cum_sum << $cum_sum[-1] + i
end

def calc(k)
  min =  $cum_sum[k] - $cum_sum[0]
  max = $cum_sum[-1] - $cum_sum[-1 - k]
  return max - min + 1
end

(k..n+1).each do |i|
  counter += calc(i) % p
end

puts counter % p


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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

using ll = long long;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    ll result = 0;
    FOR(i, 1, N + 1) {
        result += (ll) i * (N - i + 1);
    }
    REP(_, N - 1) {
        int u, v;
        cin >> u >> v;
        if (u > v) {
            swap(u, v);
        }
        result -= (ll) u * (N - v + 1);
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3648
//
// Created by 26019 on 2020/6/14/014.
//

#include <iostream>
using namespace std;

int main() {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if (x1 ==0) {
        cout << "1" << endl;
    }
    if (x2 ==0) {
        cout << "2" << endl;
    }
    if (x3 ==0) {
        cout << "3" << endl;
    }
    if (x4 ==0) {
        cout << "4" << endl;
    }
    if (x5 ==0) {
        cout << "5" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> as(N);
  for (auto i = 0; i < N; i++) cin >> as[i];


  if (N == K) {
    cout << 1 << endl;
  }else {
    cout << (N-1 + K-2) / (K - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let n = read::<usize>();
    let a: Vec<i64> = read_vec();
    let mut dp0 = vec![0; n];
    let mut dp1 = vec![0; n];
    dp0[0] = a[0];
    dp1[0] = a[0];

    for i in 1..n {
        dp0[i] = gcd(dp0[i - 1], a[i]);
        dp1[i] = max(dp0[i - 1], gcd(dp1[i - 1], a[i]));
    }
    let mut temp = 1;
    if n > 0 {
        temp = a[1];
        for i in 2..n {
            temp = gcd(a[i], temp);
        }
    }
    println!("{}", max(dp1[n - 1], temp));
}


Measured memory_bytes: 8444
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N;ll ans = 0; cin >> N;
    vector<int>A(N + 1);
    map<int, int>cnt;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        ans += cnt[i-A[i]  ];
        cnt[i + A[i]]++;
       
        }
cout << ans << endl;
}


Measured memory_bytes: 21060
//#define _GLIBCXX_DEBUG
    #include <iostream>
    #include <bits/stdc++.h>
     
     
    using namespace std;
    #define ll long long
    #define ld long double
    #define  P pair<ll,ll>
    #define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
    #define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
    #define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
    #define sortAl(v) sort(v.begin(),v.end())
    #define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
    #define cout(n) cout<<fixed<<setprecision(n)
     
    int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        ll n;
        cin>>n;
        vector<ll> v(n);
        FOR(i,0,n) cin>>v[i];
        FOR(i,0,n){
            ll x;
            cin>>x;
            v[i]-=x;
        }
        ll ans = 0;
        FOR(i,0,n)ans += max(v[i], (ll)0);
        cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 1000
#define N 10000

int graph[MAX][MAX];
int d[MAX];
int n;

int Q[N];
int max=0,min=0;

void enQ(int q){
  Q[max]=q;
  max++;
}

int deQ(){
  min++;
  return Q[min-1];
}

int size(){
  return max-min;
}

void bfs(int i){
  int j;
  for(j=0;j<n;j++){
    if(graph[i][j]==1 && d[j]==-1){
      d[j]=d[i]+1;
      enQ(j);
    }
  }
}

int main(){
  int i,j,a,b,c;

  scanf("%d",&n);

  for(i=0;i<MAX;i++) d[i]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      graph[a-1][c-1]=1;
    }
  }
  d[0]=0;
  bfs(0);

  while(size()!=0) bfs(deQ());

  for(i=0;i<n;i++) printf("%d %d\n",i+1,d[i]);

  return 0;
}

Measured memory_bytes: 988
#include<stdio.h>

int calc(int number, int flag);

int main(){
	int a,b;
	int count = 0;
	scanf("%d",&a);

	if(a - 2000 < 1000 && a >= 2000){
		count++;
	}
	a = calc(a,1);
	if(a - 200 < 100 && a >= 200){
		count++;
	}
	a = calc(a,2);
	if(a - 20 < 10 && a >= 20){
		count++;
	}
	a = calc(a,3);
	if(a - 2 < 1 && a >= 2){
		count++;
	}
	printf("%d\n",count);
	return 0;
}

int calc(int number, int flag){
	if(flag == 1){
		while(number >= 1000){
			number = number - 1000;
		}
	}
	else if(flag == 2){
		while(number >= 100){
			number = number - 100;
		}
	}
	else if(flag == 3){
		while(number >= 10){
			number = number - 10;
		}
	}
	
	return number;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>M;
    vec a(N), b(M);
    rep(i,N) cin>>a[i], --a[i];
    rep(i,M) cin>>b[i], --b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    a.push_back(-1);
    b.push_back(-1);
    ll row, col, ans = 1;
    row = col = 0;
    for(ll i = N*M - 1; i >= 0; --i){
        if(i == a[row] && i == b[col]){
            ++row; ++col;
        }else if(i == a[row]){
            ++row;
            (ans *= col)%=MOD;
        }else if(i == b[col]){
            ++col;
            (ans *= row)%=MOD;
        }else{
            (ans *= max(0LL, row*col - (N*M - 1 - i)))%=MOD;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int n, a;

    cin >> n;

    bool ans = true;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a;

        if (a % 2 == 0)
        {
            if (a % 3 && a % 5)
                ans = false;
        }
    }

    if (ans)
        cout << "APPROVED\n";
    else
        cout << "DENIED\n";

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y){}
	Point operator - (Point p) {return (Point(x - p.x, y - p.y));}
};

double cross(Point a, Point b)
{
	return (a.x * b.y - a.y * b.x);
}

int ccw(Point x, Point y)
{
	if (cross(x, y) > 0) return (+1);
	return (0);
}

int main()
{
	Point a, b, c, d;
	
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &d.x, &d.y) != EOF){
		int dir = ccw(b - a, c - a) + ccw(c - b, d - b) + ccw(d - c, a - c) + ccw(a - d, b - d);
		printf("%s\n", dir % 4 ? "NO" : "YES");
	}
	return (0);
}

Measured memory_bytes: 1036