akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool prime[1000100]={0};
int main(){
    int N;
    prime[1]=1;
    for(int i=2;i*i<1000000;i++){
        if(prime[i]==0){
            for(int j=i;j<1000000;j+=i){
                prime[j]=1;
            }
        prime[i]=0;
        }
    }
    while(~scanf("%d",&N)){
        int cnt=0;
        for(int i=1;i<=N;i++){
            if(prime[i]==0)cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n;cin >> n;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    vector<ll> y=x;
    sort(y);

    //x[i]がsortしたやつの前半にきてたら中央値は後半の最初だからy[n/2]
    //後半に来てた場合中央値は前半の最後だからy[n/2-1]
    for(int i=0;i<n;i++){
        if(x[i]<=y[n/2-1]){
            cout << y[n/2] << endl;
        }else{
            cout << y[n/2-1] << endl;
        }
    }
}

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

int main(){
    int N, K;
    cin >> N >> K;
    long long *h_list = new long long [N];
    if(!h_list){
        exit(EXIT_FAILURE);
    }
    for(int i=0; i<N; i++){
        cin >> h_list[i];
    }
    sort(h_list, h_list+N);
    long long dh_min = 1000000000;
    for(int i=0; i<N-K+1; i++){
        long long dh = h_list[i+K-1] - h_list[i];
        if(dh <= dh_min){
            dh_min = dh;
        }
    }
    cout << dh_min;
    delete [] h_list;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

bool chsK(string s) {
	int n = s.length();
	if (n % 2 == 0) {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i - 1])return false;
		}
	}
	else {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i - 1])return false;
		}
	}
	return true;
}

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}




int main() {
	
	int n;
	cin >> n;
	if (n >= 195)cout << 5 << endl;
	else if (n >= 189)cout <<4<< endl;
	else if (n >= 165)cout << 3 << endl;
	else if (n >= 135)cout <<2<< endl;
	else if (n >= 105)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

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

using namespace std;

int main()
{
    double n,m,d;
    double ans;
    cin>>n>>m>>d;
    if(d!=0)
    ans=1.0*2*(n-d)*(m-1)/(n*n);
    else
        ans=1.0*(n-d)*(m-1)/(n*n);
    printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 384
import itertools

A, B, C, D = list(input())
OP = ['+', '-']

for op1, op2, op3 in itertools.product(OP, OP, OP):
    s = A + op1 + B + op2 + C + op3 + D
    if eval(s) == 7:
        print(s + "=7")
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	if(n%1000==0)
		cout<<"0\n";
	else
	{
		int rem = n%1000;
		cout<<1000-rem<<"\n";
	}
}
int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
	int cnt[27] = {};
	string s;
	cin >> s;
	for(int i=0; i<s.length(); i++) {
		cnt[s[i]-'a']++;
	}
	bool ok = true;
	for(int i=0; i<27; i++) {
		if( cnt[i] % 2 ) {
			ok = false;
			break;
		}
	}
	if(ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 764
#include <iostream>

int main() {
	int N;
	std::cin >> N;
	int res = 0;
	for (int i = 1; i <= N; ++i) {
		if (i%2==0) {
			continue;
		}
		int sub_r = 0;
		for (int j = 1; j <= i; ++j) {
			if (i%j == 0) {
				++sub_r;
			}
		}
		if (sub_r==8) {
			++res;
		}
	}
	std::cout << res << "\n";
}

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

int  main()
{
	int  N,Y,x,y,z;
	
	cin>>N>>Y;
	
	for(x=0; x<=Y/10000; x++)
	   for(y=0; y<=Y/5000; y++)
	   {
	   	   z=N-x-y;
	   	   if(x*10000+y*5000+z*1000==Y && z>=0)
	   	   {
	   	       cout<<x<<' '<<y<<' '<<z<<endl;
	   	       return 0;
	       }
	   }
	   
	cout<<"-1 -1 -1"<<endl;
	
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
    #include <algorithm>
    using namespace std;
    int main() {
    	int N, ans = 0, ptr;
    	scanf("%d", &N);
    	char S[N];
    	for (int i = 0; i < N; ++i) scanf(" %c", &S[i]);
    	for (char i = '0'; i <= '9'; ++i) {
    		for (char j = '0'; j <= '9'; ++j) {
    			for (char k = '0'; k <= '9'; ++k) {
    				for (ptr = 0; ptr < N && S[ptr] != i; ++ptr);
    				for (++ptr; ptr < N && S[ptr] != j; ++ptr);
    				for (++ptr; ptr < N && S[ptr] != k; ++ptr);
    				if (ptr < N) ++ans;
    			}
    		}
    	}
    	printf("%d", ans);
    	return 0;
    }

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ret = N;
  for(int i = 1; i < S.size(); i++) {
    if(S[i] == S[i - 1]) --ret;
  }
  cout << ret << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    map<char,int> m;
    rep(i,3){
        char c; cin >> c;
        m[c]++;
    }
    cout<<700+m['o']*100<<endl;

}

Measured memory_bytes: 3624
// AOJ 2497 One
// 2018.3.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define DIV       500
#define EPS       1e-10
#define EQ(a,b)   (fabs((a)-(b))<EPS)

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int quadeq(double *x1, double *x2, double a, double b, double c) // ax^2 + bx + c = 0
{
	double d;

	if (EQ(a, 0)) {	if (!EQ(b, 0)) { *x1 = -c/b; return 1; } return 0; }
	b /= a, c /= a;	if (EQ(c, 0)) { *x1 = -b; return 1; }
	b /= 2.0, d = b*b-c;
	if (EQ(d, 0)) { *x1 = -b; return 1; }
	if (d <= 0) return 0;
	d = sqrt(d), *x1 = -b-d, *x2 = -b+d;
	return 2;
}

double fa, fp; double f(double x)
{
	double v = 2 * fa * (x - fp);
	return sqrt(1+v*v);
}
double integral(double xmin, double xmax)
{
	int i;
	double h, h2, x, ans;
	h = (xmax-xmin)/DIV, h2 = 0.5*h, x = xmin;
	ans = 0, i = DIV; while (i--) ans += f(x) + 4*f(x+h2) + f(x+h), x += h;
	return ans*h/6;
}


typedef struct { int a, p, q; } T;
T t[52];
double xx[10000]; int sz;

int cmp(double *a, double *b) { if (EQ(*a, *b)) return 0; if (*a <= *b) return -1; return 1; }

int main()
{
	int  W, H, N, i, j, k, f;
	double a, b, c, x1, x2, x;
	double ans, y, max;

	W = in(), H = in(), N = in();
	for (i = 0; i < N; i++) t[i].a = in(), t[i].p = in(), t[i].q = in();

	ans = 0, xx[0] = 0, sz = 1;
	for (i = 0; i < N; i++) {
		x = sqrt((double)t[i].q/(-t[i].a));
		x1 = t[i].p - x, x2 = t[i].p + x;
		if (x1 > 0) xx[sz++] = x1;
		if (x2 < W) xx[sz++] = x2;

		for (j = i+1; j < N; j++) {
			a = t[i].a - t[j].a;
			b = -2*(t[i].a*t[i].p - t[j].a*t[j].p);
			c = t[i].a*t[i].p*t[i].p - t[j].a*t[j].p*t[j].p + t[i].q-t[j].q;
			k = quadeq(&x1, &x2, a, b, c);
			if (k  > 0 && x1 > 0 && x1 < W) xx[sz++] = x1;
			if (k == 2 && x2 > 0 && x2 < W) xx[sz++] = x2;
		}
	}
	xx[sz++] = W;
	qsort(xx, sz, sizeof(double), cmp);

	for (i = 1; i < sz; i++) {
		x1 = xx[i-1], x2 = xx[i];
		if (EQ(x1, x2)) continue;

		x = (x1+x2)/2, max = 0, f = -1;
		for (k = 0; k < N; k++) {
			y = t[k].a*(x-t[k].p)*(x-t[k].p) + t[k].q;
			if (y > max) f = k, max = y;
		}
		if (f >= 0) fa = t[f].a, fp = t[f].p, ans += integral(x1, x2);
	}
	printf("%.15lf\n", ans);
	return 0;
}


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

vector<pair<ll,ll> > res;

//Nについて素因数分解
void factor(int N){
    for(int i=2;i*i <= N;i++){
        
        if(N % i != 0)continue;
        ll count = 0;
        while(N % i == 0){
            count++;
            N /= i;
        }
        res.push_back({i,count});
    }
    if(N !=1)res.push_back({N,1});
}
int main()
{
    int N; cin >> N;
    for(int i=N;i>1;i--){
         factor(i);
    }
    
    vector<ll> fac(N+1,0);
    for(auto a:res){
       fac[a.first] +=a.second;
    }

    ll sum = 1;
    for(int i=0;i<=N;i++){
        sum *= (fac[i] + 1);
        sum %= MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 384
sa = input()
sb = input()
sc = input()

ai = 0
bi = 0
ci = 0
now = 'a'
while 1:
    if now == 'a':
        ai+=1
        if ai==len(sa)+1:
            ans = 'A'
            break
        now=sa[ai-1]
    elif now == 'b':
        bi+=1
        if bi==len(sb)+1:
            ans = 'B'
            break
        now=sb[bi-1]
    else:
        now == 'c'
        ci+=1
        if ci==len(sc)+1:
            ans = 'C'
            break
        now=sc[ci-1]
print(ans)


Measured memory_bytes: 38384
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC075 =
    let rec binarySearchInt64 f s t =
        if s+1L=t then s
        else
            let d = (s+t)/2L
            if f d then binarySearchInt64 f d t
            else binarySearchInt64 f s d

    let private Widespread () =
        let g64 = ReadNext >> int64
        let ubDiv a b = (a - 1L) / b + 1L
        let n = ReadNextInt ()
        let inA, b = g64 (), g64 ()
        let a = inA - b
        let h = ReadListOf int64 n
        let f inD =
            let d = inD - 1L
            let bd = d * b
            let rec inner c = function
                | [] -> c >= 0L
                | h :: t ->
                    if h <= bd then inner c t
                    elif c < 0L then false
                    else
                        let r = ubDiv (h - bd) a
                        inner (c - r) t
            inner d h |> not
        h |> Seq.max |> (+) 1L
        |> binarySearchInt64 f 1L
        |> printfn "%d"

    let Entry = Widespread

ARC075.Entry ()

Measured memory_bytes: 23740
#include <stdio.h>

int main(void) {
	int N,D,A[11][11],ans=0,sum=0;
	scanf("%d%d",&N,&D);
	for(int i=0; i<N; i++){
		for(int j=0; j<D; j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(int i=0; i<N-1; i++){
		for(int j=i+1; j<N; j++){
			for(int k=0; k<D; k++){
				sum += (A[i][k] - A[j][k])*(A[i][k] - A[j][k]);
			}
			for(int k=0; k*k<=sum; k++){
				if(k*k == sum){
					ans++;
					break;
				}
			}
			sum = 0;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, D;
    cin >> N >> D;
    ll cnt = 0;
    rep(i, N){
        ld a, b;
        cin >> a >> b;
        cnt += (sqrt(a * a + b * b) <= D);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3856
#include <stdio.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, ans = 0, a;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    ans += a - 1;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n ; i++)
#define MAX 10000001

 
 bool is[MAX];

// n log log n
// 10^8 
void era(){
  rep(i,0,MAX) is[i] = true;
  is[0] = is[1] = 0;
  rep(i,2,MAX){
    if(is[i]){
      for(int j = 2; i*j < MAX; j++){
	is[i*j] = false;
      }   
    }
  }
}

int main(){
  // N root(n)
  // 10^4 10^4
  int n,p,ans = 0;
  cin >> n;

  rep(i,0,n){
    cin >> p;
    bool ex =true;
    if((p%2 == 0 && p != 2 )|| p == 1) continue;
    for(int j = 3 ;j <= sqrt(p) ;j += 2){
    
      if(p%j == 0) ex = false;
    }
    if(ex) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1160
function body(f){
    var ans;
    if (f[0] < f[1]) {
	ans = "a < b";
    } else if (f[0] === f[1]) {
	ans = "a == b";
    } else {
	ans = "a > b";
    }
    return(ans);
}
    
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var lines=input.split("\n");
var f = lines[0].split(" ").map((x)=>parseInt(x));

console.log(body(f));


Measured memory_bytes: 15116
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
s//=n
cost=0
for i in a:
  cost+=(i-s)*(i-s)
ans=cost
s+=1
cost=0
for i in a:
  cost+=(i-s)*(i-s)
ans=min(ans,cost)
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		int z = Integer.parseInt(sc.next());
		System.out.println((int)Math.floor((x-z)/(y+z)));
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
using namespace std;

typedef long long ll;
ll MOD = 1e9 + 7;
ll cnt[100005];

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> sizes;
    UnionFind(int n): par(n), rank(n), sizes(n){
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
            sizes[i] = 1;
        }
    }

    int root(int x){
        if(par[x] == x)
            return x;
        else
            return par[x] = root(par[x]);
    }

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

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        else {
            if(rank[x] < rank[y]){
                par[x] = y;
                sizes[y] += sizes[x];
            } else {
                par[y] = x;
                sizes[x] += sizes[y];
                if(rank[x] == rank[y]) rank[x]++;
            }
        }
    }

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

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uni(N+1);

    for(int i = 0; i < M; i++){
        int x, y, z;
        cin >> x >> y >> z;
        if(uni.root(x) != uni.root(y))
            uni.unite(x, y);
    }
    
    for(int i = 1; i <= N; i++){
        cnt[uni.root(i)]++;
    }

    ll ans = N;

    for(int i = 1; i <= N; i++){
        if(cnt[i] > 0)
            ans -= cnt[i]-1;
    }

    cout << ans << endl;

}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,ans = 0;
    cin >> a >> b >> c;
    for (;;) {
        if ((a&1) || (b&1) || (c&1)) { printf("%d\n",ans); break; }
        if (a == b && b == c) { puts("-1"); break; }

        ans++;
        int na = (b + c) >> 1;
        int nb = (a + c) >> 1;
        int nc = (a + b) >> 1;
        a = na, b = nb, c = nc;             
    }
    return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int p[100005];
    string S[100005];
    for (int i = 1; i <= M; i++)
    {
        cin >> p[i] >> S[i];
    }

    bool AC[100005] = {};
    int penalty[100005] = {};
    for (int i = 1; i <= M; i++)
    {
        if (S[i] == "AC") AC[p[i]] = true;
        else if (! AC[p[i]]) penalty[p[i]]++;
    }

    int ans_AC = 0, ans_penalty = 0;
    for (int i = 1; i <= N; i++)
    {
        ans_AC += AC[i];
        if (AC[i]) ans_penalty += penalty[i];
    }

    cout << ans_AC << " " << ans_penalty << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
int main(void){

	int a,b,c,r;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a>b){
		r=a;
		a=b;
		b=r;
	}
	if(b>c){
		r=c;	
		c=b;
		b=r;
	}
	if(a>b){
		r=a;
		a=b;
		b=r;
	}
	printf("%d %d %d\n",a,b,c);

	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll a,b;
    cin>>a>>b;
    if(a<=b)cout<<a;
    else cout<<a-1;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e3+10, mod=1e9+7;

int main ()
{
    FASTIO
    ll n , m , sum=0;
    cin >> n >> m ;
    for(int i=0;i<m;i++){
        ll a;
        cin >> a;
        sum += a;
    }
    cout << max(n-sum,-1ll) << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////
#include <atcoder/string>


int main()
{
    string S;
    io >> S;

    vi sa = atcoder::suffix_array(S);
    vi lcpa = atcoder::lcp_array(S, sa);

    ll sum = accumulate(begin(lcpa), end(lcpa), 0ll);
    ll N = S.size();
    ll ans = N * (N+1) / 2 - sum;

    io << ans << BR;
}

Measured memory_bytes: 15556
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

ll gcd(ll x, ll y)
{
    return y ? gcd(y, x % y) : x;
}

int main() {
    cin>>n>>k;
    vi v(n);
    REP(i,n) {
        cin>>v[i];
    }
    m=v[0];
    REP(i,n) {
        m=gcd(m,v[i]);
    }
    ll g = *max_element(ALL(v));
    cout<<((k>g||(k<=g&&k%m))?"IMPOSSIBLE":"POSSIBLE")<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int card[5];
    int i, j, temp;

    while(scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF){
        for(i=0;i<4;i++){
            for(j=4;j>i;j--){
                if(card[j-1]>card[j]){
                    temp=card[j];
                    card[j]=card[j-1];
                    card[j-1]=temp;
                }
            }
        }

        if(card[0]==card[3]||card[1]==card[4]) printf("four card\n");
        else if((card[0]==card[1]&&card[2]==card[4])||(card[0]==card[2]&&card[3]==card[4])) printf("full house\n");
        else if(card[0]==card[2]||card[1]==card[3]||card[2]==card[4]) printf("three card\n");
        else if((card[0]==card[1]&&(card[2]==card[3]||card[3]==card[4]))||(card[1]==card[2]&&card[3]==card[4])) printf("two pair\n");
        else if(card[0]==card[1]||card[1]==card[2]||card[2]==card[3]||card[3]==card[4]) printf("one pair\n");
        else if((card[4]==(card[0]+4))||(card[0]==1&&card[4]==13&&card[3]==12&&card[2]==11&&card[1]==10)) printf("straight\n");
        else printf("null\n");
     
    }
    return 0;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  if(a<=5){
    cout << 0 << endl;
  } else if(a<=12){
    cout << b/2 << endl;
  } else {
    cout << b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define alphanso                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL)
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main()
{
	alphanso;
	ull n, i, j, ans = 0;
	cin >> n;
	int arr[3 * n];
	for (i = 0; i < 3 * n; i++)
		cin >> arr[i];
	sort(arr, arr + 3 * n, greater<int>());
	for (i = 1, j = 1; j <= n; i += 2, j++)
		ans += arr[i];
	cout << ans;
	return 0;
}


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

using namespace std;

int h,w,k;
char matrix[6][6];
int bl = 0;

int solve(int n){
	bitset<13> b = n;
	int ans= 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(b.test(i+w) && b.test(j) == false){
				if(matrix[i][j] == '#')
					ans++;		
			}
		}
	}
	if(ans == k)
		return 1;
	else
		return 0;
}

int main(){

	cin >> h >> w >> k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> matrix[i][j];
		}
	}
	int ans = 0;
	for(int i=0;i<pow(2,h+w);i++){
		ans += solve(i);
	}	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
int main(){
   long long  X, Y, A, B ,C;
   cin >> X >> Y >> A >> B >> C;
   vector<long long> p(A);
   vector<long long> q(B);
   vector<long long> r(C);
   for(int i = 0; i < A; i++) cin >> p[i];
   for(int i = 0; i < B; i++) cin >> q[i];
   for(int i = 0; i < C; i++) cin >> r[i];
   sort(p.begin(), p.end());
   sort(q.begin(), q.end());
   sort(r.begin(), r.end());
   reverse(r.begin(), r.end());
   vector<long long> d(X + Y);
   for(int i = 0; i < X; i++){
       d[i] = p[A - 1 - i];
   }
   for(int i = X; i < X + Y; i++){
       d[i] = q[B - 1 - (i - X)];
   }
   sort(d.begin(), d.end());
   long long ans = 0;
   long long l = 0;
   for(int i = 0 ; i < X + Y; i++){
       if(d[i] < r[l] && l != -1){
           ans += r[l];
           if(l == C - 1) l = -1;
           else l++;
       }
       else ans += d[i];
   }
   cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;


int main() {
    vector<int> Sto2nd;
    unordered_map<int, bool> secTo3rd;

    int N, M;
    cin >> N >> M;

    int a, b;
    for (int m = 0; m < M; m++) {
        cin >> a >> b;
        if (a == 1) { Sto2nd.push_back(b); }
        else {
            if (b == N) { secTo3rd[a] = true; }
        }
    }

    vector<int>::iterator i = Sto2nd.begin();
    bool isPossible = false;
    while (i != Sto2nd.end()) {
        auto pair = secTo3rd.find(*i);
        if (pair != secTo3rd.end()) {
            isPossible = true;
            break;
        }
        i++;
    }

    if (isPossible) { cout << "POSSIBLE" << endl; }
    else { cout << "IMPOSSIBLE" << endl; }

    return 0;
}

Measured memory_bytes: 4764
#include<cstdio>
#include<cstdlib>
#include<cstring>
   
struct Node{
  int key;
  Node *next, *prev;
};
   
Node *nil;
   
Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur -> key != key) {
    cur = cur -> next;
  }
  return cur;
}
   
void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}
  
void printList() {
  Node *cur = nil -> next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur -> key);
    cur = cur -> next;
  }
  printf("\n");
}
   
void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
   
void deleteFirst() {
  deleteNode(nil->next);
}
   
void deleteLast() {
  deleteNode( nil -> prev);
}
   
void deleteKey(int key) {
  deleteNode(listSearch(key));
}
   
void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x -> key = key;
   
  x -> next = nil -> next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}
   
int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
      deleteKey(key); nd++;
      }
      size--;
    }
  }
   
  printList();
   
  return 0;
}
 


Measured memory_bytes: 33860
#include <iostream>

int main() {
    int r, d;
    int x[11];

    std::cin >> r >> d;
    std::cin >> x[0];

    for (int i = 1; i <= 10; i++) {
        x[i] = r * x[i - 1] - d;
        std::cout << x[i] << std::endl;
    }
}

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

using namespace std;

typedef long long ll;

int main(){
    int n, t, x, y, mi = 99999;
    cin >> n >> t;
    for(int a = 0; a < n; a++){
        cin >> x >> y;
        if(y <= t){
            mi = min(x, mi);
        }
    }
    if(mi == 99999)cout << "TLE" << endl;
    else cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)cout<<b+c<<endl;
	else cout<<a+2*b+1<<endl;
	return 0;
}




Measured memory_bytes: 256
N = int(input())
if N < 105:
    print(int(0))
elif 105<=N<135:
    print(int(1))
elif 135<=N<165:
    print(int(2))
elif 165<=N<189:
    print(int(3))
elif 189<=N<195:
    print(int(4))
else:
    print(int(5))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
#define fs first
#define re resize
#define sc second
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,n) FOR(i,0,n-1)
#define ins insert
#define mod 1000000007
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define endl "\n"
void fastIO(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif   
}
ll modexpo(ll a , ll b){
    if(a==0)return 0;
    if(a==1 or b==0)return 1;
    if(b==1)return a;
    if(b&1) return (a%mod*modexpo(a,b-1)%mod)%mod;
    return modexpo(a%mod * a%mod  ,  b/2 ) % mod;
}
void printv(vll v){
    for(auto&x:v) {
        cout<<x<<" ";
    }
    cout<<endl;
}
string to_string1(ll x){stringstream ss; ss<<x; return ss.str();}
ll to_integer(string s){stringstream ss(s); ll x; ss>>x; return x;}
#define tp9 1000000000 
#define N 8000
ld pi = 3.1415926535;
void printYes() {
    cout << "Yes\n";
}
void printNo() {
    cout << "No\n";
}
ll t , n , p ;
string s;

int main (){
    ll a ;
    ld b; 
    cin >> a >> b ;
    ll bb = b*100 + 0.01 ;
    ll c = a*bb ;
    cout<<c/100;    
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 998244353;


int main(){
	int n,k; cin >> n >> k;
	vector<int> l(k+1),r(k+1);
	for(int i=1; i<=k; i++){
		cin >> l[i] >> r[i];
	}

	vector<ll> dp(n+1);
	vector<ll> dpsum(n+1);
	dp[1] = 1;
	dpsum[1] = 1;
	for(int i=2; i<=n; i++){
		for(int j=1; j<=k; j++){
			int lim_r = i-l[j];
			int lim_l = i-r[j];
			if(lim_r < 0) continue;
			lim_l = max(lim_l,1);
			dp[i] = (dp[i] + dpsum[lim_r] - dpsum[lim_l-1] + MOD) % MOD;
		}
		dpsum[i] = (dp[i] + dpsum[i-1]) % MOD;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 6404
K = int(input().split()[3])
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

ans = []
for i in range(len(A)):
    for j in range(len(B)):
        if (i+1) * (j+1) > K:
            break
        for k in range(len(C)):
            if (i+1)*(j+1)*(k+1) > K:
                break
            ans.append(A[i]+B[j]+C[k])
ans.sort(reverse=True)
for _ in range(K):
    print(ans[_])



Measured memory_bytes: 8728
#include <stdio.h>

int main(void)
{
    int x, y;
    char buf[256];
    while (1)
    {
        fgets(buf, 256, stdin);
        buf[255] = '\0';
        sscanf(buf, "%d %d", &x, &y);

        if (!(x | y)) break;
        if (y < x)
            printf("%d %d\n", y, x);
        else
            printf("%d %d\n", x, y);
    }

    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
#define fr first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()

using namespace std;

const ll MOD = 1000000007;

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

    ll n, d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3640
h, w = map(int, input().split())
field = []

for i in range(h):
    field.append(list(input()))

dp = [[0 for i in range(w)] for j in range(h)]

for i in range(1, w):
    if field[0][i - 1] == field[0][i]:
        dp[0][i] = dp[0][i - 1] 

    else:
        if field[0][i - 1] == "." and field[0][i] == "#":
            dp[0][i] = dp[0][i - 1] + 1
        else:
            dp[0][i] = dp[0][i - 1]

for i in range(1, h):
    if field[i][0] == field[i - 1][0]:
        dp[i][0] = dp[i - 1][0]
    else:
        if field[i - 1][0] == "." and field[i][0] == "#":
            dp[i][0] = dp[i - 1][0] + 1
        else:
            dp[i][0] = dp[i - 1][0]

for y in range(1, h):
    for x in range(1, w):
        dp[y][x] = min(dp[y - 1][x] + (1 if field[y][x] != field[y - 1][x] and field[y - 1][x] == "." else 0), dp[y][x - 1] + (1 if field[y][x] != field[y][x - 1] and field[y][x - 1] == "."  else 0))

print(dp[h - 1][w - 1] + (1 if field[0][0] == "#" else 0))


Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            for(int c = 1; (n = scn.nextInt()) > 0; c++) {
                int cnt = 0;
                boolean dir = true;
                int[][] tbl = new int[n][n];

                for (int i = 0; i < n; i++) {
                    for (int j = 0; j <= i; j++) {
                        if (dir) {
                            tbl[i - j][j] = ++cnt;
                        } else {
                            tbl[j][i - j] = ++cnt;
                        }
                    }
                    dir = !dir;
                }

                for (int i = 0; i < n; i++) {
                    for (int j = 1; j < n - i; j++) {
                        if (dir) {
                            tbl[n - j][i + j] = ++cnt;
                        } else {
                            tbl[i + j][n - j] = ++cnt;
                        }
                    }
                    dir = !dir;
                }

                System.out.println("Case " + c + ":");
                for (int[] ary : tbl) {
                    for (int elm : ary) {
                        System.out.format("%3d", elm);
                    }
                    System.out.println();
                }
            }
        }
    }
}

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

inline vector<P> doit(vector<int> vec){
    vector<P> ans;
    vec.push_back(0);
    int cnt=0;
    rep(i,vec.size()-1){
        cnt++;
        if(vec.at(i)!=vec.at(i+1)){
            ans.push_back(P(cnt,vec.at(i)));
            cnt=0;
        }
    }
    return ans;
}

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    sort(all(a));
    vector<P> cnt=doit(a);
    rep(i,cnt.size()){
        while(cnt.at(i).first>=3){
            cnt.at(i).first-=2;
        }
    }
    int cnt2=0;
    rep(i,cnt.size()){
        if(cnt.at(i).first==2) cnt2++;
    }
    cout<<cnt.size()-cnt2+(cnt2/2)*2<<endl;
}

Measured memory_bytes: 4848
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-variable"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
// }}}

int main() {
    int n;
    LL sum=0;
    cin >> n;
    REP(i,n) {
        int a;
        cin >> a;
        sum+=(a%2);
    }
    if ( sum>0 ) cout << "first" << '\n';
    else cout << "second" << '\n';
    return 0;
}








Measured memory_bytes: 3600
MOD = 1000000007

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)] + [N + 2]

dp, id = [0, 1], 0
for i in range(N):
    if A[id] - 1 == i:
        id += 1
        dp.append(0)
    else:
        dp.append(dp[-1] + dp[-2])

print(dp[-1] % MOD)


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

using namespace std;
#define mp make_pair
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;

const int mod = 2019;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    vi cnt(mod,0);
    int i, curr = 0, p10 = 1;

    ll ans = 0;
    for(i = s.size()-1;i>=0;i--){
        curr = (curr + ((int(s[i]-'0')*p10)%mod))%mod;
        ans += cnt[curr];
        if(curr == 0) ans++;
        cnt[curr]++;
        p10 = (p10*10)%mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3768
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll N;
  cin >> N;
  vector<string> s(N);
  vector<ll> t(N);
  rep(i, N) cin >> s[i] >> t[i];
  string X;
  cin >> X;

  ll ans = 0;
  bool ok = false;
  rep(i, N) {
    if (ok) {
      ans += t[i];
    } else {
      if (s[i] == X) ok = true;
    }
  }
  out(ans);
}


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

int main(){
    int N;
    cin >> N;
    switch(N%10){
     case(3) : cout << "bon" << endl;
               break;
     case(0) : cout << "pon" << endl;
                break;
     case(1) : cout << "pon" << endl;
                break;
     case(6) : cout << "pon" << endl;
                break;
     case(8) : cout << "pon" << endl;
                break;
     default  : cout << "hon" << endl;
                break; 
    } 
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;

class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			int n = Integer.parseInt(s);
			double sum = (n / 2.0) * (1 + n);
			ans.add((int)sum + 1);
		}
		
		for (int a : ans)
			System.out.println(a);
		
	}
	
}

Measured memory_bytes: 9336
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long f[100][10];
long long p[100][11];
long long d[10];
long long n;

long long calc() {
	bool flg = true;
	long long s[100] = {};
	for (long long i = 0; i < 10; i++) {
		if (d[i] != 0) {
			flg = false;
			break;
		}
	}
	if (flg) {
		return -1000000000;
	}
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < 10; j++) {
			if (d[j] && f[i][j]) {
				s[i]++;
			}
		}
	}
	long long res = 0;
	for (long long i = 0; i < n; i++) {
		res += p[i][s[i]];
	}
	return res;
}
long long solve(long long depth) {
	if (depth == 10) {
		return calc();
	}
	long long l, r;
	d[depth] = 0;
	l = solve(depth + 1);
	d[depth] = 1;
	r = solve(depth + 1);
	return max(l, r);
}
int main() {
	cin >> n;
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j <= 10; j++) {
			cin >> p[i][j];
		}
	}
	cout << solve(0) << endl;

	return 0;
}

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

int main() {
    int n, k;
    std::cin >> n >> k;
    long double p = 0.0;
    for (int i = 1; i <= n; i++) {
        long double t;
        if (k - i <=0) {
            p += 1;
            continue;
        }
        long double r = log2(k) - log2(i);

        int rr = ceil(r);
        t = std::pow(0.5, rr);
        p += t;

    }
    std::cout << std::setprecision(12) << p/n << std::endl;
    return 0;
}


Measured memory_bytes: 256