akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int main(void){
    int n, p = 1;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        p *= i;
    }
    /*printf("%d\n", p);*/
    int dis[n][2];
    double sum = 0;
    for(int i = 0; i < n; i++){
        scanf("%d""%d", &dis[i][0], &dis[i][1]);
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i != j){
                /*printf("%d->%d:%lf\n", i + 1, j + 1, sqrt((dis[i][0] - dis[j][0] ) * (dis[i][0] - dis[j][0] ) + (dis[i][1] - dis[j][1] ) * (dis[i][1] - dis[j][1] )));*/
                sum += sqrt( (dis[i][0] - dis[j][0] ) * (dis[i][0] - dis[j][0] ) + (dis[i][1] - dis[j][1] ) * (dis[i][1] - dis[j][1] ) ) * p / n;
            }
        }
    }
    /*printf("%lf\n", sum);*/
    printf("%lf\n", (double)sum / p);
    return 0;
}

Measured memory_bytes: 128
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

MAXN = 10**6
MOD = 10**9 + 7

fact = [1] * MAXN
for i in range(1, MAXN):
  fact[i] = (fact[i-1] * i) % MOD

N, M = reads()
if abs(N-M) >= 2:
  print(0); exit()

ans = fact[N] * fact[M] * (2 if N == M else 1) % MOD
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#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); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#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);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int A, B, C, D; cin >> A >> B >> C >> D;

    if (A*B >= C*D) {
        cout << A*B << "\n";
    } else cout << C*D << "\n";

}


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

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

	char a[n][n + 1], b[m][m + 1];

	for(int i = 0; i < n; ++i)
		scanf("%s", a[i]);
	for(int i = 0; i < m; ++i)
		scanf("%s", b[i]);

	bool flag = 1;

	/*if(n == m){
		for(int k = 0; k < n; ++k){
			for(int l = 0; l < n; ++l){
				if(a[k][l] != b[k][l]){
					flag = 0;
				}
			}
		}
	}else{*/
		for(int i = 0; i <= n - m; ++i){
			for(int j = 0; j <= n - m; ++j){
				for(int k = 0; k < m; ++k){
					for(int l = 0; l < m; ++l){
						if(a[i + k][j + l] != b[k][l]){
							flag = 0;
							break;
						}else if(l == m - 1)
							flag = 1;
					}
				if(flag == 0)
					break;
				}
			if(flag == 1)
				break;
			}
		if(flag == 1)
			break;
		}
	//}
			
	if(flag == 1)
		cout << "Yes\n";
	else 
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    num=int(input())
    a.append([num-1,0]) #番号を１スタートから０スタートに
ans=-1
now=0
for i in range(n+100):
    now=a[now][0]
    if now==1:
        ans=i+1
        break
    if a[now][1]==1:
        break
    a[now][1]=1
print(ans)

Measured memory_bytes: 16372
#include<stdio.h>
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int a[m];
    int sum=0;
    for(int i=0;i<m;i++)
    scanf("%d",&a[i]);
    for(int i=0;i<m;i++){
        sum=sum+a[i];
        if(sum>n){
            printf("-1");
            //printf("%d ",i);
            return 0;
        }
    }
    printf("%d",n-sum);
    return 0;
}

Measured memory_bytes: 1716
N, K, Q = list(map(int, input().split()))

A_point = [K] * N

for _ in range(Q):
  A_point[int(input())-1] += 1

A_point = map(lambda x:x-Q, A_point)

for r in A_point:
  if r > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 8328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=100010;
int tp=0;
char s[N];
vector <int> q[N];
inline int solve(int n) {
    int x=++tp;
    for(auto i:q[n]) printf("%d %d\n",x,solve(i));
    return x;
}
int main() {
    scanf("%s",s+1);
    int n=strlen(s+1);
    for(int i=1;i<=n;i++) s[i]-='0';
    for(int i=1;i<=n;i++)
	if(s[i]!=s[n-i]) return cout<<-1,0;
    s[n]=1;
    for(int i=1,la=0;i<=n;i++)
	if(s[i]) {
	    int j=0;
	    if(!la) {
		if(i>1) return cout<<-1,0;
	    }
	    else {
		while(j+la<i) q[i].push_back(la),j+=la;
		while(j+1<i) q[i].push_back(1),++j;
	    }
	    la=i;
	}
    solve(n);
    return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void LCS_lenght(char *x,char *y){
  int i,j,m,n,c[1001][1001];;
  m=strlen(x+1);
  n=strlen(y+1);
  for(i=1;i<=m;i++){
    c[i][0]=0;
  }
  for(j=0;j<=n;j++){
    c[0][j]=0;
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i]==y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else if(c[i-1][j]>=c[i][j-1]){
	c[i][j]=c[i-1][j];
      }
      else {
	c[i][j]=c[i][j-1];
      }
    }
  }
  printf("%d\n",c[i-1][j-1]);
}

int main(){
  int i,numberofdataset;
  char x[1001],y[1001];

  scanf("%d",&numberofdataset);

  for(i=0;i<numberofdataset;i++){
    scanf("%s",x+1);
    scanf("%s",y+1);
    LCS_lenght(x,y);
  }

  return 0;
}

Measured memory_bytes: 4520
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

int R;
double x[200], y[200], r[200], v[200];
double dis[200];
bool used[200];

int main(){
	int a[5];
	while(cin >> a[0] && a[0]){
		rep2(i, 1, 5) cin >> a[i];
		rep(i, 5){
			int w = 0;
			int l = 0;
			rep(j, 5){
				if(i == j) continue;
				if((a[i] + 1) % 3 == a[j] % 3) w++;
				if((a[j] + 1) % 3 == a[i] % 3) l++;
			}
			if(w > 0 && l == 0) cout << 1 << endl;
			else if(w == 0 && l > 0) cout << 2 << endl;
			else cout << 3 << endl; 
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	float ans =0;
	if (N % 2 == 0){
		ans = 0.5;
	}else{
		float n = N;
		ans = ((n-1)/2+1)/n;
	}
	cout << ans;
	return 0;
}

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

int main(void) {
	string str;
	int len;
	int cnt = 0;

	cin >> str;

	len = str.length();

	for (int i = 0; i < len / 2; i++) {
		if (str[i] != str[len - i - 1]) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

using namespace std;

int main(){
    int x;
    int counter = 0;
    while(true){
        cin >> x;
        if(x==0) break;
        counter++;
        cout << "Case" << " " << counter << ": " << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 3080
import Data.List

bmi (p:h:w:_) =
  let h' = (fromIntegral h) / 100 :: Float
      w' = fromIntegral w :: Float
      bmi= w' / (h'*h')
  in
    (p, bmi)

ans' x =
  let b = map bmi x
      d = map (\ (i,b) -> (i,abs(b-22)) ) b
      s = sortBy (\ (i0,d0) (i1,d1) -> if d0 == d1
                                       then compare i0 i1
                                       else compare d0 d1 ) d
  in
    fst $ head s

ans ([0]:_) = []
ans ([n]:x) =
  let d = take n x
      r = drop n x
  in
    (ans' d):(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o

Measured memory_bytes: 5500
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b,c[110000];
pair<int,int> d[110000];
signed main()
{
	cin>>a>>b;
	b+=a*3;
	cout<<b/2;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp::min;

fn main() {
	input!(n: usize, h: [i32; n]);

	let mut dp = vec![0, (h[1] - h[0]).abs()];
	for i in 2..n {
		dp.push(min(dp[i-1] + (h[i] - h[i-1]).abs(), dp[i-2] + (h[i] - h[i-2]).abs()));
	}

	println!("{}", dp[n-1]);
}

Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

vector<int> Z_algorithm(string S) {
  int c = 0, n = S.size();
  vector<int> Z(n, 0);
  FOR(i, 1, n){
    int l = i - c;
    if (i + Z[l] < c + Z[c]) {
      Z[i] = Z[l];
    } else {
      int j = max(0ll, c + Z[c] - i);
      while (i + j < n && S[j] == S[i + j])
        j++;
      Z[i] = j;
      c = i;
    }
  }

  Z[0] = n;
  return Z;
}

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

  string s;
  cin >> s;

  int ans = 0;
  REP(i, N){
    vector<int> vec = Z_algorithm(s.substr(i));
    REP(j, vec.size()){
      chmax(ans, min(j, vec[j]));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
   SS(ll,n)
   ll ans=0;
   rep(i,n){
       string s=to_string(i+1);
       if(s.size()%2!=0)ans++;
   }
   p(ans);
}

Measured memory_bytes: 384
gets
l=gets.split.map{|c|[c.to_i]}
i=0
l.sort.map{|a|a[0]=i+=1}
b=[s=0]*r=l.size+1
l.reverse_each{|n,|i=n;(s+=b[i];i&=i-1)while i>0;(b[n]+=1;n+=n&-n)while n<r}
p s

Measured memory_bytes: 32616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

vector<int> to[100005];
bool seen[100005];

void dfs(vector<int>* G, int v) {
  seen[v] = true;
  for (int c: G[v]) {
    if (seen[c]) continue;
    dfs(G, c);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    to[x-1].push_back(y-1);
    to[y-1].push_back(x-1);
  }
  int ans = 0;
  rep(i, n) seen[i] = false;
  rep(i, n) {
    if (seen[i]) continue;
    dfs(to, i);
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8960
import sys
sys.setrecursionlimit(10000000)
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N, Q = LI()
P = [0] * N
V = [[] for _ in range(N)]

w = [0]*N
for i in range(N-1):
    A, B = LI()
    V[A-1].append(B-1)
    V[B-1].append(A-1)
#    AB[i] = LI()
for i in range(Q):
    p, x = LI()
    P[p-1] += x

#print(V)
for i in range(N):
    w[i] += P[i]

#i = int(0)
#for l in V:
#   for j in l:
#        print(i, j)
#        w[j] += w[i]
#        print(w)
#    i +=1
def solve(v,i):
#    print(v,i)
#    print(w)
#    print("#####")
    if not v[i]:
        return
    else:
        for l in v[i]:
            w[l] += w[i]
            v[l].remove(i)
            solve(v,l)
        return
i =int(0)
solve(V,i)

print(" ".join(map(str,w)))


Measured memory_bytes: 240220
#include<stdio.h>
#include<string.h> 
char a[20000]={0};
int main()
{
	int n,l,i;
	scanf("%d",&n);
	scanf("%s",a);
	l=strlen(a);
	for(i=0;i<l;i++)
	{
		if(a[i]+n<='Z')
		printf("%c",a[i]+n) ;
		else
		{
			a[i]+=n;
			while(a[i]>'Z')
			{
			a[i]=a[i]-'Z'+'A'-1;
			}
			printf("%c",a[i]);
		}
		
	}
	printf("\n");
}

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

using namespace std;

int main(){
    
    int M,N;
    
    scanf("%d%d",&M,&N);
    
	vector<tuple<int,int,int>> vec;
	
	for(int i=0;i<M;i++){
	    
		int l,r,x;
		
		scanf("%d%d%d",&l,&r,&x);
		
		vec.emplace_back(x,l-x,r-x);
	}
	
	vector<int> Time(N);
	
	set<int> st;
	
	for(int i=0;i<N;i++){
	    
		scanf("%d",&Time[i]);
		
		st.insert(Time[i]);
	}
	
	sort(vec.begin(),vec.end());
	
	map<int,int> ans;
	
	for(int i=0;i<M;i++){
	    
		int cor=get<0>(vec[i]),l=get<1>(vec[i]),r=get<2>(vec[i]);
		
		auto it1=st.lower_bound(l);
		
		auto it2=st.lower_bound(r);
		
		vector<int> done;
		
		while(it1!=it2){
		    
			ans[*it1]=cor;
			
			done.push_back(*it1);
			
			it1++;
		}
		
		for(int x : done) st.erase(x);
	}
	for(int i=0;i<N;i++){
	    
		if(ans.count(Time[i])) cout<<ans[Time[i]]<<endl;
		
		else cout<<"-1"<<endl;
	}
	
	return 0;
	
}    


Measured memory_bytes: 22128
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef struct _tmp_t {
  int val;
} tmp_t;

int compare(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;
  int    X,Y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  X = x->val % 10;
  if (X == 0) {
    X = 10;
  }
  Y = y->val % 10;
  if (Y == 0) {
    Y = 10;
  }

  if (X < Y) return 1;
  if (X > Y) return -1;

  return 0;
}

void qsort_tmp (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare);
}

#define SIZE 5

tmp_t order[SIZE];

int main()
{
  int cnt;
  int i;
  int total = 0;

  for (i=0; i<SIZE; i++) {
    cnt = scanf("%d", &order[i].val);
  }

  qsort_tmp(order, SIZE);

  for (i = 0; i < SIZE; i++) {
    total += order[i].val;
    if (i < (SIZE - 1)) {
      if ((order[i].val % 10) != 0) {
        total += (10 - (order[i].val % 10));
      }
    }
  }

  printf("%d", total);

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int h, w;
char s, t;
string mas[55];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> h >> w >> s >> t;
  rep(i, h) cin >> mas[i];

  vector<Pi> pos(30, Pi(-1, -1));
  rep(i, h) {
    rep(j, w) {
      if(isupper(mas[i][j])) {
	pos[mas[i][j]-'A'] = Pi(i, j);
      }
    }
  }

  const int dy[] = {1, 0, -1, 0};
  const int dx[] = {0, 1, 0, -1};

  auto in = [&](int i, int j) {
    return 0<=i&&i<h&&0<=j&&j<w;
  };

  int ss = s-'A', tt = t-'A';
  queue<int>  que;
  vint dist(30, -1);
  que.push(ss);
  dist[ss] = 0;
  while(!que.empty()) {
    int u = que.front(); que.pop();
    rep(i, 4) {
      int ny = pos[u].first+dy[i], nx = pos[u].second+dx[i];
      ny += dy[i];
      nx += dx[i];
      int cnt = 0;
      while(in(ny, nx) && (((i==0||i==2) && mas[ny][nx] == '|') || ((i==1||i==3) && mas[ny][nx] == '-'))) {
	ny += dy[i];
	nx += dx[i];
	++cnt;
      }
      if(cnt == 0) continue;
      ny += dy[i];
      nx += dx[i];
      if(!in(ny, nx) || !isupper(mas[ny][nx])) continue;
      int v = mas[ny][nx]-'A';
      if(dist[v] != -1) continue;
      dist[v] = dist[u]+1;
      que.push(v);
    }
  }

  cout << dist[tt] << endl;

  return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll n;
    cin>>n;
    map<map<ll, ll>, ll> mp;
    rep(i, n) {
        string s;
        cin>>s;
        ll m = s.size();
        map<ll, ll> temp;
        rep(j, m) {
            temp[s[j] - 'a']++;
        }
        mp[temp]++;
    }

    ll ans = 0;
    for (auto m : mp) {
        ans += m.second * (m.second - 1) / 2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 62336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
ll arr[1000];
int main()
{
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>arr[i];
	for(int i=1;i<=n;i++){
		if(arr[i]%2!=0&&i%2!=0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
// https://atcoder.jp/contests/abc115/tasks/abc115_c

#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, k, hmin = INT_MAX;
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    int h[n];

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

    // 小さい順に並び替えた後、k個の高さの差を計算する
    for (int i = 0; i < n - k + 1; i++) {
        hmin = min(hmin, h[i + k - 1] - h[i]);
    }

    cout << hmin << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>


int main(){
char op;
int a,b;

while(1){
scanf("%d %c %d",&a,&op,&b);

if (op == '+'){
 printf("%d\n",a+b);
}

if (op == '-'){
 printf("%d\n",a-b);
}

if (op == '*'){
printf("%d\n",a*b);
}

if (op == '/'){
 printf("%d\n",a/b);
}

if (op =='?'){
 break;
}

}
return 0;

}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
int main() {
	int N, i, j, flag = 0, flag8 = 0;
	cin >> N;
	for (i = 1;i <= N;i++) {
		for (j = 1;j <= N;j++) {
			if (i%j == 0) {
				flag++;
			}
		}
		if (flag == 8 && i%2 == 1) {
			flag8++;
		}
		flag = 0;
	}
	cout << flag8 << endl;
}

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

using namespace std;

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

double fact[9], pt[9];
pair< int, int > arr[6] = {
    {0, 1},
    {0, 2},
    {0, 3},
    {1, 2},
    {1, 3},
    {2, 3}};


double goal(int p)
{
  return (fact[8] * pow(0.25, p) * pow(0.75, 8 - p) / fact[p] / fact[8 - p]);
}

double calc(int team, vector< pair< int, int > > &match)
{
  int rank[4] = {};
  queue< int > que;
  que.push((1 << 4) - 1);
  while(!que.empty()) {
    int bit = que.front();
    int win[4] = {}, get[4] = {}, lost[4] = {}, appear[4] = {};
    que.pop();
    vector< int > latte;
    rep(i, 4) if((bit >> i) & 1) latte.push_back(i);
    for(int i = 0; i < match.size(); i++) {
      if(bit & (1 << arr[i].first) && bit & (1 << arr[i].second)) {
        if(match[i].first == match[i].second) ++win[arr[i].first], ++win[arr[i].second];
        else if(match[i].first > match[i].second) win[arr[i].first] += 3;
        else win[arr[i].second] += 3;
        get[arr[i].first] += match[i].first;
        get[arr[i].second] += match[i].second;
        lost[arr[i].first] += match[i].second;
        lost[arr[i].second] += match[i].first;
      }
    }

    for(int i : latte) {
      for(int j : latte) {
        auto comp = win[i] - win[j];
        if(comp == 0) comp = (get[i] - lost[i]) - (get[j] - lost[j]);
        if(comp == 0) comp = get[i] - get[j];
        if(comp < 0) ++rank[i];
      }
    }
    for(int i : latte) appear[rank[i]] |= 1 << i;
    for(int i = 0; i < 4; i++) {
      if(appear[i] == bit) continue;
      if(__builtin_popcount(appear[i]) >= 2) que.emplace(appear[i]);
    }
  }
  int appear[4] = {};
  rep(i, 4) appear[rank[i]] |= 1 << i;
  int tail = rank[team] + __builtin_popcount(appear[rank[team]]);
  if(rank[team] < 2) return (min(1.0, (2.0 - rank[team]) / (tail - rank[team])));
  return (0.0);
}


int main()
{
  fact[0] = 1;
  rep(i, 8) fact[i + 1] = fact[i] * (i + 1);
  rep(i, 9) pt[i] = goal(i);

  int N;
  string S[5];

  cin >> N;
  while(N--) {
    rep(i, 5) cin >> S[i];

    vector< pair< int, int > > match;
    vector< int > unknown;
    int team;

    rep(i, 5) {
      if(S[i][0] == '*') team = i - 1;
      rep(j, 24) {
        if(S[i][j] == '-') {
          if(isdigit(S[i][j + 1])) match.emplace_back(S[i][j - 1] - '0', S[i][j + 1] - '0');
          else unknown.push_back(match.size()), match.emplace_back(-1, -1);
        }
      }
    }

    double ret = 0;
    rep(i, 9) {
      rep(j, 9) {
        rep(k, 9) {
          rep(l, 9) {
            match[unknown[0]] = {i, j};
            match[unknown[1]] = {k, l};
            ret += pt[i] * pt[j] * pt[k] * pt[l] * calc(team, match);
          }
        }
      }
    }

    cout << fixed << setprecision(10) << ret << endl;
  }
}

Measured memory_bytes: 3468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod)
{
        if (n == 0) return 1;
        ll res = mod_pow(x * x % mod, n / 2, mod);
        if (n & 1) res = res * x % mod;
        return res;
}

int main() {
        int n, a;
        map<int, int> count;
        long long ans = 0;

        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> a;
                count[a]++;
        }
        if (n % 2)
                if (count[0] != 1)
                        goto end;
        for (int i = 1; i < n; i += 2)
                if (count[n-i] != 2)
                        goto end;

        ans = mod_pow(2, n / 2, (1e9) + 7);

end:
        cout << ans << endl;
        return 0;
}


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

using namespace std;

typedef long long ll;

string s;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> s;
  if (s == "ABC") cout << "ARC";
  else if (s == "ARC") cout << "ABC";
}

Measured memory_bytes: 3648
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

void solve(){
	int n;
	cin>>n;
	int a[n][3];
	rep(i,0,n)rep(j,0,3)cin>>a[i][j];
	int t1=a[0][0],t2=a[0][1],t3=a[0][2];
	int maxa[3];
	maxa[0]=t1;
	maxa[1]=t2;
	maxa[2]=t3;
	rep(i,1,n){
		//cout<<t1<<" "<<t2<<" "<<t3<<" "<<endl;
		maxa[0]=max(t2+a[i][0],t3+a[i][0]);
		maxa[1]=max(t1+a[i][1],t3+a[i][1]);
		maxa[2]=max(t2+a[i][2],t1+a[i][2]);
		t1=maxa[0];
		t2=maxa[1];
		t3=maxa[2];
	}
	cout<<max(max(maxa[0],maxa[1]),maxa[2])<<endl;
	
}
int main()
{
	waste;
	int t;
//	cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 1408
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=300005;

ll extendedeuclid(ll a,ll b,ll &x,ll &y)
{
    if(a==0)
    {
        x=0;
        y=1;
        return b;
    }
    ll g,x1,y1;
    g=extendedeuclid(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return g;
}

void solve()
{
    int inv,y;
    int g=extendedeuclid(10,2019,inv,y);
    
    //cout<<g<<endl;
    string s;
    cin>>s;
    int n=s.length();
    int pr[n+1];
    pr[0]=1;
    for(int i=1;i<=n;i++)
        pr[i]=(pr[i-1]*inv)%2019;
    int pre=0;
    map<int,int>mp;
    mp[pre]++;int ans=0;
    for(int i=1;i<=n;i++)
    {
        pre=(pre*10+s[i-1]-'0')%2019;
        int z=(pre*pr[i])%2019;
        ans=ans+mp[z];
        mp[z]++;
    }
    cout<<ans<<endl;
    
    
}

int32_t main()
{
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int n,k;
  cin >> n >> k;
  cout << ll(k * pow(k-1,n-1)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#define FOR(i,n) for(unsigned i=0; i<n; i++)

using namespace std;

typedef unsigned us;
typedef pair<us, us> point;

int main () {
    us V, E;
    cin >> V >> E;

    set<us> seen;
    seen.insert(0);
    map<us, vector<point> > graph;
    priority_queue<point, vector<point>, greater<point> > q;
    us distance = 0;

    FOR(_, E) {
        us s, t, d;
        cin >> s >> t >> d;
        graph[s].push_back(make_pair(d, t));
        graph[t].push_back(make_pair(d, s));
        if (s == 0) q.push(make_pair(d, t));
        if (t == 0) q.push(make_pair(d, s));
    }

    while (!q.empty() && seen.size() != V) {
        point p = q.top();
        us v = p.second;
        us w = p.first;
        q.pop();

        if (seen.find(v) == seen.end()) {
            seen.insert(v);
            vector<point> neighbours = graph[v];
            FOR(i, neighbours.size()) q.push(neighbours[i]);
            distance += w;
        }
    }

    cout << distance << endl;

}



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

int main() {
 
  vector<int> suuji(3); 
  for (int i = 0; i < 3; i++) {
    cin >> suuji[i];
  }
    sort(suuji.begin(), suuji.end()); // {1, 2, 2, 5}

  if(suuji[1] == 5 && suuji[0] == 5 && suuji[2] == 7){
  	cout << "YES" << endl;
  }
  else{
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
using namespace std;
int main(void)
{
	ll n, k, i, j;
	cin>>n>>k;
	ll a[n], dp[n];
	for(i=0; i<n; i++)
		cin>>a[i];
	dp[n-1] = 0;
	for(i=n-2; i>=0; i--)
	{
		dp[i] = dp[i+1] + abs(a[i+1] - a[i]);
		for(j = i+1; j<=min(n-1, i+k); j++)
			dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
	}
	cout<<dp[0]<<"\n";
}	

Measured memory_bytes: 1792
H, W, A, B = list(map(int, input().split()))
 
# 事前計算 + 演算ごとに mod する
def solve():
    # 組合せの計算用に階乗を事前計算しておく
    MOD = 10 ** 9 + 7
    FACT = [0] * (H + W + 1)
    INV_FACT = [0] * (H + W + 1)  # 逆元. 組合せの計算ごとにMODを取るため
 
    FACT[0], INV_FACT[0] = 1, 1
    for i in range(1, (H + W + 1)):
        FACT[i] = (FACT[i - 1] * i) % MOD
        INV_FACT[i] = pow(FACT[i], MOD - 2, MOD)  # フェルマーの小定理を使う
 
    def mod_nCr(n, r):
        if n < r or n == 0 or r == 0:
            return 1
 
        return FACT[n] * (INV_FACT[r] * INV_FACT[n - r]) % MOD
 
    # print(H, W, A, B)
 
    # 座標は(x, y). startは(0, 0)
    goal = W - 1, H - 1
 
    # 境界点: 移動できないエリアの右上の点
    nx = B - 1
    ny = H - A
 
    # 境界点から右斜め上に1つ移動した点(choke_left)から, 右端へ伸びる線がchoke points
    choke_left = nx + 1, ny - 1
 
    choke_points = []
    for i in range(B, W):
        choke_points.append((i, choke_left[1]))
 
    # 組合せを計算する: startからcp1, cp2からgoalまで組合せを掛ける
    ans = 0
    for cp1 in choke_points:
        x, y = cp1
        from_start_to_cp1 = mod_nCr(x + y, x)
 
        # cp1から1つ下の点がcp2
        y += 1
        dx, dy = goal[0] - x, goal[1] - y
        from_cp2_to_goal = mod_nCr(dx + dy, dx)
 
        ans = ans % MOD + (from_start_to_cp1 * from_cp2_to_goal % MOD) % MOD
 
    return ans % MOD
 
res = solve()
print(res)

Measured memory_bytes: 29040
using System;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace Tutorial
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            decimal inp = decimal.Parse(input);

            Console.WriteLine(Math.Ceiling(inp / 1000)*1000 - inp);


        }
    }
}


Measured memory_bytes: 27624
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    loop = 0
    #temp2 = temp
    temp = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        lst_a[loop] //= 2
        cnt += 1
        temp = max(temp,lst_a[loop])
        if cnt == m:
            #print(lst_a)
            print(sum(lst_a))
            sys.exit()
        if temp > max(lst_a[loop],lst_a[loop + 1]):
            break
        if lst_a[loop + 1] > lst_a[loop]:
            loop += 1
        
        
        
"""        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))
"""

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

#define cc 1000000007

int main()
{
	ll N,K; //N no of children
	cin>>N>>K;
	 ll arr[N];  ll dp[N+1][K+1];
	 ll f=K+1;ll g=N+1; ll presum[N+1][K+1];
	 memset(dp, 0, sizeof(dp[0][0]) * g * f);
       memset(presum, 0, sizeof(presum[0][0]) * g * f); 	 
	 

	 for(ll i=0;i<N;i++)
	 { cin>>arr[i];}
	 
	 for(ll i=0;i<=K;i++)
	 {
	 	if(arr[0]>=i)
		 {dp[1][i]=1;}
		 
		 if(i==0)
		 {presum[1][i]=dp[1][i];}
		 
		 else
		 {
		 	presum[1][i]=presum[1][i-1]%cc+dp[1][i]%cc;
		 }
	 }
	 

 for(ll p=2;p<=N;p++)
{
	for(ll candy=0;candy<=K;candy++)
	{
		if(candy<=arr[p-1])
		{
			dp[p][candy]=(dp[p][candy]%cc+presum[p-1][candy]%cc)%cc;
			
		}
		else
		{
			dp[p][candy]=(dp[p][candy]%cc+presum[p-1][candy]%cc-presum[p-1][candy-1-arr[p-1]]%cc)%cc;
		}
		
			if(candy>=1)
			{
			presum[p][candy]=(dp[p][candy]%cc+presum[p][candy-1]%cc)%cc;
		    }
		    else
		    {
		    	presum[p][candy]=dp[p][candy];	
			}
	}

}
cout<<(dp[N][K]+cc)%cc<<endl;	 
	 
	
	 
}



Measured memory_bytes: 158080
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    A = int(readline())
    print(N ** 2 - A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61764
#include <bits/stdc++.h>
using namespace std;
int N;
vector<string> A;
int f(int p) {
	int r = 1;
	for (int i = 0; i < N; ++ i) {
		if (A[i][p] == '#') {
			r = 0;
			break;
		}
	}
	for (int j = 0; j < N; ++ j) {
		if (A[p][j] == '.') ++ r;
	}
	for (int j = 0; j < N; ++ j) {
		bool ok = true;
		for (int i = 0; i < N; ++ i) {
			if (A[i][j] == '.') { ok = false; break; }
		}
		if (!ok) ++ r;
	}
	return r;
}
int func() {
	cin >> N;
	A.resize(N);
	for (auto& x : A) cin >> x;
	bool flag = false;
	for (int i = 0; i < N; ++ i) for (int j = 0; j < N; ++ j) if (A[i][j] == '#') flag = true;
	if (!flag) return -1;
	int r = 1<<30;
	for (int i = 0; i < N; ++ i) {
		r = min(r, f(i));
	}
	return r;
}
int main() {
	cout << func() << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
	int L,R,d,i,ans=0;
	scanf("%d %d %d",&L,&R,&d);
	for(i=0;;i++){
		int b=d*i;
		if(L<=b && b<=R) ans++;
		if(b>=R) break;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

#define x first
#define y second
#define pb push_back

using namespace std;

typedef long long ll;

int main(void) {
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;

  if (a <= 0 && b >= 0) cout << "Zero" << endl;
  else if (a < 0) {
    if ((b - a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  } else {
    cout << "Positive" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
	int sec,hour,min,sechour,secmin,secm,secs;
	scanf ("%d",&sec);
	sechour = 60*60;
	secmin = 60;
	hour = sec/sechour;
	secm = sec - (hour*sechour);
	min = secm/secmin;
	secs = secm - (min*secmin);
	sec = secs;
	printf ("%d:%d:%d\n",hour,min,sec);
	
	return 0;
}


Measured memory_bytes: 2140
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC158
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var ab = ReadIntArray();
            var a = ab[0];
            var b = ab[1];

            for (int i = 1; i <= 1000; i++)
            {
                if ((int)(0.08 * i) == a && (int)(0.1 * i) == b)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(-1);
        }

        #region Console
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13268
import numpy as np

N,M,C=map(int,input().split())
B=np.array(list(map(int,input().split())))
A=np.array([list(map(int,input().split())) for i in range(N)])
cnt=0
for i in range(N):
    if (A[i]*B).sum()+C>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 12428
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	static int n=s.nextInt();
	static int[] x=new int[n],y=new int[n],h=new int[n];

	static int nonzero=-1;

	static{
		for(int i=0;i<n;++i){
			x[i]=s.nextInt();
			y[i]=s.nextInt();
			h[i]=s.nextInt();
			if(h[i]>0)
				nonzero=i;
		}
	}

	public static void main(String[] $){
		for(int Y=0;Y<=100;++Y){
			loop:
			for(int X=0;X<=100;++X){
				int k=h(Y,X,nonzero);
				for(int i=0;i<n;++i){
					int ph=h(Y,X,i);
					if(k>ph||(k<ph&&h[i]>0))
						continue loop;
				}
				System.out.println(X+" "+Y+" "+k);
				return;
			}
		}
	}
	static int h(int Y,int X,int i){
		return h[i]+Math.abs(X-x[i])+Math.abs(Y-y[i]);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string ANS = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i, 16) {
        if (S[i] != ANS[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
input()
x = [float(i) for i in input().split()]
y = [float(i) for i in input().split()]
print("{:.6f}".format(sum([abs(i - j) for i, j in zip(x, y)])))
print("{:.6f}".format(sum([(i - j) ** 2 for i, j in zip(x, y)]) ** 0.5))
print("{:.6f}".format(sum([abs(i - j) ** 3 for i, j in zip(x, y)]) ** (1/3)))
print("{:.6f}".format(max([abs(i - j) for i, j in zip(x, y)])))


Measured memory_bytes: 5652
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
        if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j]:
          ans += 1

print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll a,b,c;cin >> a >> b >> c;
  YesNo(c-a-b>0 && 4*a*b < (c-a-b)*(c-a-b));
  return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())

n,m=reads()
link=[[]for i in range(n)]
for i in range(m):
  x,y=reads()
  link[x-1].append(y-1)
#print(link)
@lru_cache(None)
def dp(k):
  res=0
  for ele in link[k]:
    res=max(res,dp(ele)+1)
  return res
res=1
for i in range(n)  :
  res=max(res,dp(i))
print(res)

Measured memory_bytes: 137100
import sys

N = int(input())

if N == 1:
    print(1)
    sys.exit()

coor = []
for i in range(N):
    (x,y) = (int(i) for i in input().split())
    coor.append((x,y))
    
diffs = []
for i in range(N-1):
    for j in range(i+1, N):
        diffs.append((coor[j][0]-coor[i][0], coor[j][1]-coor[i][1]))
        diffs.append((coor[i][0]-coor[j][0], coor[i][1]-coor[j][1]))

m = 1

for i in range(N*(N-1)):
    times = 0
    for j in range(N*(N-1)):
        if diffs[i] == diffs[j]:
            times += 1
    if times > m:
        m = times

ans = N - m   

print(ans)


Measured memory_bytes: 3316
#pragma warning (disable : 4996)
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <utility>
using namespace std;
#define omajinai ios::sync_with_stdio(false);cin.tie(nullptr);

#pragma region typedef 
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> P;
#pragma endregion

#pragma region define
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#pragma endregion

#pragma region const
const ld PI = 3.141592653589793;
const ll INF18 = 1e18;
#pragma endregion

#pragma region function
template<class T>inline bool chmin(T& a,T b){
    if(a>b){a=b;return true;}return false;}
template<class T>inline bool chmax(T& a,T b){
    if(a<b){a=b;return true;}return false;}
#pragma endregion



int main() {
omajinai;

  int a, b, c;
  cin >> a >> b;
  cout << a*b << endl;
return 0;
}


Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++)
    {
        cin >> D[i];
    }
    int ans = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans += D[i] * D[j];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long


int main(){
  int q=998244353;
  int N;
  cin >> N;
  vector<int> D(N);
  vector<int> d(N,0);
  for(int i=0; i<N; i++){
    cin >> D[i];
    d[D[i]]++;
  }
  if(D[0] != 0){
    cout << 0 << endl;
    return 0;
  }
  
  if(d[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  
  ll ans=1;
  for(int i=1; i<N; i++){
    for(int j=0; j<d[i]; j++){
      ans = (ans*(ll)d[i-1])%q;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for(int i = 0; i < N; i++)
    {
        cin >> P.at(i);
    }

    int count = 1;
    int min = P.at(0);

    for(int i = 1; i < N; i++)
    {
        if(min > P.at(i))
        {
            count++;
            min = P.at(i);
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll s; cin>>s;
  if(s==1e18){
      ll x=1e9;
      cout<<0<<" "<<0<<" "<<0<<" "<<x<<" "<<x<<" "<<x<<endl;
      return 0;
  }
  ll t=sqrt(s-1);
  t++;
  ll rem=t*t-s;
  cout<<0<<" "<<0<<" "<<1<<" "<<t<<" "<<t<<" "<<rem<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> v,vt,vs;
string s,t;
int main() {
	cin>>s;
	int n=(int)s.length();
	for(int i=0;i<n;i++) if (s[i]!='x') t+=s[i];
	int m=(int)t.length();
	for(int i=0;i+i<m;i++) if (t[i]!=t[m-i-1]) {
		printf("-1");return 0;
	}
	for(int i=0;i<n;i++) if (s[i]=='x') v.push_back(i); else vt.push_back(i);
	vt.push_back(n);
	int j=0;
	for(int i=0;i<=m;i++) {
		vs.push_back(0);
		while (j<(int)v.size()&&v[j]<vt[i]) vs.back()++,j++;
	}
	int ans=0;
	for(int i=0;i+i<(int)vs.size();i++) {
		int x=vs[i]-vs[(int)vs.size()-1-i];
		if (x<0) x=-x;
		ans+=x;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1724
MAX_DIGIT = 4

N = int(input())
num = []

n = N
for i in range(MAX_DIGIT)[::-1]:
    num.append(int(n % 10))
    n /= 10
num.reverse()

for i in range(1 << (MAX_DIGIT - 1)):
    s = num[0]
    ans = str(num[0])
    for j in range(MAX_DIGIT - 1):
        if i >> j & 1 == 1:
            s += num[j + 1]
            ans = ans + "+" + str(num[j + 1])
        else:
            s -= num[j + 1]
            ans = ans + "-" + str(num[j + 1])
    if s == 7:
        print(ans + "=7")
        exit()



Measured memory_bytes: 3316