akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int[] sum = new int[N+1];
        // for(int i=1;i<=N;i++){
            for(int x=1;x*x<=N;x++){
                for(int y=1;x*x+y*y<=N;y++){
                    for(int z=1;x*x+y*y+z*z<=N;z++){
                        if(x*x+y*y+z*z+x*y+y*z+z*x<=N){
                            sum[x*x+y*y+z*z+x*y+y*z+z*x]++;
                        }
                    }
                }
            }
        // }
        for(int i=1;i<=N;i++){
            System.out.println(sum[i]);
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 39120
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int n,m,x;
int s[1000000];
int a[1000000];
int size=0;
char str[100];
set<P> t;

bool check(int r,int x){
  int cnt=n;
  int* d=a;
  set<P> :: iterator it;
  for(it=t.begin();it!=t.end();it++){
    int k=it->first;
    int* target=lower_bound(d,a+n,k-r);
    d = upper_bound(d,a+n,k);
    cnt-=(d - target);
  }
  if(cnt<=x)return true;
  else return false;
}

int solve(int x){
  int L=0,R=1e9,M;
  if(!check(R,x))return -1;
  while(L<R){
    M=(L+R)/2;
    if(check(M,x))R=M;
    else L=M+1;
  }
  return L;
}

int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
    a[i]=s[i];
  }
  sort(a,a+n);
  
  for(int i=0;i<m;i++){
    scanf("%s %d",str,&x);    
    if(str[0]=='A'){
      t.insert(P(s[x-1],x-1));
    }else if(str[0]=='R'){
      t.erase(P(s[x-1],x-1));
    }else if(str[0]=='C'){
      int ans=solve(x);
      if(ans==-1)printf("NA\n");
      else printf("%d\n",ans);
    }
  }
  return 0;
}

Measured memory_bytes: 9036
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(double x0, double y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        return x != p.x ? x < p.x : y < p.y ;
    }

};

double norm(Point p){
    return p.x * p.x + p.y * p.y;
}

double v_abs(Point p){
    return sqrt(norm(p));
}

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c0, double r0){
        c.x = c0.x;
        c.y = c0.y;
        r = r0;
    }
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

Point rotation(Vector v, double th){
    Point p;
    p.x = cos(th) * v.x - sin(th) * v.y;
    p.y = sin(th) * v.x + cos(th) * v.y;
    return p;
}

int main(){
    Circle c1, c2;
    cin >> c1.c.x >> c1.c.y >> c1.r;
    cin >> c2.c.x >> c2.c.y >> c2.r;
    Vector base = c2.c - c1.c;
    double t = v_abs(base);
    double th = acos((t * t + c1.r * c1.r - c2.r * c2.r) / (2 * t * c1.r));
    base = base * (c1.r / v_abs(base));
    vector<Point> P;
    P.push_back(c1.c + rotation(base, th));
    P.push_back(c1.c + rotation(base, -th));
    sort(all(P));
    printf("%.10lf %.10lf ", P[0].x, P[0].y);
    printf("%.10lf %.10lf\n", P[1].x, P[1].y);
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,W;
    cin>>n>>W;
    long long int i,w[n+1],v[n+1];
    for(i=1;i<=n;i++) cin>>w[i]>>v[i];
    long long int j,dp[n+1][W+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=W;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(j>=w[i]){
             dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
        }
        else dp[i][j]=dp[i-1][j];
    }
    }
    cout<<dp[n][W]<<endl;
  return 0;
}


Measured memory_bytes: 79104
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# [a,a],[a,a-1]が負け状況

X,Y = LI()
if abs(X-Y) == 1 or abs(X-Y) == 0:
    print('Brown')
else:
    print('Alice')

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

int main() {
    int k;
    cin >> k;
    queue<ll> a;
    for (int i = 1; i < 10; ++i) a.push(i);
    rep(i,k-1){
        ll s = a.front();
        a.pop();
        for (int j = -1; j <= 1; j++) {
            ll add = (s % 10) + j;
            if (add >= 0 && add <= 9) a.push(s * 10 + add);
        }
    }
    cout << a.front() << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N, K;

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

  std::cin >> N >> K;

  ll res = 0;

  for(int i=K;i<=N+1;++i){
      res += (1ll * i * N - 1ll * i * (i - 1) + 1) % MOD;
      if(res >= MOD){
          res -= MOD;
      }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 3652
string solve(int n){
	int x = (n.to!double/1.08).to!int();
	if((x*1.08).to!int() < n)x++;
	if((x*1.08).to!int()==n)return x.to!string();
	else return ":(";
}
void main(){
	int n = inelm();
	writeln(solve(n));
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> hi(n);
  for (int i = 0; i < n; i++) cin >> hi.at(i);
  
  int ans = 0;
  int h = hi.at(0);
  for (int i = 0; i < n; i++) {
    if (h <= hi.at(i)) ans++;
    h = max(h, hi.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits>
using ll = long long;
constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll LNF = std::numeric_limits<ll>::max() / 2;

#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    for (size_t i = 0; i < s.size(); i += 2) { cout << s[i]; }
    cout << endl;

    return 0;
}


Measured memory_bytes: 512
A,B=map(int,input().split())
sc = 0
if A == 1:
  sc += 300000
elif A == 2:
  sc += 200000
elif A == 3:
  sc += 100000
if B == 1:
  sc += 300000
  if A==1:
    sc += 400000
elif B== 2:
  sc += 200000
elif B == 3:
  sc += 100000
print(sc)

Measured memory_bytes: 3064
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define endl "\n"
const int mod = 1e9+7;
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int power(int a,int b){ int res=1; a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

ll a[101][100001];
int main()
{	
	sync
	int n, w;
	cin >> n >> w;
	int in[n+1][2];
	for(int i = 1; i <= n; i++)
		cin >> in[i][0] >> in[i][1];
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < 100001; j++)
		{
			if(in[i][0] <= j)
				a[i][j] = max(a[i-1][j], in[i][1]+a[i-1][j-in[i][0]]);
			else 
				a[i][j] = a[i-1][j];
		}
	}
	cout << a[n][w];
	return 0;
}

Measured memory_bytes: 78336
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int n,m,cnt,ans,p,x[100010];
int main()
{
	int i,s,a,b,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&x[i]);
	sort(x+1,x+1+n);
	for(i=2,s=1;i<=n;i++)
		if(x[i]!=x[i-1])
		{
			k=i-s;
			if(k<x[i-1])ans+=k;
			else ans+=k-x[i-1];
			s=i;
		}
	k=i-s;
	if(k<x[i-1])ans+=k;
	else ans+=k-x[i-1];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 10

void Func(int);

int N;
int h[120];
int H[120] = {};
int cnt = 0;

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  cin >> N;
  rep(i, N) cin >> h[i];

  rep(i, N) {
    if(h[i] != H[i]) {
      Func(i);
    }
  }

  cout << cnt << endl;

  return 0;
}

void Func(int n) {

  while(h[n] != H[n]) {
    int index = n;
    
    while(index < N) {
      if(H[index] == h[index]) break;

      index += 1;
    }

    for(int j=n; j<index; ++j) {
      ++H[j];
    }
    ++cnt;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> p;

int w, h;
int movement[3] = {-1, 0, 1};
char map[100][100], cur, dump;

void dfs(p t){
    int curX = t.first, curY = t.second;
    for(int x=0; x<3; ++x){
        for(int y=0; y<3; ++y){
            if(movement[x]!=0 && movement[y]!=0) continue;
            if(curX+movement[x]>=0 && curY+movement[y]>=0 &&
                curX+movement[x]<w && curY+movement[y]<h &&
                map[curX+movement[x]][curY+movement[y]]==cur){
                map[curX+movement[x]][curY+movement[y]]='E';
                dfs(make_pair(curX+movement[x], curY+movement[y]));
            }
        }
    }
}

int main(){
    while(cin >> w >> h){
        if(!w && !h) break;

        for(int i=0; i<w; ++i){
            for(int j=0; j<h; ++j){
                cin >> map[i][j];
            }
        }


        /// bfs
        /*queue<p> myqueue;
        int counter = 0;

        for(int i=0; i<w; ++i){
            for(int j=0; j<h; ++j){
                if(map[i][j]=='E') continue;
                cur = map[i][j];
                p t = make_pair(i, j);
                myqueue.push(t);
                while(!myqueue.empty()){
                    t = myqueue.front();
                    myqueue.pop();
                    map[t.first][t.second] = 'E';
                    int curX = t.first, curY = t.second;
                    for(int x=0; x<3; ++x){
                        for(int y=0; y<3; ++y){
                            if(movement[x]!=0 && movement[y]!=0) continue;
                            if(curX+movement[x]>=0 && curY+movement[y]>=0 &&
                                curX+movement[x]<w && curY+movement[y]<h &&
                                map[curX+movement[x]][curY+movement[y]]==cur){
                                myqueue.push(make_pair(curX+movement[x], curY+movement[y]));
                            }
                        }
                    }

                }

                counter++;
            }
        }*/

        /// dfs
        int counter = 0;

        for(int i=0; i<w; ++i){
            for(int j=0; j<h; ++j){
                if(map[i][j]=='E') continue;
                cur = map[i][j];
                map[i][j]='E';
                dfs(make_pair(i, j));
                counter++;
            }
        }

        /// printf
        cout << counter << endl;
    }
    return 0;
}



Measured memory_bytes: 3480
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll s[100100],t[100100];

int main(void){
	int n,m,q,sl,sr,tl,tr,i;
	ll x,ans;
	cin >> n >> m >> q;
	s[0] = -INFLL;
	for(i=1; i<=n; ++i){
		cin >> s[i];
	}
	s[n+1] = INFLL;
	n += 2;
	t[0] = -INFLL;
	for(i=1; i<=m; ++i){
		cin >> t[i];
	}
	t[m+1] = INFLL;
	m += 2;
	for(i=0; i<q; ++i){
		ans = INFLL;
		cin >> x;
		sr = (int)(lower_bound(s,s+n,x)-s);
		sl = sr-1;
		tr = (int)(lower_bound(t,t+m,x)-t);
		tl = tr-1;
		ans = min(abs(x-s[sr])+abs(s[sr]-t[tr]),ans);
		ans = min(abs(x-s[sr])+abs(s[sr]-t[tl]),ans);
		ans = min(abs(x-s[sl])+abs(s[sl]-t[tr]),ans);
		ans = min(abs(x-s[sl])+abs(s[sl]-t[tl]),ans);
		ans = min(abs(x-t[tr])+abs(t[tr]-s[sr]),ans);
		ans = min(abs(x-t[tr])+abs(t[tr]-s[sl]),ans);
		ans = min(abs(x-t[tl])+abs(t[tl]-s[sr]),ans);
		ans = min(abs(x-t[tl])+abs(t[tl]-s[sl]),ans);
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

ll *num;

void init(){
}

void solve(){
    char c;
    cin >> c;
    if (c >= 'a' && c <= 'z') cout << 'a' << "\n";
    else cout << "A\n";
}

int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  vector<float> A(N), A_inv(N);
 
  cin>>N;
  for(int i; i<N; i++){
    cin>>A.at(i);
    A_inv.at(i) = 1/A.at(i);
  }
  float S_inv = 0;
  for(int i; i<N; i++){
    S_inv += A_inv.at(i);
  }
  cout<<1/S_inv<<"\n";
}

Measured memory_bytes: 512
import sys
line = sys.stdin.readline().strip()

n = "N" in line
s = "S" in line
e = "E" in line
w = "W" in line

if not (n or s) and (e and w):
    print "Yes"
elif (n and s) and not (e or w):
    print "Yes"
elif n and s and e and w:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
package main

import (
	"fmt"
)

func main() {
	var k, a, b int
	fmt.Scanf("%d\n%d %d", &k, &a, &b)
	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1816
#include <iostream>

using namespace std;

int main()
{
    int m;
    int n;
    
    cin >>m>>n;
    
    while(m!=0){
        int c=0;
        for (int i=1; i<=m;i++){
            for (int j=1; j<i;j++){
                for (int k=1; k<j;k++){
                    if (i+j+k==n){
                      c+=1;
                    }
                }
            }
        }
        cout<< c<<endl;
        cin >>m>>n;
    }
    
   
    return 0;
}




Measured memory_bytes: 3104
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		StringBuilder results = new StringBuilder();
		while(sc.hasNext()){
			
			int number = Integer.parseInt(sc.next());
			if(number == 0){
				
				break;
			}
			
			List<Integer> input = new ArrayList<>(100);
			for(int i = 0;i<number;i++){
				
				int score = Integer.parseInt(sc.next());
				input.add(score);
				
			}
			
			double sd = computeStandardDeviation(input);
			
			results.append(String.format("%.8f\n", sd));
		}
		System.out.println(results);
		sc.close();
		
		
	}

	private static double computeStandardDeviation(List<Integer> input) {
		
		
		double variance = calculateVariance(input);
		return Math.sqrt(variance);
	}

	private static double calculateVariance(List<Integer> input) {
		
		int sum = calculateSum(input);
		
		double average = (double)sum / input.size();
		
		double square = 0;
		
		for(Integer number : input){
			
			square += Math.pow(number, 2);
		}
		return square / input.size() - Math.pow(average,2);
	}

	private static int calculateSum(List<Integer> input) {
		
		Integer sum = 0;
		
		for(Integer number : input){
			
			sum += number;
		}
		return sum;
	}

}



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

int n ;

long long a[100010], b[100010] ;

int main(){
	#define NAME "MULARR"
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	ios_base :: sync_with_stdio(false) ; 

	cin >> n ;

	for (int i = 1; i <= n; ++ i) cin >> a[i] >> b[i] ;

	long long total = 0;
	
	for (int i = n; i >= 1; -- i){
		a[i] += total ;
		total += (b[i] - (a[i] % b[i])) % b[i] ;
	}

	cout << total << endl ;

	return 0 ;
}

Measured memory_bytes: 1792
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val orders = mutableListOf<Int>()
    var maxWaitingTime = 0

    repeat(5) {
        val t = nextInt()
        if (t % 10 != 0) {
            val waitingTime = 10 - (t % 10)
            if (waitingTime > maxWaitingTime) maxWaitingTime = waitingTime
            orders.add(t + waitingTime)
        } else {
            orders.add(t)
        }
    }
    println(orders.sum() - maxWaitingTime)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33820
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]): Unit = {

    var continue = true
    while (continue) {
      val Array(m, f, r) = readLine().split(" ").map(_.toInt)
      if (m == -1 && f == -1 && r == -1) {
        continue = false
      } else {
        printGrade(m, f, r)
      }
    }
  }

  def printGrade(m: Int, f: Int, r: Int): Unit = {
    if (m == -1 || f == -1) {
      println("F")
    } else {
      m + f match {
        case x if x >= 80 => println("A")
        case x if x >= 65 => println("B")
        case x if x >= 50 => println("C")
        case x if x >= 30 => {
          if (r >= 50) println("C")
          else println("D")
        }
        case _ => println("F")
      }
    }
  }
}



Measured memory_bytes: 43712
#include<bits/stdc++.h>
using namespace std;
#include <climits>
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
	inline char gc()
	{
		static const int IN_LEN=1<<18|1;
		static char buf[IN_LEN],*s,*t;
		return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
	}
	template <typename _Tp> inline ios & operator >> (_Tp&x)
	{
		static char ch,sgn; ch = gc(), sgn = 0;
		for(;!isdigit(ch);ch=gc())
		{	
			if(ch==-1)return *this;sgn|=ch=='-';
		}
		for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
		sgn&&(x=-x); return *this;
	}
}io;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

/**问一个数的末尾有几个0，就是问分解因数时，最多能分解出几个10
10=2*5，也就是分解质因数后，问2与5中更少的
显然，在阶乘分解质因数后，5的个数是少于2的,所以只要求5的个数就可以了
求n的阶乘分解质因数中有多少个5，我们可以这样计算：一直让ans加上n/5，再让n/5，直到n为0为止**/
ll n,ans;
int main()
{
    scanf("%lld",&n);
    if(!(n&1))//最后一位是0
	{
        n>>=1;//右移一位 
        while(n)
		{
            ans += n/5;
            n /= 5;
        }
        printf("%lld\n",ans);
    }
    else
    	printf("0\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N,K,X,P,i;
  char S[100000];
  scanf("%d%d\n",&N,&K);
  scanf("%s",&S);
  
  X=0;
  for(i=0;i<=N-2;i++){
    if(S[i]==S[i+1]){
      X++;
    }
  }
  
  if(K*2+X>N-1){
    P=N-1;
  }else{
    P=K*2+X;
  }
  
  printf("%d",P);
  
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $h, $w);

if ($h == 1 or $w == 1) {
  echo '1';
  exit;
}

if (($h * $w) % 2 == 0) {
  echo ($h * $w) / 2;
} else {
  echo (($h * $w) + 1) / 2;
}

Measured memory_bytes: 4732
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

typedef long long ll;
const ll MAXN=1e5+5;

ll n,m,cir,spx,spy;
ll dis[MAXN],sum[MAXN],nx[MAXN];
ll sta[MAXN],top;
bool vis[MAXN];
vector<ll> E[MAXN];

void dfs(ll u,ll fa=0){
    vis[u]=1;
    dis[u]=dis[fa]+1;
    for(ll i=0;i<(ll)E[u].size();i++){
        ll v=E[u][i];
        if(v==fa) continue;
        if(vis[v]){
            cir=dis[u]-dis[v]+1;
            spx=u,spy=v;
            continue;
        }
        dfs(v,u);
    }
}

void solve(ll u,ll fa=0){
    vis[u]=1;
    for(ll i=0;i<(ll)E[u].size();i++){
        ll v=E[u][i];
        if(v==fa||vis[v]) continue;
        solve(v,u);
        nx[u]+=nx[v];
        sum[u]+=sum[v];
    }
}

int main(){
    //freopen("print.in","r",stdin);
    //freopen("print.out","w",stdout);

    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=m;i++){
        ll u,v;
        scanf("%lld%lld",&u,&v);
        E[u].push_back(v);
        E[v].push_back(u);
    }
    dis[0]=-1;
    dfs(1);
    ll tot=0,ans=0;
    for(ll i=1;i<=n;i++)
        tot+=(sum[i]=(dis[i]&1?-1:1));
    if(!cir){ if(tot) return puts("-1"),0;}
    else{
        if(cir&1){
            if(tot&1) return puts("-1"),0;
            sum[spx]-=tot/2;
            sum[spy]-=tot/2;
            ans+=abs(tot)/2;
        }
        else{
            if(tot) return puts("-1"),0;
            nx[spx]=1;
            nx[spy]=-1;
        }
    }
    memset(vis,0,sizeof vis);
    solve(1);
    for(ll i=1;i<=n;i++){
        if(!nx[i]) ans+=abs(sum[i]);
        else{
            if(nx[i]==1) sum[i]*=-1;
            sta[++top]=sum[i];
        }
    }
    sta[++top]=0;
    sort(sta+1,sta+top+1);
    ll k=sta[(top+1)/2];
    for(ll i=1;i<=top;i++)
        ans+=abs(sta[i]-k);
    printf("%lld\n",ans);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 15232
function Main(input) {
	var input = input.split(" ");
	var n = parseInt(input[0]);
	var k = parseInt(input[1]);

	var digit = 0;

	while(n > 0) {
		n = parseInt(n / k);
		digit++;
	}

	console.log(digit);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n;
	cin >> n;
	cout << (n-2)*180 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point {
public:
	int x, y;
	Point(int x, int y) :
			x(x), y(y) {
	}
	Point operator -(const Point p) const {
		return Point(x - p.x, y - p.y);
	}
};

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2) :
			p1(p1), p2(p2) {
	}
};

double dot(Point p1, Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}

double cross(Point p1, Point p2) {
	return p1.x * p2.y - p1.y * p2.x;
}

bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

int main() {

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; ++i) {
		int p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y;
		scanf("%d %d %d %d %d %d %d %d", &p0x, &p0y, &p1x, &p1y, &p2x, &p2y, &p3x, &p3y);
		Point p1(p0x, p0y);
		Point p2(p1x, p1y);
		Point p3(p2x, p2y);
		Point p4(p3x, p3y);
		Segment s1(p1, p2);
		Segment s2(p3, p4);

		if (isOrthogonal(s1, s2)) {
			cout << 1 << endl;
		} else if (isParallel(s1, s2)) {
			cout << 2 << endl;
		} else {
			cout << 0 << endl;
		}
	}
	return 0;
}

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

namespace TYC
{
	typedef long long ll;
	const int N = 1e5 + 5;

	int Siz[N], Id[N];
	ll D[N];
	unordered_map<ll, int> M;
	vector<int> E[N];

	template <typename T>
	inline T read()
	{
		T x = 0;
		int f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	ll dfs(const int u, const int d)
	{
		ll ans = d;
		for (int v : E[u])
			ans += dfs(v, d + 1);
		return ans;
	}

	void work()
	{
		int n = read<int>();
		for (int i = 1; i <= n; i++)
		{
			ll d = D[i] = read<ll>();
			Id[i] = i;
			M[d] = i;
			Siz[i] = 1;
		}
		sort(Id + 1, Id + 1 + n, [](const int a, const int b) { return D[a] < D[b]; });
		for (int i = n; i > 1; i--)
		{
			int v = Id[i];
			ll d = D[v] + 2 * Siz[v] - n;
			if (d >= D[v] || !M.count(d))
				return void(puts("-1"));
			int u = M[d];
			Siz[u] += Siz[v];
			E[u].push_back(v);
		}
		if (dfs(Id[1], 0) != D[Id[1]])
			puts("-1");
		else
			for (int i = 1; i <= n; i++)
				for (int j : E[i])
					printf("%d %d\n", i, j);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 14884
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    rep(i,n)std::cin >> a[i];
    std::vector<int> p(n);
    rep(i,n)p[a[i]-1]=i;
    int ans=0;
    int cnt=1;
    rep(i,n-1){
        if(p[i+1]>p[i])cnt++;
        else {
            ans=max(cnt,ans);
            cnt=1;
        }
    }
    
    ans=max(cnt,ans);
    std::cout << n-ans << std::endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<ctype.h>
int swapUpDown(int c) {
    if(islower(c)) {
        c=toupper(c);
    } else if(isupper(c)) {
        c=tolower(c);
    }
    return c;
}

int main() {
    int c;
    while((c = getchar()) != EOF) {
        putchar(swapUpDown(c)); 
    }
    return 0;
}


Measured memory_bytes: 2500
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<algorithm>
typedef long long LL;
#define MAXN 300010
int A, B, C = ~(1<<31), M = (1<<16)-1;
int myRand() {
  A = 36969 * (A & M) + (A >> 16);
  B = 18000 * (B & M) + (B >> 16);
  return (C & ((A << 16) + B)) % 1000000;
}
int N, zn, z[MAXN], f[MAXN], max[MAXN];
struct V {
	int x, y, z;
	bool operator < (const V &t) const {
		if(x != t.x) {
			return x < t.x;
		}
		if(y != t.y) {
			return y > t.y;
		}
		return z > t.z;
	}
}v[MAXN];
struct T {
	int id, x, y, z;
	bool operator < (const T &t) const {
		if(y != t.y) {
			return y < t.y;
		}
		if(x != t.x) {
			return x > t.x;
		}
		return z > t.z;
	}
}t[MAXN];
int query(int x) {
	int ans = 0;
	for(int i = x; i > 0; i -= i & -i) {
		ans = std::max(ans, max[i]);
	}
	return ans;
}
void update(int x, int v) {
	for(int i = x; i <= zn; i += i & -i) {
		max[i] = std::max(max[i], v);
	}
}
void clear(int x) {
	for(int i = x; i <= zn; i += i & -i) {
		max[i] = 0;
	}
}
void cdq(int x, int y) {
	if(x == y) {
		return ;
	}
	int mid = (x + y) >> 1;
	cdq(x, mid);
	for(int i = x; i <= y; i ++) {
		t[i].id = i;
		t[i].x = v[i].x, t[i].y = v[i].y, t[i].z = v[i].z;
	}
	std::sort(t + x, t + y + 1);
	for(int i = x; i <= y; i ++) {
		if(t[i].id <= mid) {
			update(t[i].z, f[t[i].id]);
		} else {
			f[t[i].id] = std::max(f[t[i].id], query(t[i].z - 1) + 1);
		}
	}
	for(int i = x; i <= y; i ++) {
		if(t[i].id <= mid) {
			clear(t[i].z);
		}
	}
	cdq(mid + 1, y);
}
int main() {
	//freopen("test.in", "rb", stdin);
	int m;
	while(scanf("%d%d%d%d", &N, &m, &A, &B), N + m > 0) {
		for(int i = 0; i < N; i ++) {
			scanf("%d%d%d", &v[i].x, &v[i].y, &v[i].z);
		}
		for(int i = 0; i < m; i ++) {
			v[N].x = myRand();
			v[N].y = myRand();
			v[N].z = myRand();
			++ N;
		}
		std::sort(v, v + N);
		for(int i = 0; i < N; i ++) {
			z[i] = v[i].z;
		}
		std::sort(z, z + N);
		zn = std::unique(z, z + N) - z;
		for(int i = 0; i < N; i ++) {
			v[i].z = std::lower_bound(z, z + zn, v[i].z) - z + 1;
		}
		for(int i = 0; i < N; i ++) {
			f[i] = 1;
		}
		cdq(0, N - 1);
		int ans = 0;
		for(int i = 0; i < N; i ++) {
			ans = std::max(ans, f[i]);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 12772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(k,a);
    k -= a;
    if (k <= 0){
        cout << ans << endl;
        return 0; 
    }
    k -= b;
    if (k <= 0){
        cout << ans << endl;
        return 0;
    }
    ans -= min(k,c);
    cout << ans << endl;
} 

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


def main():
    s = input()
    start_0_invalid = 0
    start_1_invalid = 0
    for i, si in enumerate(s):
        if i % 2 == 0:
            if si == '0':
                start_1_invalid += 1
            else:
                start_0_invalid += 1
        else:
            if si == '0':
                start_0_invalid += 1
            else:
                start_1_invalid += 1
    print(min([start_0_invalid, start_1_invalid]))


if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

template <typename T> bool next_combination(T first, T last, int k){
    T subset = first + k;
    if (first==last || first==subset || last==subset){
        return false;
    }
    T src = subset;
    while(first != src){
        src--;
        if(*src < *(last-1)){
            T dest = subset;
            while(*src >= *dest){
                dest++;
            }
            iter_swap(src, dest);
            rotate(src+1, dest+1, last);
            rotate(subset, subset+(last-dest)-1, last);
            return true;
        }
    }
    rotate(first, subset, last);
    return false;
}

int main() {
    int N; cin >> N;
    vector<ll> march(5,0);
    REP(i,N){
        string S; cin >> S;
        switch (S[0]){
            case 'M':
                march[0]++;
                break;
            case 'A':
                march[1]++;
                break;
            case 'R':
                march[2]++;
                break;
            case 'C':
                march[3]++;
                break;
            case 'H':
                march[4]++;
                break;
        }
    }
    ll ans = 0;
    vector<int> itr(5,0);
    REP(i,5){
        itr[i] = i;
    }
    do{
        ans += march[itr[0]]*march[itr[1]]*march[itr[2]];
    }while(next_combination(ALL(itr), 3));

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

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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

void solve() {

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

	set<vector<int>> s;

	int ans = 0;

	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {

		if (!s.insert({a, b, c}).ss) {
			cout << -1;
			return;
		}

		int a_half = a / 2, b_half = b / 2, c_half = c / 2;
		a = b_half + c_half;
		b = a_half + c_half;
		c = a_half + b_half;

		// cout << a << ' ' << b << ' ' << c << endl;
		ans++;
	}
	
	cout << ans;

}

int main() {

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

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}

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

using namespace std;

typedef long long ll;

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

int n;
ll k;
ll a[252521];
ll b[252521]; // for za-atu
ll bit[252521]; // for fenwick-tree

// fenwick tree max size is n
ll sum(int x){
  ll ret = 0;
  while(x>0){
    ret += bit[x];
    x -= x&-x;
  }
  return ret;
}
void add(int x,ll v){
  while(x<=n){
    bit[x] += v;
    x += x&-x;
  }
}

int main(){
  scanf("%d%lld",&n,&k);
  REP(i,n)scanf("%lld",a+i+1);
  REP(i,n)a[i+1] += a[i] - k;
  n++;

  // za-atu
  REP(i,n)b[i] = a[i];
  sort(b,b+n);
  REP(i,n)a[i] = lower_bound(b,b+n,a[i])-b+1;

  // fenwick tree
  ll ans = 0;
  REP(i,n){
    ans += sum(a[i]);
    add(a[i], 1);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 5376
h,w = map(int, input().split())

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

ans = [[0 for _ in range(w)] for _ in range(h)]


c = 0
cnt_c = 0
for i in range(h):
  for j in range(w):
    if i % 2 == 0:
      ans[i][j] = str(c+1)
      
    else:
      ans[i][(w-1)-j] = str(c+1)
      
    cnt_c += 1
    if cnt_c == a[c]:
      c += 1
      cnt_c = 0
    
for i in range(h):
  print(" ".join(ans[i]))
    

Measured memory_bytes: 3700
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;

int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<int> c(m), d(m);
    REP (i, m) scanf("%d%d", &c[i], &d[i]);
    // solve
    vector<int> imos(n + 2);
    REP (i, m) {
        imos[c[i]] += 1;
        imos[d[i]] -= 1;
    }
    int result = n + 1;
    REP (i, n + 1) {
        imos[i + 1] += imos[i];
        result += 2 * bool(imos[i + 1]);
    }
    // output
    printf("%d\n", result);
    return 0;
}

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

using namespace std;

int main()
{
	int n, q;
	cin>>n>>q;
	string s;
	cin>>s;
	vector<char> t, d;
	for(int i = 0; i < q; i++){
		char tt, td;
		cin>>tt>>td;
		t.push_back(tt);
		d.push_back(td);
	}
	int ans = n;
	int l = -1, r = n;
	while(r - l > 1){
		int mid = (r + l) / 2;
		bool fl = false;
		int pos = mid;
		for(int i = 0; i < q; i++){
			if( 0 <= pos && pos < n && t[i] == s[pos]){
				if(d[i] == 'L')
                    pos--;
				else pos++;
			}
			if( pos == -1 )
                fl = true;
		}
		if(fl){
			l = mid;
		}
		else{
			r = mid;
		}
	}
	ans -= r;
	l = -1, r = n;
	while(r - l > 1){
		int mid = (r + l) / 2;
		bool fl = false;
		int pos = mid;
		for(int i = 0; i < q; i++){
			if( 0 <= pos && pos < n && t[i] == s[pos]){
				if(d[i] == 'L')
                    pos--;
				else
                    pos++;
			}
			if(pos == n)
                fl = true;
		}
		if(fl){
			r = mid;
		}
		else{
			l = mid;
		}
	}
	ans -= (n - r);
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    int N = 0;
    int n = 0;
    int c = 0;
    std::cin >> N;
    while(std::cin >> n){
        bool f = false;
        for(int i=2; i<=sqrt(n); i++){
            if(n%i==0){
                f = true;
                break;
            }
        
        }
        
        if(!f){
            c++;
        }
    }
    std::cout << c << std::endl;
    return 0;
}


Measured memory_bytes: 3100
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7

ans = 0
for i in range(n):
    c_0 = 0
    c_1 = 0
    for j in range(n):
        if i == j:
            pass
        elif a[i] > a[j]:
            if i < j:
                c_1 += 1
            else:
                c_0 += 1      
    ans += c_1*k*(k+1)//2 + c_0*k*(k-1)//2
    ans %= mod
print(ans)

Measured memory_bytes: 9256
#include <iostream>
using namespace std;
typedef long long ll;
ll MOD = 1000000007LL;
ll inv(ll K) {
  ll A = MOD - 2;
  ll ret = 1;
  ll D = K;
  while (A > 0) {
    if (A % 2 == 1) {
      ret = (ret * D) % MOD;
    }
    D = (D * D) % MOD;
    A /= 2;
  }
  return ret;
}
ll FC[200005];
ll IFC[200005];
ll initFC(int N) {
  FC[0] = 1;
  for (ll i=1; i<=N; i++) {
    FC[i] = (FC[i-1] * i) % MOD;
  }
  IFC[N] = inv(FC[N]);
  for (ll i=N; i>=0; i--) {
    IFC[i-1] = (IFC[i] * i) % MOD;
  }
}

ll modSum(ll& N, ll B) {
  N = (N + B % MOD + MOD) % MOD;
}
int main() {
  ios::sync_with_stdio(false);
  ll N, A, B;
  cin >> N >> A >> B;
  ll ret = 1;
  ll n = N;
  ll m = 2;
  while (n > 0) {
    if (n % 2) ret = (ret * m) % MOD;
    n /= 2;
    m = (m * m) % MOD;
  }
  modSum(ret, -1);
  initFC(200001);
  ll AA = 1;
  for (ll i=0; i<A; i++) {
    AA = (AA * (N-i)) % MOD;
  }
  AA = (AA * IFC[A]) % MOD;
  modSum(ret, -AA);
  ll BB = 1;
  for (ll i=0; i<B; i++) {
    BB = (BB * (N-i)) % MOD;
  }
  BB = (BB * IFC[B]) % MOD;
  modSum(ret, -BB);
  cout << ret << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long a,b,c,i,j,k[2000009],ans=99999999999,f[2000009];
int main(){
	cin>>a;
	for(i=1;i<=a;i++){
		cin>>k[i];
		f[i]=k[i];
		k[i]+=k[i-1];
	}
//	for(i=1;i<=a;i++){
//		cout<<k[i]<<' ';
//	}cout<<endl;
	for(i=1;i<a;i++){
//		cout<<k[a]<<' '<<k[i]<<endl;
//		cout<<abs(k[a]-k[i]-k[i])<<endl;
	//	ans=min(ans,int(abs(k[i]-k[a]+k[i])));
	    long long t,l,r;
	    l=k[i];
	    r=k[a]-k[i];
	    if (l<r){
	    	ans=min(ans,r-l);
	    }else{
	    	ans=min(ans,l-r);
	    }
	}
	cout<<ans<<endl;
	/*ans=999999999
	for(i=1;i<a;i++){
		int s1=0,s2=0;
		for(j=1;j<=i;j++){
			s1+=f[i];
		}
		for(j=i+1;j<=a;j++){
			s2+=f[i];
		}
		ans
	}*/
} 

Measured memory_bytes: 5888
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    if (A[i] + 1 == A[i+1]):
        ans += C[A[i]-1]
ans += sum(B)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int len[5] = {0};
    int result = 0;
    int minRest = INF;
    rep(i, 5) {
        cin >> len[i];

        int mod = len[i] % 10;
        if (mod == 0) {
            result += len[i];
        } else {
            result += ((len[i] / 10) * 10) + 10;
            minRest = min(minRest, mod);
        }
    }

    if (minRest == INF) {
        cout << result << endl;
    } else {
        cout << (result - 10 + minRest) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  vector <vi> a(3, vi(3));
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  vi b(n);
  rep(i, n) cin >> b[i];

  rep(i, n){
    rep(j, 3){
      rep(k, 3){
        if (a[j][k] == b[i]) a[j][k] = -1;
      }
    }
  }

  string ans = "No";
  if((a[0][0] == -1 and a[0][1] == -1 and a[0][2] == -1) or 
     (a[1][0] == -1 and a[1][1] == -1 and a[1][2] == -1) or
     (a[2][0] == -1 and a[2][1] == -1 and a[2][2] == -1) or
     (a[0][0] == -1 and a[1][0] == -1 and a[2][0] == -1) or
     (a[0][1] == -1 and a[1][1] == -1 and a[2][1] == -1) or
     (a[0][2] == -1 and a[1][2] == -1 and a[2][2] == -1) or
     (a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1) or
     (a[2][0] == -1 and a[1][1] == -1 and a[0][2] == -1)
    ) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	char t[21];
	char flug=0;
	cin>>t;
	for(int i=20;i>=0;i--){
		if(flug==1){
			cout<<t[i];
		}
		if(t[i]=='\0'){
			flug=1;
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1132
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int64 gcd(int64 a,int64 b){
  int64 r=a%b;
  while(r>0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int64 t;
  scanf("%lld",&t);
  int i;
  for(i=1;i<n;i++){
    int64 s;
    scanf("%lld",&s);
    t=t/gcd(t,s)*s;
  }
  printf("%lld\n",t);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int n,a[100000],i,c=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];	
	}
	for(i=1;i<=n;i++){
		if(a[i]==i){
		int t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			c++;		
		}
	if(a[i]==i&&i==n){
		int t=a[i];
			a[i]=a[i-1];
			a[i-1]=t;
			c++;		
		}	
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            int output = 1;
            int cnt = int.Parse(Console.ReadLine());
            int[] input=  Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int total = 0;
            foreach (var pint in input)
            {
                total = total + pint;                
            }
            
            decimal ave = (decimal)total / (decimal)cnt;
            int num1 = (int)Math.Ceiling(ave);
            int num2 = (int)Math.Floor(ave);

            int total1 = 0;
            int total2 = 0;

            for (int idx = 0; idx < input.Length; idx++)
            {
                total1 = total1 + (int)Math.Pow((input[idx] - num1),2);
                total2 = total2 + (int)Math.Pow((input[idx] - num2), 2);
            }

            if (total1 > total2)
            {

                Console.WriteLine(total2.ToString());
            }
            else
            {

                Console.WriteLine(total1.ToString());
            }
            
        }
    }
}




Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = INF;

int main (){
     
     vector<int>a(5);
     for(int i=0;i<5;i++){
     cin >> a.at(i);
     }
     
     for(int i=0;i<5;i++){
     if(a.at(i) == 0 )cout << i+1 << endl;
     }
     
     return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
 
using namespace std;
 
const int MAX = 100;
int N;
int x[MAX];
int y[MAX];
int h[MAX];
 
int check(int cx,int cy){
    int H = -1;
 
    for(int i = 0;i < N;i++){
        if(h[i] == 0) continue;
        
        if(H == -1)H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
        if(h[i] + abs(x[i] - cx) + abs(y[i] - cy) != H)return -1;
        
    }

    for(int i = 0;i < N;i++){
        if(h[i] != 0)continue;
        
        if(H == -1)return -1;
        if(abs(x[i] - cx) + abs(y[i] - cy) < H)return -1;
    }
    return H;
}
 
int main(){
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> x[i] >> y[i] >> h[i];
    }
 
    for(int i = 0;i <= 100;i++){
        for(int j = 0;j <= 100;j++){
 
            int H = check(i,j);
            if(H != -1){
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
 
        }
    }
 
    return 0;
}

Measured memory_bytes: 256