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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n, k; cin >> n >> k;
	long long a[n];
	rep(i,0,n,1) cin >> a[i];
	sort(a, a+n);
	cout << accumulate(a, a+k, 0ll) << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	vector<long long> n(3);
	string s = "No";

	for(long long i = 0;i < 3;i++)
		cin >> n[i];

	sort(n.begin(), n.end());
	
	if ((n[0] != n[1]&& n[1] == n[2]) || (n[0] == n[1]&&n[1] != n[2]))
		s = "Yes";


	cout << s << endl;
}

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

using namespace std;

int main()
{
	vector<int> a(5);
	for (auto &x : a) {
		cin >> x;
	}

	int ans = 0;
	int ext = 0;
	for (auto x : a) {
		ans += (x + 9) / 10 * 10;
		if (x % 10 != 0) {
			ext = max(ext, 10 - x % 10);
		}
	}
	ans -= ext;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }

    return 0;
}

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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  el "\n";

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};



#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    long long n,k;
    cin>>n>>k;

    vector<long long> items;


    for(int i=0; i<k; i++)
    {

        long long it;
        cin>>it;

        items.push_back(it);
    }

    long long mx=0;

    long long f=0;

    while(true)
    {

        long long dif=0;

        if(f==k-1)
        {
           dif=n-items[f]+items[0];

           debug(dif);

           mx=max(dif,mx);
           break;
        }
        else
        {
            dif=items[f+1]-items[f];
            mx=max(dif,mx);
        }



        f++;
    }

    cout<<n-mx<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 2420
//by xxj
//I love 7 sea k fall
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
//const int mod=;
inline int read(){
    int x=0;char ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x;
}
string s1,s,t;
bool canbe[20000007];
bool used[20000007];
int nxt[500007];
void find_nxt(){
	string q=t;
	q+='$';
	int i=0,j=-1;
	nxt[i]=j;
	while (i!=q.size()-1){
		if (j==-1 || q[i]==q[j]){
			if (q[++i]==q[++j]){
				nxt[i]=nxt[j];
			}
			else{
				nxt[i]=j;
			}
		}
		else{
			j=nxt[j];
		}
	}
}
vector<int> v;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s1>>t;
	s=s1;
	while (s.size()<t.size()){
		s+=s1;
	}
	s1=s;
	s+=s1;
	s+=s1;
	find_nxt();
	int j=0;
	for (int i=0;i<s.size();i++){
		while (j!=-1 && t[j]!=s[i]){
			j=nxt[j];
		}
		j++;
		if (j==t.size()){
			canbe[i-t.size()+1]=true;
			v.push_back(i-t.size()+1);
			j=nxt[j];
		}
	}
	int ans=0,mx=0;
	int cnt=0;
	for (int i=0;i<v.size();i++){
		if (used[v[i]]){
			continue;
		}
		j=v[i];
		cnt=0;
		while (canbe[j]){
			cnt++;
			used[j]=true;
			j=j+t.size(); 
		}
		ans=max(ans,cnt);
	}
	if (!ans){
		printf("%d\n",ans);
		return 0;
	}
	memset(canbe,false,sizeof(canbe));
	memset(used,false,sizeof(used));
	s+=s;
	j=0;
	for (int i=0;i<s.size();i++){
		while (j!=-1 && t[j]!=s[i]){
			j=nxt[j];
		}
		j++;
		if (j==t.size()){
			canbe[i-t.size()+1]=true;
			v.push_back(i-t.size()+1);
			j=nxt[j];
		}
	}
	for (int i=0;i<v.size();i++){
		if (used[v[i]]){
			continue;
		}
		j=v[i];
		cnt=0;
		while (canbe[j]){
			cnt++;
			used[j]=true;
			j=j+t.size(); 
		}
		mx=max(mx,cnt);
	}
	if (mx>ans){
		puts("-1");
	}
	else{
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 83168
S = [input() for i in range(3)]
cnt = [0, 0, 0]
limit = [len(S[i]) for i in range(3)]
point = 0
NUM = "ABC"
while cnt[point] != limit[point]:
  if S[point][cnt[point]] == 'a':
    cnt[point] += 1
    point = 0
  elif S[point][cnt[point]] == 'b':
    cnt[point] += 1
    point = 1
  elif S[point][cnt[point]] == 'c':
    cnt[point] += 1
    point = 2
print(NUM[point])

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n,y;

int main(){

    cin >> n >> y;
	
	rep(i,0,n+1){
        rep(j,0,n+1-i){
            int k = n-i-j;

            if(i*10000 + j*5000 + k*1000 == y){
                cout << i << " " << j << " " << k << endl;
                ret 0;
            }
        }
	}
	P("-1 -1 -1");
	return  0;
}

Measured memory_bytes: 256
# nとmを整数として受け取る
nm = gets.split(' ').map(&:to_i)

# nの２パターンの総和をsnと定義
sn = nm[0] * (nm[0] - 1) / 2

# mの2パターンの総和をsmと定義
sm = nm[1] * (nm[1] - 1) / 2

puts sn + sm

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int n, x; cin >> n >> x;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  int ans = abs(x - arr[0]);

  rep(i,n-1) {
    int a = abs(arr[i+1] - arr[i]);
    int b = ans;
    int c = a % b;
    while (c != 0) {
      a = b;
      b = c;
      c = a % b;
    }
    ans = b;
  }

  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	int K;
	cin >> K;

	if (K % 2 == 0) {
		cout << K * K / 4 << endl;
	}
	else {
		cout << (K - 1) * (K + 1) / 4 << endl;
	}


	return 0;
}

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

int main()
{
  int a[10000],i,n,max,min;
  long long sum;
  i=0; 
  cin >> n;
  max=-1000000;
  min=1000000;
  sum=0;
  
  while(i!=n){
    
    cin >> a[i];
    if(max<a[i]){
      max=a[i];
    }
    if(min>a[i]){
      min=a[i];
    }
    sum=sum+a[i];  /*sum no gokei*/
    
    i++;
  }
  
  cout << min << " " << max << " " << sum << endl;
  
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>

int F[45];

int fib(int n){
  int i;
  F[0]=1;
  F[1]=1;  
  for(i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }

  return F[n];
}

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

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


  return 0;
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> map<Z, int> factorize(Z n) {
  map<Z, int> res;
  for (Z i = 2; i * i <= n; ++i) while (n % i == 0) ++res[i], n /= i;
  if (n != 1) ++res[n];
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint a, b; cin >> a >> b;
  auto mp = factorize(__gcd(a, b));
  cout << mp.size() + 1 << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApp3
{
	class Program
	{
		static void Main(string[] args)
		{
			int stringsCount = int.Parse(Console.ReadLine());
			var strings = new List<string>(stringsCount);
			for (int i = 0; i < stringsCount; i++)
			{
				strings.Add(Console.ReadLine());
			}

			// 個々の文字列に含まれる数
			int targetCount = 0;
			foreach (var str in strings)
			{
				targetCount += GetCountOfSubstring(str, "AB");
			}

			int tailA = 0;
			int headB = 0;
			int headBtailA = 0;
			foreach(var str in strings)
			{
				if (str[str.Length - 1] == 'A')
				{
					tailA++;
					if (str[0] == 'B')
					{
						headBtailA++;
					}
				}
				if (str[0] == 'B')
				{
					headB++;
				}
			}
			targetCount += Math.Min(tailA, headB);
			if (headBtailA == tailA &&
				headBtailA == headB &&
				headBtailA != 0)
			{
				targetCount -= 1;
			}

			Console.WriteLine(targetCount);
		}

		static int GetCountOfSubstring(string str, string target)
		{
			int count = 0;
			int searchIndex = 0;
			while(true)
			{
				int index = str.IndexOf(target, searchIndex);
				if (index == -1)
				{
					break;
				}
				count++;
				searchIndex = index + target.Length;
			}
			return count;
		}
	}
}


Measured memory_bytes: 13436
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	vector<int> dat;
	vector<int> gg;
	vector<int> inf;
	scanf("%d",&n);
	int i;
	int x;
	gg.push_back(1);
	for(i = 1; i <= n; i++){
		dat.push_back(i);
		gg.push_back(gg[i-1]*10);
	}
	inf.reserve(50000);
	do {
		x = 0;
        for(i = 0; i < n; i++)
        	x += dat[i]*gg[i];
        inf.push_back(x);
        //for(i = 0; i < n; i++) printf("%d, ",dat[i]); printf("__ %d\n",x);
    } while(next_permutation(dat.begin(), dat.end()));
	int a = 0,b = 0;
	vector<int> va(n),vb(n);
	for (i = 0; i < n; ++i)
		scanf("%d",&va[i]);
	for (i = 0; i < n; ++i)
		scanf("%d",&vb[i]);
	
	for(i = 0; i < n; i++){
        a += va[i]*gg[i];
        b += vb[i]*gg[i];
	}
	int A=0,B=0;
	n = inf.size();
	for(i = 0; i < n; i++){
		if(a == inf[i])
			A = i;
		if(b == inf[i])
			B = i;
	}
	//printf("%d %d, a=%d, b=%d\n",A,B,a,b);
	//for(i = 0; i < gg.size(); i++)
	//	printf("%d, ", gg[i]);
	//printf("\n");
	printf("%d\n",abs(A-B));
	return 0;
}

Measured memory_bytes: 384
N , Y= map(int,input().split())

for a in range(N + 1):
    be = N - a 
    for b in range(be + 1):
        c = N - b - a
        kingaku = 1000 * c + 5000 * b + 10000 * a

        if kingaku == Y:
            print(a,b,c)
          
            break
    else:
        continue
    break
                   

else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = ull;
using Double = double;

using P = pair<Double, Int>;
using V = vector<Int>;
using M = vector<V>;


Int combination(Int n, Int m){
    Int sum = 1;
    for(Int i = 0; i < m; i++){
        sum *= n - i;
        sum /= i + 1;
    }
    return sum;
}

Int sum_combination(Int n, Int a, Int b){
    Int sum = 0;
    for(Int m = a; m < b; m++){
        sum += combination(n, m);
    }
    return sum;
}


P solve(int n, int a, int b, V& vs){
    map<Int, Int> counter;
    for(auto v : vs){
        counter[v]++;
    }
    Int sum = 0;
    Int m = 0;
    Int v, k;
    for(auto x = counter.rbegin(); x != counter.rend(); x++){
        v = x->first;
        k = x->second;
        if(m + k < a){
            sum += v * k;
            m += k;
        }else{
            break;
        }
    }
    Int rest = a - m;
    Double mean = (Double)(sum + v * rest) / a;
    Int pattern = (sum == 0) ? sum_combination(k, a, b + 1) : combination(k, rest);
    return P(mean, pattern);
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    V vs(n);
    for(int i = 0; i < n; i++){
        cin >> vs[i];
    }

    P ans = solve(n, a, b, vs);
    cout << fixed << setprecision(6) << ans.first << "\n" << ans.second << "\n";

    return 0;
}


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

int X[100000];
int Y[100000];

int main(){
  int N, M;
  int sum = 0;
  int ans = 0;
  cin >> N >> M;

  for ( int i = 0; i < M; i++ ) {
    cin >> X[i];
  }
  sort(X,X+M);
  for ( int i = 0; i < M-1; i++ ) {
    if ( X[i] < 0 && X[i+1] < 0 ) {
      Y[i] = (-1*X[i]) -  ( -1*X[i+1]);
    } else if ( X[i] < 0 && X[i+1] >= 0 ) {
      Y[i] = X[i+1] + (-1*X[i]);
    } else if ( X[i] >= 0 && X[i+1] >= 0 ) {
      Y[i] = X[i+1] - X[i];
    
    }
  }
  for ( int i = 0; i < M-1; i++ ) {
    // cout << "Y[i]" << " " << Y[i] << endl;
  }
  sort(Y,Y+M-1);
  for ( int i = 0; i < M-1; i++ ) {
    sum += Y[i];
  }
  if ( N > M ) {
    cout << 0 << endl;
    return 0;
  }
  if ( N == 1 ) {
    cout << sum << endl;
    return 0;
  }
  
  while ( N > 1 ) {
    sum -= Y[M-2];
    M--;
    N--;
  }
  cout << sum << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  vector<int> alpha(26,51);
  for(int i=0; i<N; i++){
    vector<int> sx(26);
    string s = vec.at(i);
    for(int j=0; j<s.size(); j++){
      int z = s.at(j) - 'a';
      sx.at(z)++;
    }
    for(int k=0; k<26; k++){
        alpha.at(k) = min(alpha.at(k),sx.at(k));
    }
  }  
  
  for(int i=0; i<26; i++){
    for(int j=1; j<=alpha.at(i); j++){
      char x = 'a' + i;
      cout << x;
    }
  }
  cout << endl;
  
}

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

using namespace std;

struct vect{
	int x, y;
};

bool equals(vector< vect > v1, vector< vect > v2 ){
	bool flg[8];
	bool ret = false;

	if( v1.size() != v2.size() ) return false;

	for(int i = 0; i < 8; i++)
		flg[i] = true;

	//0,90,180,270,反転の8通り
	for( int i = 0; i < 2; i++ ) {
		int indx;
		for(int j = 0; j < 4; j++) {
			if( i == 0 ) indx = 0;
			else indx = v1.size() - 1;
			for(int _indx = 0; _indx < v2.size(); _indx++) {
				if( j == 0 ) {
					flg[ j + i * 4 ] &= ( v1[indx].x == v2[_indx].x && v1[indx].y == v2[_indx].y );
				} else if( j == 1 ) {
					flg[ j + i * 4 ] &= ( v1[indx].x == -v2[_indx].y && v1[indx].y == v2[_indx].x );
				} else if( j == 2 ) {
					flg[ j + i * 4 ] &= ( v1[indx].x == -v2[_indx].x && v1[indx].y == -v2[_indx].y );
				} else if( j == 3 ) {
					flg[ j + i * 4 ] &= ( v1[indx].x == v2[_indx].y && v1[indx].y == -v2[_indx].x );
				}
				if( i == 0 ) indx ++;
				else indx --;
			}

		}

	}

	for(int i = 0; i < 8; i++)
		ret |= flg[i];

	return ret;

}

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	//与えられる座標をベクトルに変換する
	while( 1 ) {
		int n;
		cin >> n;
		if( n == 0 ) break;

		vector< vector< vect > > vv;

		
		for(int i = 0; i <= n; i++) {
			vector< vect > line;
			int m, px, py;
			cin >> m >> px >> py;
			for(int j = 0; j < m - 1; j++) {
				int x, y;
				cin >> x >> y;
				vect nv;
				nv.x = x - px;
				nv.y = y - py;
				px = x;
				py = y;
				line.push_back( nv );
			}
			vv.push_back( line );
		}

		for(int i = 1; i < vv.size(); i++)
			if( equals( vv[0], vv[i] ) ) cout << i << endl;



		cout << "+++++" << endl;
	}

//	while(1){}

    return 0;
}

Measured memory_bytes: 1224
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;


int main(){

	string str1,str2;
	
	cin >> str1;

	for (int i = str1.length()-1; i >= 0; i--){
		str2.push_back(str1[i]);
	}


	cout << str2 << endl;


	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<int> v;
    string n;
    cin >> n;
    for(int i = 0; i < n.length(); i++) {
        v.push_back(n[i] - '0');
    }
    int res = 0;
    for(int i = 1; i < n.length(); i++) {
        if(v[i] == v[i - 1]) {
            res++;
            v[i] = 1 - v[i - 1];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>

using namespace std;

void solve(int x, int a, int b) {
    if (b <= a) {
        std::cout << "delicious" << std::endl;
    } else if(b <= a+x){
        std::cout << "safe" << std::endl;
    } else {
        std::cout << "dangerous" << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    int x, a, b;

    gettimeofday(&start,NULL);

    std::cin >> x >> a >> b;
    solve(x, a, b);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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


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

    int total = accumulate(W.begin(), W.end(), 0);
    int partial = 0;
    int ans = 1e+9;
    for (auto elem : W) {
        partial += elem;
        int diff = abs(partial - (total - partial));
        if (diff < ans) ans = diff;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
   return a%b ==0 ? b : gcd(b,a%b);
}
struct node
{
    int a,b;
}t[100000+10];
bool cmp(node x,node y)
{
    if(x.a!=y.a)return x.a<y.a;
    return x.b<y.b;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>t[i].a>>t[i].b;
    }
    sort(t,t+m,cmp);
    int l=t[0].a;
    int r=t[0].b;
    int ans=0;
    for(int i=1;i<m;i++)
    {
        if(t[i].a>=r)
        {
            ans++;
            l=t[i].a;
            r=t[i].b;
        }
        else
        {
            if(t[i].a>l)
            {
                l=t[i].a;
            }
            if(t[i].b<r)
            {
                r=t[i].b;
            }
        }
    }
    ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i;
    scanf("%d", &i);
    
    switch(i%10){
    case 2:
   case 4:
   case 5:
   case 7:
   case 9:
    printf("hon");
    break;
    case 0:
    case 1:
    case 6:
    case 8:
    printf("pon");
    break;
    case 3:
    printf("bon");
    break;}
    return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

int mini = LONG_LONG_MAX;

void go(int sum , int c){
    if(sum == 0){
        mini = min(c , mini);
        return;
    }
    int r6 = 1;
    while(r6 <= sum){
        r6 *= 6;
    }
    r6 /= 6;
    go(sum - r6 , c+1);
    int r9 = 1;
    while(r9 <= sum){
        r9 *= 9;
    }
    r9 /= 9;
    go(sum - r9 , c+1);
}


void solve() {
    int n;
    cin>>n;
    go(n , 0);
    cout<<mini<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
// 型に合わせた値 2倍してもオーバーフローしないようにする
const int INF = 1e9;
// const LL INF = 1e17;

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    vector<int> v(D);
    // vを0, 1, 2, … D-1 という数値で埋める
    iota(all(v), 0);

    int ans = INF;
    while(1){
        int solve = 0, score = 0;
        for(auto i : v){
            if(score + 100*(i+1)*p[i] + c[i] <= G){
                solve += p[i];
                score += 100*(i+1)*p[i] + c[i];
            }else{
                int less = G-score;
                if(less == 0) break;
                solve += min(p[i], (less+100*(i+1)-1)/(100*(i+1)));
                break;
            }
        }
        ans = min(ans, solve);
        if(!next_permutation(all(v))) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    string s;
    ll n;
    cin>>n;
    cin>>s;
    ll d[26] = {};
    rep(i, n) {
        auto c = s[i];
        auto indx = c - 'a';
        d[indx]++;
    }
    auto sum = 0;
    rep(j, 26){
        auto yy = (sum * d[j]) % 1000000007;
        sum += yy + d[j];
        sum%=1000000007;
    }
    pr(sum);

    return 0;
}



Measured memory_bytes: 1144
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
import collections
N,K,L=map(int,input().split())
uf1=UnionFind(N)
for i in range(K):
  p,q=map(int,input().split())
  uf1.union(p-1,q-1)
uf2=UnionFind(N)
for j in range(L):
  r,s=map(int,input().split())
  uf2.union(r-1,s-1)
list=[]
for i in range(N):
  list.append((uf1.find(i),uf2.find(i)))
count=collections.Counter(list)
for i in range(N):
  ans=count[list[i]]
  if i==N-1:
    print(ans)
  else:
    print(ans,end=' ')

Measured memory_bytes: 61908
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


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

    cout << "Christmas";

    Rep(i,n,25){
        cout << " Eve";
    }

    cout << endl;
}


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

int main(int argc, char* argv[])
{
    int arr[3];
    int temp;
    cin >> arr[0] >> arr[1] >> arr[2];

    for (int i = 0; i < (sizeof(arr) / sizeof(arr[0])) - 1; i++)
    {
        for (int j = 1; j < (sizeof(arr) / sizeof(arr[0])); j++)
        {
            if (arr[i] > arr[j])
            {
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }

    cout << arr[0] << " " << arr[1] << " " << arr[2] << endl;

    return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 


int main(){
    ll n;string s;cin >> n >>s;
    ll rcnt=0,wcnt=0;
    rep(i,n){
        if(s[i]=='R')rcnt++;
        else wcnt++;
    }
    if(rcnt==n||rcnt==0)cout << 0 <<endl,exit(0);
    ll ans=0;
    rep(i,rcnt){
        if(s[i]=='W')ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3948
#include<stdio.h>
int main(void)
{
    int A,B;
  
    scanf("%d%d",&A,&B);
  
    if(A>=13) printf("%d\n",B);
    else if((A>=6)&&(A<=12)) printf("%d\n",B/2);
    else printf("0\n");
    
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------
// beetさんの素因数分解
template<typename T>
map<T, ll> factorize(T x){
  map<T, ll> res;
  for(ll i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}
// 使用例
//   for(int i=2; i<=N; i++){
//     for(auto p: factorize(i)){
//       cnt[p.first] += p.second;
//     }
//   }

int main(){
  ll N;
  cin >> N;
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  ll res = 1;
  map<ll,ll> cnt;
  for(int i=2; i<=N; i++){
    for(auto p : factorize(i)){
      cnt[p.first] += p.second;
    }
  }
  ll ans = 1;
  for(auto p : cnt){
    ans *= p.second+1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[100]; // dp[i] := i日目の最高所持金額

int main(void){
    ll money = 1000;
    ll kabu = 0;
    int n;

    cin >> n;

    vector<ll> a(n);

    rep(i,n)cin >> a[i];

    dp[0] = 1000;

    for(int i=0;i<n;i++){
        if(i>0)dp[i] = dp[i-1];
        for(int j=0;j<i;j++){
            chmax(dp[i],(dp[j]/a[j]) * a[i] + dp[j]%a[j]);
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  int R=x[n-1]; 
  int L=x[0];
  int ans=1000000000;
  for(int i=L;i<=R;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      sum+=(x[j]-i)*(x[j]-i);
    }
    ans=min(sum,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>
#include <math.h>

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;

    double num = std::atoi((a + b).c_str());
    num = sqrt(num);
    if(num == (int)num){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

int N;
// 上からk桁目までがsのとき(ただし、9桁固定で先頭に0があると考える)
int f(int k, int s) {
    if (k == 9) {
        stringstream ss;
        ss << s;
        string S;
        ss >> S;

        if (S.find("7") != string::npos &&
            S.find("5") != string::npos &&
            S.find("3") != string::npos &&
            s >= 1 &&
            s <= N) {
                return 1;
        } else {
            return 0;
        }
    }
    if (s != 0) {
        return f(k+1, s*10 + 7) + f(k+1, s*10 + 5) + f(k+1, s*10 + 3);
    } else {
        return f(k+1, s*10 + 7) + f(k+1, s*10 + 5) + f(k+1, s*10 + 3) + f(k+1, s*10 + 0);
    }
    
}

int main(int argc, char *argv[])
{
    cin >> N;
    cout << f(0, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
vector<int> v;
int main(){ 

int ans =0;
cin>>s ;
int cnt =0;
for(int i=0;i <4;i ++){
if(s [i]=='+')cnt++;
if(s [i]=='-')cnt--;
}
cout<<cnt<<endl;
return 0;
}


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



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

	if (n == 0) {
		n = 1;
	}
	else if (n == 1) {
		n = 100;
	}
	else {
		n = 10000;
	}

	if (d == 100) {
		cout << n * (d+1) << endl;
	}
	else {
		cout << n * d << endl;
	}

	return 0;
}

Measured memory_bytes: 384
N = list(input())
#print(N)
if N[len(N)-1]=="2" or N[len(N)-1]=="4" or N[len(N)-1]=="5" or N[len(N)-1]=="7" or N[len(N)-1]=="9":
	print("hon")
elif N[len(N)-1]=="3":
  	print("bon")
else:
	print("pon")

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

#define MaxN 100005
#define INF 2140000000
#define MOD 1000000007

using namespace std;

long long N,A,B,C,D,Ans=0;

int main()
{
    cin>>A>>B>>C>>D>>N;
    N*=4;
    if(A*2<B)
        B=2*A;
    if(B*2<C)
        C=2*B;
    if(C*2<D)
        D=2*C;
    Ans=N/8*D+N%8/4*C+N%4/2*B+N%2*A;
    cout<<Ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

void dekinai(){
	puts("No");
	exit(0);
}

ll mat[510][510];
ll ps[510][510];

ll rect(int d, int u, int l, int r){
	return ps[u][r]-ps[d-1][r]-ps[u][l-1]+ps[d-1][l-1];
}

int main()
{
	int N, M;
	int h, w;
	read(N, M, h, w);
	
	//if(N%h==0 && M%w==0) dekinai();
	
	for(int i=1; i<=N; ++i){
		for(int j=1; j<=M; ++j){
			mat[i][j]=250;
			if(i%h==0 && j%w==0) mat[i][j]=-h*250LL*w + 249;
			ps[i][j]=ps[i-1][j]+ps[i][j-1]-ps[i-1][j-1]+mat[i][j];
		}
	}
	for(int i=1; i<=N-h+1; ++i){
		for(int j=1; j<=M-w+1; ++j){
			if(rect(i, i+h-1, j, j+w-1) >= 0) dekinai();
		}
	}
	if(ps[N][M] <= 0) dekinai();
	puts("Yes");
	for(int i=1; i<=N; ++i){
		for(int j=1; j<=M; ++j){
			printf("%lld ", mat[i][j]);
		}
		putchar(10);
	}
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
 
using namespace std;

int main(){
    bool ans=1;
    int devide[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)cin>>devide[i][j];
    }
    if(!(devide[0][0]-devide[1][0]==devide[0][1]-devide[1][1]&&devide[0][1]-devide[1][1]==devide[0][2]-devide[1][2]))ans=0;
    if(!(devide[1][0]-devide[2][0]==devide[1][1]-devide[2][1]&&devide[1][1]-devide[2][1]==devide[1][2]-devide[2][2]))ans=0;
    if(!(devide[0][0]-devide[0][1]==devide[1][0]-devide[1][1]&&devide[2][0]-devide[2][1]==devide[1][0]-devide[1][1]))ans=0;
    if(!(devide[0][1]-devide[0][2]==devide[1][1]-devide[1][2]&&devide[2][1]-devide[2][2]==devide[1][1]-devide[1][2]))ans=0;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
    int N,L;
    cin >> N >> L;

    string A[N];
    for(int i=0;i<N;i++) cin >> A[i];

    sort(A,A+N);
    
    for(int i=0;i<N;i++){
        cout << A[i];
    }
    cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  char A[20];
  for(int i=1; i<=12; ++i){
    cin>>A[i];
    cout<<A[i];
    if(i==4) cout<<" ";
  }
  cout<<endl;
}


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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = 0;
       

        int a[] = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int w = 0; w < N; w++){
            int num = a[w];
           
            if(isPrime(num) == true){
                x++;
            }
        }
        System.out.println(x);
    }


    public static boolean isPrime(int num) {
        
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; 
    
        double sqrtNum = Math.sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2){
            if (num % i == 0){
        
            return false;
            }
        }
        return true;       
    }
}


Measured memory_bytes: 40800
#!/usr/bin/env python3

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

d = [0 for _ in range(201)]
for i in range(-100, 101):
    d[i+100] = i+1 

for i in p:
    d.remove(i)

d2 = [0 for _ in range(len(d))]
for i in range(len(d)):
    d2[i] = abs(d[i]-x)

m = 10000
for i in reversed(range(len(d2))):
    if d2[i] <= m:
        m = d2[i]
        tmpi = i 

print(d[tmpi])


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll a[20][20];
ll d[65540],tac[65540];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			cin >>a[i][j];
	for (int i=0;i<(1<<n);i++)
	{
		vector<bool> biti(20);
		for (int j=0;j<n;j++) if (i & (1<<j)) biti[j]=1;
		for (int j=0;j<n;j++)
			for (int k=j+1;k<n;k++)
				if (biti[j]&biti[k]) tac[i]+=a[j][k];
	}
	for (int i=0;i<(1<<n)-1;i++)
	{
		vector<int> v;
		for (int j=0;j<n;j++) if (!(i & (1<<j))) v.push_back(j);
		int t=0;
		for (int j=0;j<(1<<v.size());j++)
		{
			d[i+t]=max(d[i+t],d[i]+tac[t]);
			int ti=j,cnt=0;
			while (ti&1) ti>>=1,t-=(1<<v[cnt++]);
			if (cnt!=n) t+=(1<<v[cnt]);
		}
	}
	cout <<d[(1<<n)-1];
	return 0;
} 

Measured memory_bytes: 1280
import java.util.Scanner;

//Expected Allowance
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int k = sc.nextInt();
			if((n|m|k)==0)break;
			int[] v = new int[n*m+1];
			for(int i=1;i<=m;i++)v[i]=1;
			for(int i=2;i<=n;i++){
				int[] nv = new int[n*m+1];
				for(int j=1;j<=n*m;j++){
					if(v[j]==0)continue;
					for(int d=1;d<=m;d++){
						if(j+d<=n*m)nv[j+d]+=v[j];
					}
				}
				v = nv;
			}
			double ex = 0;
//			for(int i=1;i<=n*m;i++)System.out.println("I:" + i + " " + v[i]);
			int[] c = new int[n*m+1-k];
			for(int i=1;i<=n*m;i++){
				if(i-k<=0)c[1]+=v[i];
				else c[i-k]+=v[i];
			}
//			for(int i=1;i<=n*m-k;i++)System.out.println("I:" + i + " " + c[i]);
			int div = (int)Math.pow(m, n);
			for(int i=1;i<c.length;i++){
				ex += c[i]*1.0/div*i;
			}
			System.out.printf("%.8f\n", ex);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int N,M;
  cin >> N >> M;
  queue<int> que;
  vector<vector<int>> G(N+1);
  repr(i, M, 0) {
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist(N+1, numeric_limits<int>::max());
  que.push(1);
  dist[1] = 0;
  while (!que.empty()) {
    int now = que.front();
    que.pop();

    for (auto to : G[now]) {
      if (dist[to] == numeric_limits<int>::max()) {
        dist[to] = now;
        que.push(to);
      }
    }
  }

  cout << "Yes" << endl;
  for (int i = 2; i <= N; ++i) {
    cout << dist[i] << endl;
  }
}

Measured memory_bytes: 10156
#include <stdio.h>

void
draw(int, int);

int
main(void)
{
    int h, w;
    while (scanf("%d %d", &h, &w) && h && w)
        draw(h, w);
    return 0;
}

void
draw(int h, int w)
{
    int i, j;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++)
            putchar(i > 0 && i < h - 1 && j > 0 && j < w - 1 ? '.' : '#');
        putchar('\n');
    }
    putchar('\n');
}


Measured memory_bytes: 2036
import fractions


mod = 10 ** 9 + 7

def lcm(a, b):
    return a * b // fractions.gcd(a, b)


n = int(input())
A = list(map(int, input().split()))

num = 1
for a in A:
    num = lcm(num, a)

ans = 0
for a in A:
    ans += num // a
print(ans%mod)

Measured memory_bytes: 6200
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int a,b,c,k;
  cin>>a>>b>>c>>k;

  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);
  vector<ll> s(b*c);
  rep(i,a) cin>>p[i];
  rep(i,b) cin>>q[i];
  rep(i,c) cin>>r[i];
  rep(i,b){
    rep(j,c){
      s[i*c+j]=q[i]+r[j];
    }
  }

  sort(all(p));
  sort(all(s));

//————————————————二分探索——————————————————————————

  ll ng = INF;
  ll ok = 0;
  while (abs(ok - ng) > 1) {
    ll mid = (ng + ok) / 2;

    ll cnt=0;
    rep(i,a){
      int x = lb(s,mid-p[i]);
      cnt+=b*c-x;
    }
    (cnt>=k? ok : ng) = mid;
  }

//——————————————————————————————————————————

  vector<ll> ans;
  rep(i,a){
    int x = lb(s,ok-p[i]);
    for(int j=x;j<b*c;j++){
      ans.pb(p[i]+s[j]);
    }
  }  

  sort(all(ans));
  reverse(all(ans));

  rep(i,k){
    cout << ans[i] << endl;
  }

}

Measured memory_bytes: 142312
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printAns(bool can);

/* main */
int main(){
    int q, option, num; 
    set<int> S;
    int S_size = 0;
    cin >> q;
    for (int i  = 0; i < q; i++) {
        cin >> option >> num;
        if (option) {
            /*
            set<int>::iterator itr = S.find(num);
            if (itr != S.end()) printAns(1);
            else printAns(0);
            */
            cout << S.count(num) << '\n';
        }
        else {
            /*
            // pair<itr, bool> = S.insert(num)
            // if find num in S -> itr = find index
            // bool = whther inserted
            bool inserted = S.insert(num).second;
            S_size += inserted;
            cout << S_size << '\n';
            */
            S.insert(num);
            cout << S.size() << '\n';
        }
    }
}


void printAns(bool can) {
    if (can) cout << 1 << '\n';
    else cout << 0 << '\n';
}



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

class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();

            switch (line)
            {
                case "A":
                    Console.WriteLine("T");
                    break;

                case "C":
                    Console.WriteLine("G");
                    break;

                case "G":
                    Console.WriteLine("C");
                    break;

                case "T":
                    Console.WriteLine("A");
                    break;

                default:
                    break;
            }

        }
    }

Measured memory_bytes: 11092