akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
bool visited[1000007];
int main(){
	int k;
	cin>>k;
	int curr = 7%k;
	visited[7%k]=true;
	int rep = 1;
	while(1){
		if(curr==0){
			cout<<rep;
			return 0;
		}
		curr = (curr*10+7)%k;
		rep++;
		if(visited[curr]){
			cout<<-1;
			return 0;
		}
		visited[curr] = true;
	}
}

Measured memory_bytes: 4544
from sys import stdin

def attack(h):
    if h <= 1:
        return 1
    f = {}
    n = 1
    while (h // 2 > 1):
        h = h // 2
        n += 1
    for i in range(n):
        f[i] = 0
    f[0] = 1
    for i in range(1, n + 1):
        f[i] = f[i-1] * 2 + 1
    return f[n]

if __name__ == '__main__':
    h = int(stdin.readline().rstrip())
    print(attack(h))

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

int main() {
  int K;
  cin >> K;
  long ans = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        ans += gcd(gcd(i, j), k);
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
map<int,int> cnt;
void input(){
    fast_io();
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a,b; cin >> a >> b;
        a--,b--;
        cnt[a]++;
        cnt[b]++;
    }
    
}

int solve(){
    for (int i = 0; i < N; i++)
    {
        if(cnt[i]%2==0) continue;
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  string sample = "ABC"; 
  for (int i = 0; i < n-2; i++){
    bool match = true;
    for (int j = 0; j < 3; j++){
      match &= (s.at(i+j) == sample.at(j));
    }
    if (match){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
x_diff = [b-a for b, a in zip(x[1:], x[:-1])]
x_diff.sort()
if n >= m:
    print(0)
else:
    # dp[n] n個の駒で取りうる最小の手数
    # dp[n] = dp[n-1] - {n-1駒の守備範囲で最も大きい空白の長さ}
    dp = [0] * (n+1)
    dp[1] = x[-1] - x[0]
    for i in range(2, n+1):
        dp[i] = dp[i-1] - x_diff.pop(-1)
    print(dp[n])

Measured memory_bytes: 14088
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int ctr=0;
        for(int i=0;i<n;i++){
            if(s[i]=='W')
                ctr++;
        }
        int ctr1=0;
        for(int i=0;i<n-ctr;i++){
            if(s[i]=='W')
                ctr1++;
        }
        cout<<ctr1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3764
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

int func(int num) {
	int a = (num - 7) * 3;
	int b = num * 3;
	int c = (num + 7) * 3;
	return a + b + c;
}

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

	int n, k;
	cin >> n >> k;

	if (n <= 2) {
		cout << 0 << endl;
		return 0;
	}

	int ans = 0;
	FOR(i, 1, 6) {
		FOR(j, 1, n - 1) {
			if (func(j * 7 + i + 1) % 11 == k) {
				ans += (n - 2 - j) / 11;
				ans++;
				break;
			}
		}
	}

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

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

int main()
{
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; ++i)
  {
    cin >> a.at(i);
  }
  
  sort(a.rbegin(), a.rend());
  
  int alice_sum, bob_sum = 0;
  for(int i = 0; i < N; ++i)
  {
    if(i % 2 == 0)
    {
      alice_sum += a.at(i);
    }
    else
    {
      bob_sum += a.at(i);
    }
  }
  
  cout << alice_sum - bob_sum << endl;
  return 0;
}    

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


int main(){
int a[5];
cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
sort(a,a+5);
for (int i = 4; i >= 1; --i) {
	cout<<a[i]<<" ";
}
cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 3088
N = int(input())
a = list(map(int, input().split()))

count = 0
flag = 0
while (flag == 0):
  for i in range(len(a)):
    if a[i] % 2 != 0:
      flag = 1
      break
    else:
      a[i] //= 2
  count += 1
print(count-1)
    

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct UnionFind {
    vector<int> par;

    //正の場合、親を表す
    //負の場合、根で数値は連結成分のサイズ
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) {
            return x;
        } else {
            return par[x] = root(par[x]); //経路圧縮
        }
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); //小さい方を大きい方にくっつけるため

        par[x] += par[y];
        par[y] = x;

        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {

    int n, m; cin >> n >> m;

    UnionFind tree(n);

    for (int i = 0; i < m; ++i) {
        int x, y, z; cin >> x >> y >> z;
        --x; --y;

        tree.unite(x, y);
    }

    set<int> se;
    for (int i = 0; i < n; ++i) {
        se.insert(tree.root(i));
    }

    cout << se.size() << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	


  
  	ini(n);
	vi morty;
	FOR(i,0,n){
		ini(x);
		x--;
		morty.push_back(x);
	}
	int tmp  = n;
	vi rick;
	while(tmp--){
		int tmp1 = -1;
		FOR(i,0,morty.size()){
			if(morty[i] == i)tmp1 = max(tmp1,i);
		}
		if(tmp1 == -1){
			out(-1);
			return 0;
		}
		rick.push_back(tmp1);
		morty.erase(morty.begin()+tmp1);
	}
	for(int i1 = n-1;i1>=0;i1--){
		out(rick[i1]+1);
	}










	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init, i, n) for (int i = init; i < (n); i++)
#define ll long long
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
#define PI 3.14159265358979323846264338327950
//コード自動整形 Shift + Option + F @vscode
using namespace std;

/////main/////
int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N), A(M), B(M), goodlocation(N, 1);
    ll sum = 0;

    rep(0,i,N){
        cin>>H.at(i);
    }

    rep(0, i, M)
    {
        cin >> A.at(i) >> B.at(i);
    }

    rep(0, i, M)
    {
        ll a = A.at(i); a = a-1;
        ll b = B.at(i);b = b-1;;
        if (H.at(a) >= H.at(b))
        {
            goodlocation.at(b) = 0;
        }
        if (H.at(b) >= H.at(a))
        {
            goodlocation.at(a) = 0;
        }
    }
    //rep(0,i,M){
    //    cout<< "A("<< i+1<<")=" << A.at(i)<<"B("<< i+1<<")=" << B.at(i)<<endl;
    //}
    rep(0, i, N)
    {
        sum += goodlocation.at(i);
    }
    cout << sum << endl;
}
/////main/////

/////function/////

Measured memory_bytes: 6392
#include <iostream>

using namespace std;
#define ll long long
int main(){
    int n,k;
    cin >> n >> k;
    int onepos=-1;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if (a==1){
            onepos=i;
        }
    }
    ans=(n-1)/(k-1)+(((n-1)%(k-1)>0)?1:0);
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i>=1&&i<H-1&&j>=1&&j<W-1)printf(".");
				else printf("#");
			}
			printf("\n");
		}
	printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin>>a>>b>>c;
  vector<vector<int>>v(a+1,vector<int>(a+1,0));
  for(int i=0; i<b;++i){
    int d, e;
    cin>>d>>e;
    ++v[d][e];
  }
  for(int i=0;i<=a;++i){
    for(int j=0;j<a;++j){
      v[i][j+1]+=v[i][j];
    }
  }
  for(int i=0;i<a;++i){
    for(int j=0;j<=a;++j){
      v[i+1][j]+=v[i][j];
    }
  }
  for(int i=0;i<c;++i){
    int e,d;
    cin>>e>>d;
    --e;
    cout<<v[d][d]+v[e][e]-v[e][d]-v[d][e]<<endl;
  }
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int d;
        Scanner scanner = new Scanner(System.in);
        d = scanner.nextInt();
        if (d == 25) {
            System.out.println("Christmas");
        } else if (d == 24) {
            System.out.println("Christmas Eve");
        } else if (d == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (d == 22) {
            System.out.println("Christmas Eve Eve Eve");
        }

}
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);
            string[] ks = new string[m];
            foreach(var i in Enumerable.Range(0, m))
            {
                ks[i] = Console.ReadLine();
            }
            var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            List<LightBulb> lightBulbs = new List<LightBulb>();
            foreach (var i in Enumerable.Range(0, m))
            {
                var tmpks = ks[i].Split(' ').Select(int.Parse).ToArray();
                var k = tmpks[0];
                var s = tmpks.Skip(1).ToArray();
                lightBulbs.Add(new LightBulb(k, p[i], s));
            }
            var result = 0;
            for (int i = 0; i < 1 << n; i++)
            {
                int[] tmps = new int[n];
                for(int j = 0; j < n; j++)
                {
                    if (((i >> j) & 1) == 1)
                    {
                        tmps[j] = 1;
                    }
                }
                if(lightBulbs.All(x => x.IsOn(tmps)))
                {
                    result++;
                }
            }
            Console.WriteLine(result);

        }
    }
    public class LightBulb
    {
        int _k;
        int _p;
        int[] _s;
        public LightBulb(int k,int p,int []s)
        {
            _k = k;
            _p = p;
            _s = s;
        }
        public bool IsOn(int[] switchstate)
        {
            var sum = 0;
            foreach(var tmp in _s)
            {
                sum += switchstate[tmp - 1];
            }
            return sum % 2 == _p;
        }
    }
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i])
			cnt++;
	}
	cout << cnt << "\n";
 	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
using namespace std ;
int main()
{
	int n,m;
	cin >> n >> m;
	int s;
	if(m%n==0) s=m/n;
	else 
	{
		s=m/(n+1);
		while((m-(n-1)*s)%s!=0)
			s--;	
	} 
	cout << s ;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int[] read = inta();
        WriteLine(Max(read[2]-read[0]+read[1],0));
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 11092
n = int(input())
H = list(map(int,input().split()))
dp = [0]*(n+1)
dp[1] = abs(H[1]-H[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[n-1])


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		string s;
		cin>>s;
		if(s=="0") break;
		int res=0;
		vi dp(11);
		for(auto c:s){
			vi DP(11);
			int t=c-'0';
			if(t) DP[t]++;
			for(int i=0;i<11;i++) DP[(10*i+t)%11]+=dp[i];
			dp=DP;
			res+=dp[0];
		}
		cout<<res<<endl;
	}
}


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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end());
}

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

int main() {
	int X, answer = 1;
	cin >> X;
	for (int i = 2; i < 32; i++) {
		for (int j = 2; pow(i, j) <= X; j++) {
			int tmp_ans = pow(i, j);
			if (tmp_ans <= X && tmp_ans > answer) answer = tmp_ans;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int search(int A[],int n,int key){
  A[n] = key;
  int s = n;
  for(int i = 0;i < n;i++){
    if(A[i]==key)s = i;
  }
  return s != n;
}
int main (){
  int n,S[10001],q;
  int i;
  scanf("%d",&n);
  for(i = 0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int sum = 0;
  int key;
  for(i = 0;i < q;i++){
    scanf("%d",&key);
    if(search(S,n,key))sum++;
  }
  printf("%d\n",sum);
}



Measured memory_bytes: 2780
#include <iostream>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
int frec[1 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1;i <= n; i++){
    int a;
    cin >> a;
    frec[a]++;
  }
  int smin = 0, smax = 0;
  for(int i = 1;i <= n; i++) {
    if(smin == 0 && 0 < frec[i])
      smin = i;
    if(0 < frec[i])
      smax = i;
  }
  if(smin == smax){
    if(smin == n - 1)
      cout << "Yes";
    else if(smin <= n / 2)
      cout << "Yes";
    else
      cout << "No";
  } else if(frec[smin] + frec[smax] < n){
    cout << "No";
  } else if(smin == smax - 1){
    if(frec[smin] + 1 <= smax && smax <= frec[smin] + frec[smax] / 2)
      cout << "Yes";
    else
      cout << "No";
  } else
    cout << "No";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 5/11/2020
 
 21:29-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N],F[MAX_N],K;
int N;

void solve() {
  sort(A,A+N);
  sort(F,F+N),reverse(F,F+N);
  
//  dumpC(A,A+N);
//  dumpC(F,F+N);
  
  LL good=1e12,bad=-1;
  while(abs(good-bad)>1) {
    LL mid=(good+bad)/2;
    LL cost=0;
    REP(i,N) {
      LL a=A[i],f=F[i];
      LL aa=mid/f;
      cost+=max(0LL,a-aa);
    }
    (cost<=K?good:bad)=mid;
  }
  cout<<good<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K;
  REP(i,N) cin>>A[i];
  REP(i,N) cin>>F[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 5888
N, Y = map(int, input().split())
for y in range(N+1):
  up = Y - 1000*N - 4000*y
  if up >= 0 and up % 9000 == 0:
    x = up // 9000
    z = N - x - y
    if z >= 0:
      print(x, y, z)
      exit()
print("-1 -1 -1")

Measured memory_bytes: 3316
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() 
{
	double x1, x2, y1, y2, a;
	cin >> x1 >> x2 >> y1 >> y2 >> a;
	a = sqrt((y1 - x1) * (y1 - x1) + (y2 - x2) * (y2 - x2));
	cout << fixed << setprecision(8) << a << endl;
	return 0;
}


Measured memory_bytes: 3288
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

template<typename T>
vector<vector<T>> accum2d(vector<vector<T>> & vec) { // 0-indexed
    int H = vec.size();
    int W = vec[0].size();
    vector<vector<T>> res(H + 1, vector<T>(W + 1));
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            res[i][j] = vec[i - 1][j - 1] - res[i - 1][j - 1] + res[i][j - 1] + res[i - 1][j];
        }
    }
    return res;
}

template<typename T>
T sum_square(vector<vector<T>> & accum, vector<T> coor0, vector<T> coor1) { // 0-indexed
    T res = accum[coor1[0] + 1][coor1[1] + 1] + accum[coor0[0]][coor0[1]] - accum[coor1[0] + 1][coor0[1]] - accum[coor0[0]][coor1[1] + 1];
    return res;
}

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<vector<int>> vec(N, vi(N));
    for (int i = 0; i < M; i++) {
        int l, r; cin >> l >> r;
        --l; --r;
        vec[l][r]++;
    }

    vector<vector<int>> acc = accum2d(vec);

    for (int qq = 0; qq < Q; qq++) {
        int p, q; cin >> p >> q; --p; --q;
        cout << sum_square(acc, { p,p }, { q,q }) << endl;;
    }

}

Measured memory_bytes: 5604
import java.util.Scanner;
class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int a = (int)(X/100);
        int b = X-a*100;
        if (b > a*5) {
        		System.out.println(0); 
        } else {
        		System.out.println(1);
        }
    }
} 

Measured memory_bytes: 22740
N=int(input())
xy=[[] for i in range(N)]

for i in range(N):
  for j in range(int(input())):
    x,y=map(int,input().split())
    xy[i].append([x-1,y])

m=0
for i in range(2**N):
  f=True
  for j in range(N):
    if (i>>j)&1==0:
      continue	
    for k in xy[j]:
      if (i>>k[0])&1!=k[1]:
        f=False
        break
    if f==False:
      break
  if f==True:
    c=0
    while i>0:
      c+= i&1
      i >>= 1
    m=max(m,c)
print(m)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

typedef pair<ll, ll> pll;

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }
    
    set<ll> st;
    for (int i=0; i<n; i++){
        // cout << uf.root(i) << endl;
        st.insert(uf.root(i));
    }
    long long ans = 0;
    for (auto it: st){
        ans = max(ans, uf.size(it));
    }
    cout << ans << endl;
}
// int main() {
//     int N;
//     cin >> N;
//     vector<ll> A(N);
//     for (int i=0; i<N; i++) cin >> A[i];
//     vector<ll> s(N+1);
//     for (int i=0; i<N; i++){
//         s[i+1] = (s[i] + A[i]) % MOD;
//     }
    
//     long long ans = 0;
//     for (int i=0; i<N; i++){
//         // cout << A[i] << " " << (s[N] - s[i+1])<< (A[i] * (s[N] - s[i])) << endl;
//         ans += ((A[i]% MOD * (s[N] - s[i+1]) % MOD) % MOD) % MOD;
//         ans %= MOD;
//     }
//     cout << ans << endl;
// }


Measured memory_bytes: 15572
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	int n,m;
	cin >> n >> m;
	int mat[n][m],bas[m],res[n];

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> mat[i][j];
		}
	}
	for (int i = 0; i < m; ++i) {
		cin >> bas[i];
	}

	for (int i = 0; i < n; ++i) {
		int sum=0;
		for (int j = 0; j < m; ++j) {
			sum += mat[i][j]*bas[j];
		}
		println(sum);
	}


	return 0;
}



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

int main(void)
{
    int n;
    string s;
    cin >> n >> s;
    if (n % 2) {
        cout << "No" << endl;
        return 0;
    }

    string s1 = s.substr(0, n / 2);
    string s2 = s.substr(n / 2, n / 2);
    if (s1 == s2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int n,x;
int l[100];
int d=0;
int kaisu=0;

int i,j;//制御

scanf("%d%d",&n,&x);

for(i=0;i<n;i++){
    scanf("%d",&l[i]);
}
i=0;
kaisu=1;
while(i<n){
    
    d=d+l[i];
    if(d<=x){
        kaisu++;
    }
    i++;
}
printf("%d",kaisu);


return 0;

}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ct=0
for i in range(n):
  if a[i]>=b[i]:
    ct+=b[i]
  else:
    ct+=a[i]
    x=a[i+1]
    a[i+1]=max(a[i+1]-b[i]+a[i],0)
    ct+=x-a[i+1]
print(ct)

Measured memory_bytes: 19116
#include <bits/stdc++.h>
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;

int main(void) {
    int i,j,n,u,k,v;
    vector< vector<int> > arr;
    cin >> n;
    arr.resize(n);
    rep(i,n) {
        arr[i].resize(n,0);
    }
    rep(i,n){
        cin >> u >> k;
        u--;
        rep(j,k){
            cin >> v;
            v--;
            arr[u][v]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            if(j!=0) cout << " ";
            cout << arr[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

const int Nmax = 200001;

int N, K;
int cnt[Nmax];
multiset<int> st;

int main() {
	cin >> N >> K;
	memset(cnt, 0, sizeof(cnt));
	int Amax = 0;
	for (int i = 0; i < N; i++) {
		int a;  cin >> a;
		Amax = max(Amax, a);
		cnt[a]++;
	}
	for (int i = 1; i <= Amax; i++) {
		if (cnt[i] != 0) {
			st.insert(cnt[i]);
		}
	}

	int dN = st.size() - K;
	int ans = 0;
	auto itr = st.begin();
	while (dN > 0) {
		dN--;
		ans += *itr;
		++itr;
	}

	cout << ans << endl;
}


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

int main()
{
  int N,count = 0;
  cin >> N;
  int D[N][2];
  for(int i=0;i<N;i++){
    cin >> D[i][0] >> D[i][1];
  }
  string result = "No";

  for(int i=0;i<N;i++){
    if(D[i][0] == D[i][1]){
      count += 1;
      if(count==3){
        result = "Yes";
      }
    }else{
      count = 0;
    }
  }
  
  cout << result << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    
    int r;
    while (r = a%b) {
        a = b;
        b = r;
    }
    return b;
}

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

    int N; cin >> N;
    int A0, A1;
    cin >> A0 >> A1;

    int res = gcd(A0, A1);
    if (N > 2) {
        rep(i, 2, N) {
            int Ai;
            cin >> Ai;
            res = gcd(res, Ai);
        }
    }

    cout << res << "\n";
}

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

int check(string S, int n){
    if(S[0] != 'A'){
        //cout << "first" << endl;
        return 0;
    }
    int c = 0;
    for(int i = 2; i < n - 1; i++){
        if(S[i] == 'C')c++;
    }
    if(c != 1){
        //cout << "second" << endl;
        return 0;
    }
    for(int i = 1; i < n; i++){
        if(S[i] != 'A' && S[i] != 'C'){
            if(S[i] - 'a' < 0){
                //cout << "third" << endl;
                return 0;
            }
        }
    }
    return 1;
}

int main(){
    string S;
    cin >> S;
    int size = S.size();
    int x = check(S, size);
    if(x)cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}

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

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    if(H < W) swap(H, W);

    int cnt = 0;
    int painted = 0;
    while(painted < N){
        painted += H;
        cnt += 1;
    }
    cout << cnt << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr double PI = atan(1)*4;

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

    cout << setprecision(18);

    int N;
    ll L;
    cin >> N >> L;

    vll T(N);
    for (int i=0;i<N;i++) cin >> T[i];

    vd angs(N);
    for (int i=0;i<N;i++) angs[i] = (2*PI*T[i])/L;

    double ansx = 0.;
    double ansy = 0.;
    for (int i=0;i<N;i++) {
        for (int j=i+1; j<N; j++) {
            double nang = (angs[i] + angs[j]) / 2;
            int between = (j - i - 1);

            ansx += (N-2 - between)*cos(nang);
            ansy += (N-2 - between)*sin(nang);

            ansx += between*cos(nang + PI);
            ansy += between*sin(nang + PI);


        }
    }
    ansx /= (N-2);
    ansy /= (N-2);

    ansx *= 6.0/(N*(N-1));
    ansy *= 6.0/(N*(N-1));
    

    cout << ansx << " " << ansy << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<string>s(n);
	vector<int>p(n);
	vector<int>m(n);
	rep(i,n){
	  cin>>s[i];
	  int tmp;
	  rep(j,n-1){
	    cin>>tmp;
		if(!tmp)p[i]++;
		else if(tmp==1)m[i]++;
	  }
	}
	rep(i,n){
	  rep(j,n-i-1){
	    if(p[j]<p[j+1]||(p[j]==p[j+1]&&m[j]>m[j+1])){
		  swap(s[j],s[j+1]);
		  swap(m[j],m[j+1]);
		  swap(p[j],p[j+1]);
		}
	  }
	}
	rep(i,n)cout<<s[i]<<endl;
  }
}

Measured memory_bytes: 1200
import sys
N = int(input())
a = sorted([(x + l, x - l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if last <= l:
        ans += 1
        last = r

print(ans)

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

a = list(map(int, input().split()))

cnt = 0
ave = sum(a)/2

for i in range(n):
    cnt += a[i]
    if cnt >= ave:
        ans = min(cnt*2-ave*2, ave*2-(cnt-a[i])*2)
        break

print(int(ans))

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

int main(void) {
    int N, D;
    cin >> N >> D;
    int X[11][11];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) {
            cin >> X[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; ++j) {
            int dist = 0;
            for (int k = 0; k < D; ++k) {
                int term = X[i][k] - X[j][k];
                dist += term * term;
            }
            int root = (int)sqrt(dist);
            if (root * root == dist) {
                ++count;
            }
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b  = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int min1 = a;
		int min2 = c;
		if(a > b) min1 = b;
		if(c > d) min2 = d;
		int ans;
		ans = min1 + min2;
		System.out.println(ans);
	}
}



Measured memory_bytes: 21972
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {

	ll N, D, X;
	cin >> N >> D >> X;
	vector<ll> A(N);
	ll an = X;
	rep(i, N) {
		ll A;
		cin >> A;
		an += 1 + (D - 1) / A;
	}
	cout << an << endl;
}


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

int main()
{
    for(;;){
        int n;
        double m,sum=0,sum2=0;
        cin >> n;
        if(n==0)break;
        else{
            double a[n];
            for(int i=0;i<n;i++){
                cin >> a[i];
                sum+=a[i];
            }
            m=sum/n;
            for(int i=0;i<n;i++){
                sum2+=pow(a[i]-m,2);
            }
            cout << fixed << setprecision(8) << sqrt(sum2/n) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3268
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

if P == Q:
    print(0)
    exit()

L = list(range(1, N+1, 1))

p = itertools.permutations(L, N)

cn = 0
cn1 = 0
cn2 = 0

for i in p:
    i = list(i)

    cn = cn + 1
    if i == P:
       cn1 = cn
    elif i == Q:
       cn2 = cn
       

print(abs(cn1 - cn2))

Measured memory_bytes: 9144
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
	cin >> x>> y>> z;
    string ans;
    if(x+y<z)ans="dangerous";
    else if(y<z)ans = "safe";
    else ans = "delicious";
      cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  int a=0;
  rep(i,1000000){
    a+=i;
    if(a>=n){cout<<i<<endl;break;}
  }
    

  return 0;
}


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

int main(){

	int n, old[7], x;
	
	while(cin >> n){
		if(n == 0) break;
		fill(old, old+7, 0);
		
		for(int i=0; i<n; i++){
			cin >> x;
			if(x >= 60) old[6]++;
			else old[(x - x % 10) / 10]++;
		}
		
		for(int i=0; i<7; i++){
			cout << old[i] << endl;
		}
		
	}

	return 0;

}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main()
{
    int a1, a2, a3, res;

    cin >> a1 >> a2 >> a3;

    res = a1+a2+a3;
    if (res >= 22)
        cout << "bust" << endl;
    else 
        cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)  {
  int n, i, j;
  int A[100];
  
  scanf("%d", &n);
  for (i = 0; i < n; i++)  
    scanf("%d", &A[i]);
  
  trace(A, n);
  insertionSort(A, n);
  
  return 0;
}

void trace(int A[], int n)  {
  int i;
  for (i = 0; i < n; i++)  {
    if ( i > 0) 
      printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int n)  {
  int j, i, v;
  for (i = 1; i < n; i++)  {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v)  {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, n);
  }
}

Measured memory_bytes: 1764
#define rep(i,n) for(ll i=0;i<(n);++i)

#include<iostream>
#include<fstream>
#include<iomanip>

#include<vector>
#include<array>
#include<string>
#include<bitset>
#include<queue>
#include<list>

#include<utility>

#include<algorithm>
#include<cmath>
using ll = long long;
using namespace std;

int n,m;

void src(){
    cin>>n>>m;
    priority_queue<int> q;
    int a;
    rep(i,n){
        cin>>a;
        q.push(a);
    }
    rep(i,m){
        int t=q.top();
        q.pop();q.push(t/2);
    }
    ll sum=0;
    rep(i,n){
        sum+= q.top();
        q.pop();
    }
    cout<<sum<<endl;;
    return;
}


int main(int argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif


bool solve()
{
    string s;
    cin >> s;

    char prev = 0;
    for (char c : s)
    {
        if (c == prev)
            return false;

        prev = c;
    }

    return true;
}

int main()
{
    if (solve())
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const int N=3e5+100;

int main()
{
   ll n;cin>>n;
   ll yu=n%500;
   ll q=n/500;
   ll p=yu/5;
   ll ans=1000*q+5*p;
   cout<<ans;
   return 0;
}


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

#define ARR_LIMIT 1001
#define END "END_OF_TEXT"

int counting(char* sentence, char* word);

int main(void) {
	int count = 0;
	char word[11];
	char sentence[ARR_LIMIT];

	scanf("%s", word);
	while (1) {
		memset(sentence, 0, sizeof(sentence));
		scanf(" %s", sentence);
		if (!strcmp(sentence, END)) {
			break;
		}

		count += counting(sentence, word);
	}

	printf("%d\n", count);
}


int counting(char* sentence, char* word) {
	int count = 0;

	char* pW = word;
	char* pS = sentence;

	while (1) {
		char curW = tolower(*pW++);
		char curS = tolower(*pS++);

		if (curW && !curS) {
			break;
		}

		if (!curW && curS) {
			break;
		}

		if (!curW && !curS) {
			count++;
			break;
		}

		if (curW != curS) {
			break;
		}
	}

	return count;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <iostream>

using namespace std;
const int MAXN = 1e6+10;
int n,a[MAXN];
int main()
{
	scanf("%d",&n);
	for (int i = 1;i<=n;i++)scanf("%d",&a[i]);

	for (int i = 1;i<=n;i++)
	{
		if (a[i] > a[i-1])a[i]--;else
		if (a[i] < a[i-1])
		{
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 640