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

const int XN=100+11;
const long long INF=1e18;

typedef std::array<std::array<long long,26>,26> X;

template <class T>
bool Reduce(T &a,T const &b) {
    return a>b?a=b,1:0;
}

X Merge(X const &a,X const &b) {
    X c;
    for(int i=0;i<26;++i)
        for(int j=0;j<26;++j) {
            c[i][j]=INF;
            for(int k=0;k<26;++k)
                for(int h=0;h<26;++h)
                    if(h!=k)
                        Reduce(c[i][j],a[i][k]+b[h][j]);
        }
    return c;
}

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
    //freopen("input","r",stdin);
    static X f[XN];
    static char s[XN];
    std::cin>>(s+1);
    int n=strlen(s+1),k;
    std::cin>>k;
    for(int i=0;i<=n;++i)
        for(int c0=0;c0<26;++c0)
            for(int c1=0;c1<26;++c1)
                f[i][c0][c1]=INF;
    for(int c=0;c<26;++c)
        f[1][c][c]=(s[1]-'a'!=c);
    for(int h=0;h<26;++h)
        for(int i=2;i<=n;++i)
            for(int t0=0;t0<26;++t0)
                for(int t1=0;t1<26;++t1)
                    if(t0!=t1)
                        Reduce(f[i][h][t1],f[i-1][h][t0]+(s[i]-'a'!=t1));
    X base=f[n],res={};
    for(;k;k>>=1,base=Merge(base,base))
        if(k&1)
            res=Merge(res,base);
    long long Ans=1e18;
    for(int c0=0;c0<26;++c0)
        for(int c1=0;c1<26;++c1)
            Reduce(Ans,res[c0][c1]);
    std::cout<<Ans<<'\n';
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	
	vector<LL> b, s;
	{
		vector<int> a(n);
		inc(i, n) { cin >> a[i]; }
		sort(ALL(a));
		inc(i, n) {
			if(i == 0 || a[i] != a[i - 1]) { b.PB(0); }
			b.back()++;
		}
		sort(RALL(b));
		s = vector<LL>(SI(b) + 1);
		dec(i, SI(b)) { s[i] = s[i + 1] + b[i]; }
	}
	
	inc1(k, n) {
		if(k > SI(b)) { cout << 0 << "\n"; continue; }
		
		auto f = [&](int v) { return fl(s[v], k - v); };
		
		int ok = k, ng = -1;
		while(abs(ok - ng) > 1) {
			int v = (ok + ng) / 2;
			(f(v) >= b[v] ? ok : ng) = v;
		}
		
		cout << f(ok) << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 7020
#include <stdio.h>
#define n_max 45

int main(){
  int n, i;
  int fib[n_max];
  
  scanf("%d",&n);
  
  fib[0]=1;
  fib[1]=1;
  for(i=2;i<=n;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }

  printf("%d\n",fib[n]);
  return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

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

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

long long A, B, C, D;

int main(int argc, char **argv) {
    std::cin >> A >> B >> C >> D;
    
    long long total = B - A + 1;

    long long div_c = (B/C) - ((A-1)/C);
    long long div_d = (B/D) - ((A-1)/D);

    long long dc = lcm(C, D);
    long long div_cd = (B/dc) - ((A-1)/dc);

    //std::cout << total << " " << div_c << " " << div_d << " " << div_cd << std::endl;

    std::cout << total - div_c - div_d + div_cd << std::endl;
    

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        r: u64
    }

    let ret = if r < 1200 {
        "ABC"
    } else if r < 2800 {
        "ARC"
    } else {"AGC"};
    println!("{}", ret);
}

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

int f[10][5];


int main(void){
  int H;
  while(cin >> H, H){
    int score = 0;
    for(int i=0; i < H; i++){
      for(int j=0; j < 5; j++){
        cin >> f[i][j];
      }
    }
    while(1){
      bool noch = true;
      for(int p=0; p < H; p++){
        for(int q=0; q < 5; q++){
          int flg = 0;
          int cnt = 0;
          int st;
          for(int r=q+1; r < 5; r++){
            if(f[p][q] != f[p][r])
              break;
            if(f[p][q] == f[p][r] && r-q >= 2){
              flg = f[p][q];
              cnt = r-q+1;
              st = q;
            }
          }
          if(flg){
            for(int i=q; i < q+cnt; i++){
              f[p][i] = 0;
            }
            noch = false;
            score += cnt * flg;
          }
        }
      }
      for(int p=H-1; p > 0; p--){
        for(int q=0; q < 5; q++){
          if(f[p][q] == 0){
            for(int r=p-1; r >= 0; r--){
              if(f[r][q] != 0){
                f[p][q] = f[r][q];
                f[r][q] = 0;
                break;
              }
            }
          }
        }
      }

      if(noch) break;
    }
    cout << score << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import bisect

n,k=map(int,input().split())
x=list(map(int,input().split()))

zero_ind=bisect.bisect_left(x,0)
"""
print("max",0,k-zero_ind-1)
print("min",k,n-zero_ind)
print("max",1,k-n+zero_ind-1)
print("min",k,zero_ind+2)
"""
v,w=10**9,10**9
if(n-zero_ind >= k):v=abs(x[zero_ind+k-1])
if(zero_ind >= k):w=abs(x[zero_ind-k])

y=[10**9]
z=[10**9]

if(zero_ind != 0 and zero_ind != n):
    for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind)):
        if(zero_ind+i<0 or zero_ind+i>=n or zero_ind-(k-i)+1<0 or zero_ind-(k-i)+1>=n):continue
        y.append(abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]))
    for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2)):
        if(zero_ind-i<0 or zero_ind-i>=n or zero_ind+(k-i)-1<0 or zero_ind+(k-i)-1>=n):continue
        z.append(abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]))
    """
    y=[abs(x[zero_ind+i])+abs(x[zero_ind+i]-x[zero_ind-(k-i)+1]) for i in range(max(0,k-zero_ind-1),min(k,n-zero_ind))]
    z=[abs(x[zero_ind-i])+abs(x[zero_ind-i]-x[zero_ind+(k-i)-1]) for i in range(max(1,k-n+zero_ind-1),min(k,zero_ind+2))]
    """

"""
for i in range(k):
    print(abs(x[zero_ind+i]))
    print(x[zero_ind-(k-i)+1])

for i in range(1,k):
    print(abs(x[zero_ind-i]))
    print(x[zero_ind+(k-i)-1])
"""
print(min([v,w]+y+z))
"""
print(y)
print(z)
"""

Measured memory_bytes: 14252
n, k=[int(w) for w in input().split()]
lim=100*1000+1
c=[0]*lim
for i in range(n):
    a, b=[int(w) for w in input().split()]
    c[a]+=b
for i in range(lim):
    k-=c[i]
    if k<=0:
        print(i)
        break


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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int main(){
    int n;
    while (cin >> n, n){
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        sort(all(a));
        unsigned long long ans = 0, s = 0;
        rep(i, n){
            ans += a[i] * (n - i - 1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;
int n;
int arr[50];
int mods[50];
int goal, ind;
vector<bitset<50> > save[50];
int cnts[50][50];
bool blocked[50][2000];
int sze[50];
void func(int num, bitset<50> res){
    if (num == goal){
        save[ind].push_back(res);
        return;
    }
    if (num == 0){
        return;
    }
    for (int i=1; i<=num; i++){
        res[i-1] = 1;
        func(num%i, res);
        res[i-1] = 0;
    }
}
int main(){
  prep();
  cin >> n;
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  for (int i=0; i<n; i++){
      cin >> mods[i];
  }
  for (int i=0; i<n; i++){
      if (mods[i] >= ceil((double)arr[i]/2) && mods[i] != arr[i]){
          cout << -1;
          return 0;
      }
  }
  for (int i=0; i<n; i++){
      goal = mods[i];
      ind = i;

      bitset<50> empty(0);
      func(arr[i], empty);
      sze[i] = save[i].size();
      
  }
  for (int i=0; i<n; i++){
      for (int j=0; j<save[i].size(); j++){
          for (int k=0; k<50; k++){
              if (save[i][j][k]){
                  cnts[i][k]++;
              }
          }
      }
  }
  long long cost = 0;
  for (int i=49; i>=0; i--){
      bool manditory = false;
     
      for (int j=0; j<n; j++){
          if (cnts[j][i] == sze[j]){
              manditory = true;
              break;
          }
      }
      if (manditory){
          cost += pow(2, i+1);
      }else{
          for (int j=0; j<n; j++){
              for (int k=0; k<save[j].size(); k++){
                  if (save[j][k][i] && !blocked[j][k]){
                      for (int l=0; l<50; l++){
                          if (save[j][k][l]){
                              cnts[j][l]--;
                          }
                      }
                      blocked[j][k] = true;
                      sze[j]--;
                  }
              }
          }
      }
  }
  cout << cost;
  return 0; 
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main () {
	int a = ri(), b = ri();
	int n = ri();
	bool res = false;
	for (int i = 0; i < n; i++) {
		int s = ri(), t = ri();
		if (s >= b || t <= a) continue;
		res = true;
	}
	std::cout << res << std::endl;
	return 0;
}



Measured memory_bytes: 3232
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

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

    int H, W;
    i64 c[12][12];
    memset(c, 0x3f, sizeof(c));

    cin >> H >> W;
    for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j <= 9; ++j) {
            cin >> c[i][j];
        }
    }

    for (int k = 0; k <= 9; ++k) {
        for (int i = 0; i <= 9; ++i) {
            for (int j = 0; j <= 9; ++j) {
                chmin(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }


    i64 ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int a; cin >> a;
            if (a != 1 && a != -1) ans += c[a][1];
        }
    }

    cout << ans << endl;

    return 0;
}

// vim: set foldmethod=marker :


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
ll N, W;
int main() {
	scanf("%lld%lld", &N, &W);
	vector<ll> w(N), v(N);
	vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
	rep(i, 0, N)scanf("%lld%lld", &w[i], &v[i]);
	rep(i, 0, N) {
		rep(i2, 0, W + 1) {
			if (i2 >= w[i]) dp[i + 1][i2] = max(dp[i][i2 - w[i]] + v[i], dp[i][i2]);
			else dp[i + 1][i2] = dp[i][i2];
			//printf("%lld ", dp[i + 1][w]);
		}
		//puts("");
	}
	ll ans = 0;
	rep(i, 0, W + 1)ans = max(ans, dp[N][i]);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 80256
s = input()
t = input()
#a = list(map(int,input().split()))
m = 1001

#print(len(s))
for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if(s[i+j]!=t[j]):
      count += 1
  m = min(m,count)
  
print(m)

Measured memory_bytes: 73192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;

	int d[110];

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		cin >> d[i];
	}

	sort(d+1, d + N+1,greater<int>());

	d[0] = 9999999999;

	for (int i = 1; i <= N; i++) {
		if (d[i] < d[i - 1])ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = set(map(int, input().split()))

res = 1000
for i in range(-1, 102):
    if i not in p:
        res = min(res, abs(x - i))

if x - res in p:
    print(x + res)
else:
    print(x - res)


Measured memory_bytes: 9120
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

// #include"binary_heap.cpp"
// #include"d_heap.cpp"
// #include"pqueue.cpp"

template<class T>
class d_heap_for_Dijkstra{
	static const int N_MAX=100;
	int n,d,key[N_MAX],pos[N_MAX];
	T val[N_MAX];

	void sift_up(int i,const T &x){
		val[i]=x;
		while(i!=0 && val[(i-1)/d]>val[i]){
			int p=(i-1)/d;
			swap(pos[key[p]],pos[key[i]]);
			swap(key[p],key[i]);
			swap(val[p],val[i]);
			i=p;
		}
	}
	void sift_down(int i,const T &x){
		val[i]=x;
		for(int j,k,c;;i=j){
			j=i;
			for(c=0,k=d*i+1;c<d;c++,k++) if(k<n && val[j]>val[k]) j=k;
			if(j==i) break;
			swap(pos[key[j]],pos[key[i]]);
			swap(key[j],key[i]);
			swap(val[j],val[i]);
		}
	}
public:
	d_heap_for_Dijkstra(int d):n(0),d(d){}
	int find_min()const{ return key[0]; }
	void insert(int u,const T &x){
		int i=n++;
		key[i]=u;
		pos[u]=i;
		sift_up(i,x);
	}
	void delete_min(){
		n--;
		pos[key[n]]=pos[key[0]];
		key[0]=key[n];
		sift_down(0,val[n]);
	}
	void decrease_key(int u,const T &x){
		sift_up(pos[u],x);
	}
	bool empty()const{ return n==0; }
	int size()const{ return n; }
	// bool member(int u)const{ return pos[u]}
	void print(){
		puts("-------");
		printf("n=%d:\n",n);
		rep(i,n) printf("  key[%d] = %d, val[%d] = %d\n",i,key[i],i,val[i]);
		// rep(i,5) printf("  pos[%d] = %d\n",i,pos[i]);
		puts("-------");
	}
};

const int INF=1<<29;

struct edge{ int v,cost1,cost2; };

int main(){
	for(int m,n;scanf("%d%d",&m,&n),n;){
		vector<edge> G[100];
		rep(i,m){
			int u,v,cost1,cost2; scanf("%d%d%d%d",&u,&v,&cost1,&cost2); u--; v--;
			G[u].push_back((edge){v,cost1,cost2});
			G[v].push_back((edge){u,cost1,cost2});
		}

		int q; scanf("%d",&q);
		while(q--){
			int s,t,type; scanf("%d%d%d",&s,&t,&type); s--; t--;
// printf("s=%d, t=%d\n",s+1,t+1);

			int d[100];
			rep(u,n) d[u]=(u==s?0:INF);
			d_heap_for_Dijkstra<int> H(4);
			H.insert(s,0);
			while(!H.empty()){
// H.print();
				int u=H.find_min();
// printf("  u=%d, d[%d]=%d\n",u,u,d[u]);
				H.delete_min();

				rep(i,G[u].size()){
					const edge &e=G[u][i];
					int d2=d[u]+(type==0?e.cost1:e.cost2);
					if(d[e.v]>d2){
// printf("    v=%d, d2=%d\n",e.v,d2);
						if(d[e.v]==INF) H.insert(e.v,d2);
						else            H.decrease_key(e.v,d2);
						d[e.v]=d2;
					}
				}
			}

			printf("%d\n",d[t]);
		}
	}

	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
 
void fio() 
{
    std::ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
void inputread()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
const ld p=6.28318530717958623200;

int32_t main()
{
    fio();
    ll n,m,s=0,a,i;
    cin >> n >> m;
    for(i=0;i<m;i++)
    {
        cin >> a;
        s+=a;
    }
    if(s<=n)
    {
        cout << n-s;
    }
    else
    {
        cout << -1;
    }
    

    

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <functional>
#include <string>
 
using namespace std;

int main()
{
    int N;
    cin >> N;
    double result = 0;
    result = (double)(N-N/2)/N;
    cout << setprecision(10) << result;

    return 0;
}

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

int main(){
    map<string,int>s;
    map<string,int>t;
    int n,m;
    cin>>n;
    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        s[str]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>str;
        t[str]++;
    }
    int ans=0;
    for(auto i=s.begin();i!=s.end();i++){
        ans=max(ans,s[i->first]-t[i->first]);
    }
    cout<<ans<<endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M, 0));
  rep(i, N) {
    cin >> C[i];
    rep(j, M) { cin >> A[i][j]; }
  }
  int min = INF_INT;
  rep(i, BIT(N)) {
    int cost = 0;
    vector<int> AA(M, 0);
    rep(j, N) {
      if (i & BIT(j)) {
        cost += C[j];
        rep(k, M) { AA[k] += A[j][k]; }

      }
    }
    bool ok = true;
    rep(k, M) {
      if (AA[k] < X) ok = false;
    }
    if (ok) chmin(min, cost);
  }
  if(min == INF_INT) min = -1;
  cout << min << endl;
}

Measured memory_bytes: 3656
N = int(input())
A = list(map(int, input().split()))

min_a = min(A)
max_a = max(A)

ans = float('inf')

for i in range(min_a,max_a+1):
    num = 0
    for a in A:
        num += (a-i)**2
    ans = min(ans,num)

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
enum Query
{
    Min = 0,
    Max = 1,
};
std::istream &operator>>(std::istream &is, Query &i)
{
    int tmp;
    if (is >> tmp)
        i = static_cast<Query>(tmp);
    return is;
} //オペレーターオーバーロード
int main()
{
    vector<int> A;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        Query com;
        cin >> com;
        int b, e;
        cin >> b >> e;
        if (com == Min)
        {
            cout << *min_element(A.begin() + b, A.begin() + e) << endl;
        }
        else if (com == Max)
        {
            cout << *max_element(A.begin() + b, A.begin() + e) << endl;
        }
    }
}


Measured memory_bytes: 3156
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        pp: [usize;n]
    }
    let mut pp = pp;
    let mut cnt = 0;
    for i in 0..n {
        if i+1 == pp[i] {
            if i < n-1 {
                pp.swap(i,i+1);
            }
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}
 
class Eratosthenes{
  public:
    int n, sqlim;
    vector<bool> prime;
    Eratosthenes(int N):n(N+1){
        sqlim=(int)ceil(sqrt(n));
        prime=vector<bool>(n,1); prime[0]=prime[1]=0;
        for(int i=2;i<=sqlim;i++) if(prime[i]) for(int j=i*i;j<=n;j+=i) prime[j]=0;}
    vector<int> primeArray(int s=0, int l=10000){vi ret; for(int i=s;ret.size()!=l;i++) if(prime[i]) ret.push_back(i); return ret;}
};
using vvd=vector<vector<double>>;
using vd=vector<double>;

vvd c;
double a=-1;
void combi(int n, int s, vi t){
    if(s==0){
        double ans=0;
        for(auto i:t)for(auto j:t)ans+=c[i][j];
        a=max(a,ans);
        return;
    }
    if(n==0)return;
    combi(n-1,s,t);
    t.pb(n-1);
    combi(n-1,s-1,t);
}

int main(){
	int p,q;
	cin>>p>>q;
	c=vvd(p,vd(p,0));
	vvd color(p,vd(3));
	rep(i,p){
	    cin>>color[i][0]>>color[i][1]>>color[i][2];
	}
	rep(i,p)rep(j,p){
	    c[i][j]=pow(color[j][0]-color[i][0],2)+pow(color[j][1]-color[i][1],2)+pow(color[j][2]-color[i][2],2);
	}
	combi(p,q,vi());
	cout<<fixed<<setprecision(8)<<a/2<<endl;
	return 0;
}

Measured memory_bytes: 3288
#include<iostream>
#include<bitset>
#include<algorithm>
#include<vector>
#include<cstdio>
#define MAX 50001
using namespace std;
struct Query
{
  int A,B,order;
  Query(int A=-1,int B=-1,int order=-1):A(A),B(B),order(order){}
};
int r,c,q;
bool used[2][MAX];

int main()
{
  while(true)
    {
      scanf("%d %d %d",&r,&c,&q);
      if(r+c+q == 0)break;
      for(int i=0;i<MAX;i++)used[0][i] = false;
      for(int j=0;j<MAX;j++)used[1][j] = false;
      Query queries[q];
      for(int i=0;i<q;i++)
	scanf("%d %d %d",&queries[q-(i+1)].A,&queries[q-(i+1)].B,&queries[q-(i+1)].order);
	
      int ru,rd,cu,cd,total;
      ru = rd = cu = cd = total = 0;

      for(int i=0;i<q;i++)
	{
	  Query qw = queries[i];
	  //cout << "query -> " << qw.A << " " << qw.B << " " << qw.order << endl;
	  if(used[qw.A][qw.B])continue;
	  used[qw.A][qw.B] = true;

	  if(qw.order)
	    {
	      if(!qw.A)
		{
		  total += c - (ru+rd);
		  cu++;
		}
	      else 
		{
		  total += r - (cu+cd);
		  ru++;
		}
	    }
	  else
	    {
	      if(!qw.A)
		{
		  cd++;
		}
	      else 
		{
		  rd++;
		}
	    }
	  //cout << i << " - th : " << total << endl;  
	}
      cout << total << endl;
    }
  return 0;
}

Measured memory_bytes: 1888
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int N, ans;
  cin >> N;
  cout << N * N * N << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <vector>
#include <bitset>

int t1,t2;

int n,m;

bool edge[705][705];

std::vector<int> g[705];
int dist[705];
std::vector<int> visnode;

bool bad=0;

void dfs(int u)
{
    visnode.push_back(u);
    for (int v:g[u]) {
        if (dist[v]) {
            if ((dist[u]+dist[v])%2==0) bad=1;
            continue;
        }
        dist[v]=dist[u]+1;
        dfs(v);
    }
}

std::vector<int> a,b;
std::bitset<705> bs;
int ans=0x3f3f3f3f;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d",&n,&m);
    while (m--) {
        scanf("%d%d",&t1,&t2);
        edge[t1][t2]=1;
        edge[t2][t1]=1;
    }
    for (int i=1; i<=n; i++) {
        for (int j=1; j<i; j++) {
            if (edge[i][j]) continue;
            g[i].push_back(j);
            g[j].push_back(i);
        }
    }
    for (int i=1; i<=n; i++) {
        if (dist[i]) continue;
        visnode.clear();
        dist[i]=1;
        dfs(i);
        if (bad) {
            printf("-1\n");
            return 0;
        }
        t1=t2=0;
        for (int u:visnode) {
            if (dist[u]&1) t1++;
            else t2++;
        }
        a.push_back(t1);
        b.push_back(t2);
    }
    // do dp
    bs[0]=1;
    for (int i=0; i<a.size(); i++) {
        bs=((bs<<a[i])|(bs<<b[i]));
    }
    for (int i=0; i<=n; i++) {
        if (!bs[i]) continue;
        t1=((i-1)*i+(n-i-1)*(n-i))/2;
        if (ans>t1) ans=t1;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3072
#include<stdio.h>

int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int a[h][w],i,j,ans[h*w][4],counter=0;//long n=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf("%d",&a[i][j]);
	//		n+=(a[i][j]%2);
		}
	}
	//printf("%ld\n",n);
	for(i=h-1;i>0;i--){
		for(j=0;j<w;j++){
			if(a[i][j]!=0){
				while(a[i][j]%2==1){
					a[i][j]-=1;
					a[i-1][j]+=1;
					ans[counter][0]=i+1;
					ans[counter][1]=j+1;
					ans[counter][2]=i;
					ans[counter][3]=j+1;
					counter++;
			}
			}
		}
	}
	for(i=w-1;i>0;i--){
		while(a[0][i]%2==1){
			a[0][i]-=1;
			a[0][i-1]+=1;		
			ans[counter][0]=1;
			ans[counter][1]=i+1;
			ans[counter][2]=1;
			ans[counter][3]=i;
			counter++;
		}
	}
	printf("%d\n",counter);
	for(i=0;i<counter;i++){
			printf("%d %d %d %d\n",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
	}
	return 0;
}


Measured memory_bytes: 6912
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	vector<double>v(6);
	vector<double>w(6);
	for (auto &i : v) {
		cin >> i;
		i /= 100;
	}
	for (auto &i : w) {
		cin >> i;
		i /= 100;
	}
	vector < double >box;
	box.push_back(0);
	box.push_back(1);
	for (int i = 0; i < 6; i++) {
		box.push_back((double)w[i] / (v[i] + w[i]));
	}
	double ans = 1;
	for (auto i : box) {
		double bag = i;
		for (int j = 0; j < 6; j++) {
			if (i*(v[j] + w[j]) <= w[j]) {
				bag += w[j] * (1 - i) - v[j] * i;
			}
		}
		//cout << bag << endl;
		ans = min(ans, bag);
	}
	cout <<setprecision(20)<< ans << endl;
	return 0;
}

Measured memory_bytes: 256
// 一回計算した結果を全て持っておく
function Main(input){
    const N = Number(input);
    let fn = new Array(N).fill(0);
    for(let x=1; x**2<=N; x++){
        for(let y=1; y**2<=N; y++){
            if(x+y > N) break;
            for(let z=1; z**2<=N; z++){
                const i = x**2 + y**2 + z**2 + x*y + y*z + z*x;
                if(i >N) break;
                fn[i-1]++
            }
        }
    }
    console.log(fn.join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//---------------------------------------------------------------------------


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    int n,a,b;
	    cin>>n>>a>>b;
	    bool ok=1;
	    fl(i,a,b+1)
	    {
	        if(i%n==0)
	        {cout<<"OK"<<endl;ok=0;break;}
	    }
	    if(ok)
	    cout<<"NG"<<endl;
	    
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(N);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    
    int left = 0;
    int right = 0;
    for (int i = 0; i < M; i++) {
        if (A[i] < X) {
            left++;
        }else{
            right++;
        }
    }
    cout << min(left, right) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005;

int n, q, a, b;
vector<int> conn[N];
int val[N];

void dfs(int v, int p) {
	for (auto& u : conn[v]) {
		if (u != p) {
			val[u] += val[v];
			dfs(u, v);
		}
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		a--; b--;
		conn[a].push_back(b);
		conn[b].push_back(a);
	}	
	
	for (int i = 0; i < q; i++) {
		cin >> a >> b;
		a--;
		val[a] += b;
	}
	
	dfs(0, -1);
	for (int i = 0; i < n; ++i) cout << val[i] << " ";
	
    return 0;
}


Measured memory_bytes: 23552
n,k=map(int,input().split())
dp=[0]*(k+1)
mod=int(1e9+7)
for i in range(k,0,-1):
    sm=0
    for j in range(2*i,k+1,i):
        sm=(sm+dp[j])%mod
    dp[i]=(pow(k//i,n,mod)-sm)%mod

ans=0
for i in range(1,k+1):
    ans+=(dp[i]%mod*i%mod)%mod
print(ans%mod)


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> g[n], cost[n];
    rep (i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
        cost[u].push_back(w);
        cost[v].push_back(w);
    }
    vector<int> res(n, -1);
    res[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        rep (i, g[u].size()) {
            int v = g[u][i];
            if (res[v] != -1) continue;
            res[v] = (res[u] + cost[u][i]) % 2;
            q.push(v);
        }
    }
    rep (i, n) cout << res[i] << endl;
    
    return 0;
}



Measured memory_bytes: 11904
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		ArrayList<Integer> x1=new ArrayList<Integer>();
		ArrayList<Integer> y1=new ArrayList<Integer>();
		ArrayList<Integer> x2=new ArrayList<Integer>();
		ArrayList<Integer> y2=new ArrayList<Integer>();
		int count=0;
		int a[][] =new int[H][W];
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				a[i][j]=in.nextInt();
			}
		}
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(W>1&&a[i][j]%2==1&&W-1>j) {
					a[i][j]-=1;
					a[i][j+1]+=1;
					count++;
					x1.add(i+1);
					y1.add(j+1);
					x2.add(i+1);
					y2.add(j+2);
					
				}else if(H>1&&a[i][j]%2==1&&H-1>i){
					a[i][j]-=1;
					a[i+1][j]+=1;					
					count++;
					x1.add(i+1);
					y1.add(j+1);
					x2.add(i+2);
					y2.add(j+1);
				}
			}
		}
		System.out.println(count);
		for(int i=0;i<x1.size();i++) {
			System.out.println(x1.get(i)+" "+y1.get(i)+" "+x2.get(i)+" "+y2.get(i));
		}
		
	}
}


Measured memory_bytes: 122752
#include<stdio.h>
int main()
{
    int i,j,a,b=0,c=0,ar1[51],ar2[51],t;
    scanf("%d",&a);
    for(i=1;i<=a;i++)
    {
        scanf("%d",&ar1[i]);
    }
    for(i=1;i<=a;i++)
    {
        if(ar1[i]!=i)
        {
            b=i;
            break;
        }
    }
    for(j=i+1;j<=a;j++)
    {
        if(ar1[j]!=j)
        {
            c=j;
            break;
        }
    }
    if(b!=0 && c!=0)
    {
    t=ar1[b];
    ar1[b]=ar1[c];
    ar1[c]=t;
    }
    for(i=1;i<=a;i++)

    {
        if(ar1[i]!=i)
        {
            printf("NO\n");
            break;
        }
        if(i==a)
        {
            printf("YES\n");
            break;
        }
    }
    return 0;
}



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

int main(void)
{	
	int n, x[1000], y[1000],i;
	double p1 = 0, p2 = 0, p3 = 0, p = 0;

	scanf("%d",&n);

	for(i=0; i<n; i++)
	{
		scanf("%d", &x[i]);
	}

	for(i=0; i<n; i++)
	{
		scanf("%d", &y[i]);
	}

	for(i=0; i<n; i++)
	{
		if(x[i] < y[i])
		{
			p1 = p1 + y[i] - x[i];
			p3 = p3 + (y[i] - x[i]) * (y[i] - x[i]) * (y[i] - x[i]);
		}
		if(x[i] > y[i])
		{
			p1 = p1 + x[i] - y[i];
			p3 = p3 + (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
		}

		p2 = p2 + (x[i] - y[i]) * (x[i] - y[i]);

		if(x[i] < y[i])
		{
			if(p < y[i] - x[i])
			{
				p = y[i] - x[i];
			}
		}
		if(x[i] > y[i])
		{
			if(p < x[i] - y[i])
			{
				p = x[i] - y[i];
			}
		}
	}

	printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), pow(p3, 1.0/3.0), p);
	return 0;
}

Measured memory_bytes: 680
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string roman;
    while (cin >> roman) {
        int arabic = 0;
        int left = 1000, right;
        for (size_t i = 0; i < roman.size(); i++) {
            switch (roman.at(i)) {
            case 'M':
                right = 1000;
                break;
            case 'D':
                right = 500;
                break;
            case 'C':
                right = 100;
                break;
            case 'L':
                right = 50;
                break;
            case 'X':
                right = 10;
                break;
            case 'V':
                right = 5;
                break;
            case 'I':
                right = 1;
                break;
            }

            arabic += right;
            if (left < right) {
                arabic -= 2 * left;
            }

            left = right;
        }

        cout << arabic << endl;
    }

    return 0;
}

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

long long N,T;
int main(){
	while(cin >> N >> T){
		vector<long long> large(N+10,0);
		vector<long long> small(N+10,0);		
		for(int i=0;i<N;i++){
			int a;
			cin >> a;
			large[i] = a;
			small[i] = a;
		}
		long long s = 10000000000;
		long long l = 0;
		for(int i=0;i<N;i++){
			if(s>small[i]){
				s = small[i];
				large[i] -= s;
			}else{
				small[i] = s;
				large[i] -= s;
			}
			if(large[i] > l){
				l = large[i];
			}
		}
		int count = 0;
		for(int i=0;i<N;i++){
			if(large[i] == l) count++; 
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define ll      long long 
#define double      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     10000000000000007
#define PI 3.14159265
const int N=300005;
// ll a[N],BIT[N];
// void upd(ll x,ll y)
// {
//     for(;x<N;x+=x&-x)
//         BIT[x]+=y;
// }
// ll get(ll x)
// {
//     ll res=0;
//     for(;x;x-=x&-x)
//         res+=BIT[x];
//     return res;
// }
// void f(ll i,ll l,ll r){
//     ll lo,hi,mid,st,en;
//     lo=0;
//     hi=n-1;
//     st=n;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(v[mid].F>=l) st=mid,hi=mid-1;
//         else lo=mid+1;
//     }
//     en=-1;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(v[mid].F<=r) en=mid,lo=mid+1;
//         else hi=mid-1;
//     }
//     for(;st<=en;st++)
//         seg[i].pb(v[st].S);
//     mid=(l+r)/2;
//     f(2*i,l,mid);
//     f(2*i+1,mid+1,r);
// }
// ll g(ll i,ll l,ll r,ll x,ll y){
    
// }
// void run(int t){
//     cin>>n>>q;
//     for(i=0;i<n;i++)cin>>a[i];
//     for(i=0;i<n;i++)
//         v.pb(MP(a[i],i));
    
//     sort(all(v));
//     f(1,1,100000);
//     while(q--){
//         cin>>x>>y;
//         cout<<g(1,1,100000,x,y)<<"\n";
//     }


   


// }

void run()
{
    ll n;
    cin>>n;
    if(n&1) {
        cout<<0;
        return;
    }
    n/=2;
    ll ans=0;
    while(n)
    {
        ans+=n/5;
        n/=5;
    }
    cout<<ans;


}
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,a,b,c;
  cin>>N;
  for(int i=0;;N++){
    a=N/100;
    b=(N-a*100)/10;
    c=N%10;
    if(a==b&&b==c) break;
  }
  cout<<N<<endl;
}	


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

#define lo long long
#define pii pair<lo,lo>
#define piii pair<pii,lo>
#define fi first
#define se second
#define mp make_pair
#define pia pair<int,pii>
#define pb push_back
using namespace std;

vector <pia> lis;
int n;
piii ko[100010];
int par[100010];
bool cmp(piii aa,piii bb)
{
    return aa.fi.se<bb.fi.se;
}
int findPar(int a)
{
    if (par[a]==a) return a;
    par[a]=findPar(par[a]);
    return par[a];
}
void Union (int a,int b)
{
    a=findPar(a);
    b=findPar(b);

    par[a]=b;
}
int main()
{
    //ifstream cin("input.in");
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>ko[i].fi.fi>>ko[i].fi.se;
        ko[i].se=i;
    }

    sort(ko,ko+n);

    for (int i=1;i<n;i++)
    {
        pia aaa=mp((ko[i].fi.fi-ko[i-1].fi.fi),mp(ko[i].se,ko[i-1].se));
        lis.pb(aaa);
    }
    sort(ko,ko+n,cmp);
    for (int i=1;i<n;i++)
    {
        pia aaa=mp((ko[i].fi.se-ko[i-1].fi.se),mp(ko[i].se,ko[i-1].se));
        lis.pb(aaa);
    }

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

    for (int i=0;i<n+5;i++)
    {
        par[i]=i;
    }
    lo ans=0;
    for (int i=0;i<lis.size();i++)
    {
        if (findPar(lis[i].se.fi)==findPar(lis[i].se.se)) continue;
        ans+=lis[i].fi;
        Union(lis[i].se.fi,lis[i].se.se);
    }

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


Measured memory_bytes: 10736
n = int(input())
lst = []
dic = {}
for i in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    if s not in dic.keys():
        dic[s] = 1
    else:
        dic[s] += 1

ans = 0
for i in dic.values():
    ans += i * (i-1) // 2

print(ans)

Measured memory_bytes: 17804
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double d=(Math.ceil((a+b)/2));
	
        System.out.print(String.format("%.0f", d));
		
    }
}

Measured memory_bytes: 21716
from fractions import gcd
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(abs(l[i]-x))
if n==1:
  print(a[0])
  exit()
g=0
for i in range(n-1):
  g=gcd(g,gcd(a[i],a[i+1]))
print(g)

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 5;

int arr[maxr];
int32_t main()
{
	GO;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	int idx = 0, val = 1;
	int ans = 0;
	while (idx < n) {
		if (arr[idx] == val) {
			ans++;
			val++;
		}
		idx++;
	}
	if (ans == 0)
		cout << -1 << endl;
	else
		cout << n - ans << endl;
	return 0;
}

//!

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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
// lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
// lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


//---------------------------------------------------------------
/*lint gcd(lint x, lint y){
    if(x>y) swap(x, y);
    while(1){
        y %= x;
        swap(x, y);
        if(x==0) return y;
    }
}
*/
// lint gcd(lint x, lint y){
//     if(x>y) swap(x,y);
//     if(x==0) return y;
//     return gcd(y%x, x);
// }

lint gcd(lint a, lint b) { return b?gcd(b,a%b):a;}

void Main()
{
    lint N, M, ans;
    cin >> N >> M;
    vector<lint> a(N);
    REP(i, N){
        cin >> a[i];
        a[i] /= 2;
    }

    lint T;
        T = a[0];
    FOR(i, 1, N){
        T = T * a[i] / gcd(T, a[i]);
    }

    int f = 0;
    REP(i, N){
        if((T/a[i])%2 == 0) f = 1;
    }
    if(!f){
        ans = (1 + M / T)/2;
    }else{
        ans = 0;
    }
    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 1024