akhauriyash/Code-Regression huggingface dataset:
A,B=map(int,input().split())
count=0
if A==0 or B==0:
	print("Zero")
	exit()
else:
	if A<0 and B>0:
		print("Zero")
	elif A>0:
		print("Positive")
	elif A<0 and B<0:
		if (abs(B)-abs(A))%2==0:
			print("Negative")
		else:
			print("Positive")

Measured memory_bytes: 3060
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  string s,t;
  cin>>s>>t;
  int cnt=0;
  rep(i,s.size()){
    if (s[i] == t[i]) cnt += 1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 504
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N, T, t[212345];
LL ans, to;

int main()
{
	in >> N >> T;
	rep(i, N) { in >> t[i]; }

	rep(i, N)
	{
		if (to < t[i])
		{
			ans += T;
			to = t[i] + T;
		}
		else
		{
			ans -= to;
			to = t[i] + T;
			ans += to;
		}
	}

	out << ans << std::endl;
	return 0;
}

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

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

int main(int argc, char *argv[])
{
    int n, ni, di, w, h;
    while (cin >> n, n) {
        vector<int> x(n, 0);
        vector<int> y(n, 0);
        for (int i = 1; i < n; ++i) {
            cin >> ni >> di;
            x[i] = x[ni] + dx[di];
            y[i] = y[ni] + dy[di];
        }
        w = *max_element(x.begin(), x.end()) - *min_element(x.begin(), x.end());
        h = *max_element(y.begin(), y.end()) - *min_element(y.begin(), y.end());
        cout << ++w << ' ' << ++h << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
# https://atcoder.jp/contests/abc056/tasks/abc056_b

W, a, b = map(int, input().split())

if a < b and a+W < b:
    ans = abs(a+W - b)
elif b < a and b+W < a:
    ans = abs(b+W - a)
else:
    ans = 0

print(ans)

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

int main() {
	char S[4];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> p>>T>>Q;
	cout << "A" << T[0] << "C";
	
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	REP(i, s.size()) {
		if (s[i] == 'R') {
			cnt++;
			if (cnt == 4) {
				ans++;
				cnt = 0;
			}
		}
		else {
			cnt--;
			if (cnt == -4)cnt = 0;
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 3232
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# from numpy import array, sum

N, A, B = map(int, input().split())

h_li = []

for i in range(N):
	h_li.append(int(input()))

def all_beatable_check(k):
	# All enemy get B damage every time
	h_damaged = [h - B*k for h in h_li]
	# print(h_damaged)
	# A-B damage will be additionally given to enemies s.t. HP > 0
	ex_dmg = A - B
	h_ex_needed = [(h+ex_dmg-1) // ex_dmg if h > 0 else 0 for h in h_damaged]
	# print(h_ex_needed)
	# how many A-B damage is needed to beat all enemies
	hits_needed = sum(h_ex_needed)
	if hits_needed > k:
		return False
	else:
		return True

MIN_K = 0         # impossible
MAX_K = max(h_li) # possible

while MAX_K - MIN_K > 1:
	# print(f"{MIN_K}-{MAX_K} {MIN_K + (MAX_K - MIN_K) // 2}")
	k = MIN_K + (MAX_K - MIN_K) // 2
	res = all_beatable_check(k)
	if res is True:
		MAX_K = k
	elif res is False:
		MIN_K = k

print(MAX_K)

Measured memory_bytes: 14932
#include<stdio.h>
#define MAX 101
void dfs (int);
void visit(int,int);
int ar[MAX][MAX],time=0,color[MAX],d[MAX][2];
int main(){
int n,i,j,m,l,k;
for(i=0;i<MAX;i++){
  for(j=0;j<MAX;j++){
    ar[i][j]=0;
  } 
 }



 scanf("%d",&n);

 for(i=1;i<=n;i++){
   scanf("%d",&m);
   scanf("%d",&l);
   for(j=1;j<=l;j++){	
     scanf("%d",&k);
     ar[i][k]=1;
   }
 }
 dfs(n);
 for(i=1;i<=n;i++){
   printf("%d %d %d\n",i,d[i][0],d[i][1]);
 }

 return 0;
}
void dfs(int u){
  int i;
  for(i=1;i<=u;i++){
    color[i]=0;
  }
  time=0;
  for(i=1;i<=u;i++){
    if(color[i]==0){
      visit(i,u);
    }
  }
}
void visit(int u,int p){
  int i;
  color[u]=1;//1はGRAY
  d[u][0]=++time;
  for(i=1;i<=p;i++){
    if(color[i]==0 && ar[u][i]==1){
      visit(i,p);
    }
  }
    color[u]=2;
    d[u][1]=++time;


}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

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

int main() {

    int H, W;
    cin >> H >> W;

    vector<vector<char>> s(H, vector<char>(W));

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

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            
            bool can = false;

            if(s[i][j] == '#') {

                for (int k = 0; k < 4; k++) {
                    if (i+dx[k] >= 0 && i+dx[k] < H && j+dy[k] >= 0 && j+dy[k] < W) {
                        
                        if(s[i+dx[k]][j+dy[k]] == '#') {
                            can = true;
                        }
                    }
                }
                if(!(can)) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    
    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,h[maxn],cnt;
struct edge{
	int v,p;
}e[maxn<<1];
int c[maxn];
inline void add(int a,int b){
	e[++cnt].p=h[a];
	e[cnt].v=b;
	h[a]=cnt;
	e[++cnt].p=h[b];
	e[cnt].v=a;
	h[b]=cnt;
}
bool cmp(int a,int b){return a>b;}
int ans[maxn],dfn;
void dfs(int u,int fa){
	ans[u]=c[++dfn];
	for(int i=h[u];i;i=e[i].p){
		int v=e[i].v;
		if(v==fa)continue;
		dfs(v,u);
	}
}
int tot=0;
void dfs2(int u,int fa){
	for(int i=h[u];i;i=e[i].p){
		int v=e[i].v;
		if(v==fa)continue;
		tot+=min(ans[u],ans[v]);
		dfs2(v,u);
	}
}
int main(){
	n=read();
	for(int i=1,a,b;i<n;i++){
		a=read(),b=read();
		add(a,b);
	}
	for(int i=1;i<=n;i++)c[i]=read();
	sort(c+1,c+1+n,cmp);
	dfs(1,0);
	dfs2(1,0);
	printf("%d\n",tot);
	for(int i=1;i<=n;i++)
	printf("%d ",ans[i]);
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int** a = new int* [n];
    for (int i = 0; i < n; i++) {
        a[i] = new int[m];
    }
    int* b = new int[m];

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

    int* result = new int[n];

    for (int i = 0; i < n; i++) {
        result[i] = 0;
        for (int j = 0; j < m; j++)
            result[i] += b[j] * a[i][j];
        cout << result[i] << endl;
    }



    delete[] b;
    for (int i = 0; i < n; i++) {
        delete[] a[i];
    }
    delete[] a;
    delete[] result;
    return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;

int main() {
  int r;
  cin >> r;
  cout << 2 * r * 3.1415926535 << endl;
}

Measured memory_bytes: 3788
//package main;

import java.io.*;
import java.util.*;
import java.math.*;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;
    
    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    long mod = 998244353;
    StringBuilder res = new StringBuilder(1000005);
    void run() throws Exception {
        int n = ni();
        long[] a = new long[n];
        long ans = 0;
        for(int i = 0; i < n; i++) {
            a[i] = nl();
        }
        for(int i = 1; i < n; i++) {
            long diff = a[i] - a[i - 1];
            if(diff < 0) {
                ans += -diff;
                a[i] += -diff;
            }
        }
        System.out.println(ans);
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens())
            stk = new StringTokenizer(br.readLine(), " ");
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }
    
    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }
    
    //Some Misc methods
    int get(int l, int r, int[] a) {
        return l == 0 ? a[r] : a[r] - a[l - 1];
    }
    
    void shuffle(long[] a) {
        Random r = new Random();
        for(int i = 0; i < a.length; i++) {
            int idx = r.nextInt(a.length);
            long temp = a[i];
            a[i] = a[idx];
            a[idx] = temp;
        }
    }
    
    void reverse(int[] a) {
        for(int i = 0, j = a.length - 1; i < j; i++, j--) {
            int temp = a[i];
            a[i] = a[j];
            a[j] = temp;
        }
    }
}

Measured memory_bytes: 57040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool dp[100009];
int main()
{
    int i,j,k;
    int n;
    cin>>n>>k;
    int arr[n+1];
    memset(dp,0,sizeof dp);
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=0;i<=k;i++)
        for(j=0;j<n;j++)
            if(i>=arr[j] && !dp[i-arr[j]])
                dp[i]=1;
    puts(!dp[k]?"Second":"First");
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

if a.count(0)>0:
    print(0)
    exit()

for i in range(n):
    ans *= a[i]

    if ans >10**18:
        print(-1)
        exit()


print(ans)


Measured memory_bytes: 83236
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();

        if(n % 10 == 7 ||
           n % 100 - n % 10 == 70 ||
           n % 1000 - n % 100 == 700) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        scan.close();
        return;
    }
}

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


int main() {
    string S,T;
    int count,ans;
    cin >> S >> T;
    ans=S.size();
    for(int i=0;i<S.size()-T.size()+1;i++){
        count=0;
        for(int j=0;j<T.size();j++){
            if(T.at(j)!=S.at(i+j)){
                count++;
            }
        }
        ans=min(count,ans);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3628
/* AtCoder Beginner Contest abc130
 * Problem B
 * Au: SJoshua
 */
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main(void) {
	int n, x;
	cin >> n >> x;
	int ans = 0 <= x;
	int cur = 0;
	while (n--) {
		int t;
		cin >> t;
		cur += t;
		ans += cur <= x;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline
    #define re register
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
#define N 100005
char s[N];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	bool flag1=1,flag2=1;
	for(re int i=1;i<=len;i+=2){
		if(s[i]=='R'||s[i]=='U'||s[i]=='D') continue;
		flag1=0;
	}
	for(re int i=2;i<=len;i+=2){
		if(s[i]=='L'||s[i]=='U'||s[i]=='D') continue;
		flag2=0;
	}
	if(flag1&&flag2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
from collections import*

def main():
	v, e, *L = map(int, open(0).read().split())
	g = [[] for _ in range(v)]
	deg = [0] * v
	for s, t in zip(*[iter(L)] * 2):
		g[s - 1].append(t - 1)
		deg[t - 1] += 1
	q = deque()
	for i, d in enumerate(deg):
		if not d:
			q.append(i)
	ans = [0] * v
	while q:
		c = q.popleft()
		for n in g[c]:
			deg[n] -= 1
			if not deg[n]:
				q.append(n)
				ans[n] = c + 1
	print("\n".join(map(str, ans)))

if __name__ == "__main__":
	main()

Measured memory_bytes: 37892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/

lint sgm(lint n) {
	//0からの総和を返す
	return n  * (n + 1)/2;
}

int main() {
	unsigned long long int N;
	cin >> N;
	if (N % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	N -= N % 10;
	unsigned long long int sum = 0;
	unsigned long long int ans = 0;
	unsigned long long int cnt = 10;
	while (1) {
		sum = N / cnt;
		ans += sum;
		cnt *= 5;
		if (sum == 0) {
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void XXX(vector<int> &vec,int x,int y){
    for (int i = x; i < y; i++)
    {
        vec.at(i) = 1;
    }
}
int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    int R = 0;
    vector<int> Alice = vector<int>(101,0);
    vector<int> Bob = vector<int>(101,0);

    XXX(Alice,A,B);
    XXX(Bob,C,D);

    for (int i = 0; i < 101; i++)
    {
        if(Alice.at(i)==1&&Bob.at(i)==1){
            R++;
        }
    }
    
    cout << R << endl;

}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: usize,
        y: usize,
    };

    for tsuru in (0..=x) {
        let kame = x - tsuru;
        if tsuru * 2 + kame * 4 == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2164
#include <iostream>

using namespace std;

int main() {
    int width, height, x, y, radius;
    
    cin >> width >> height >> x >> y >> radius ;
    if(radius <= x && (width - radius) >= x && radius <= y && (height - radius) >= y) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  int sum = (m > 1 ? m * (m - 1) / 2 : 0) + (n > 1 ? n * (n - 1) / 2 : 0);
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define el "\n"
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define M 1000000007
#define all(v) v.begin(), v.end()

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<max(max(a*b,a-b),a+b);        
    return 0;
}

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

int main()
{
    int tate=1,yoko=1;
    while(1){
        cin>>tate>>yoko;
        if(tate==0 && yoko==0)break;
        for(int i=0;i<tate;i++) {
            for(int j=0;j<yoko;j++) {
                if(i==0 || i==tate-1) printf("#");
                else if(j==0 || j==yoko-1) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using ldb = long double;
using pa = pair < int, int >;
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;
#define pb push_back
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 2000 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;
int add(int x, int y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
int multiply(int a,int b){
    a %= MOD;
    b %= MOD;
    return (a*b)%MOD;
}
int n;
int dp[N];
int dfs(int s){
	if(s == 0){
		return 1;
	}
	if(s < 0){
		return 0;
	}
	if(dp[s] != -1){
		return dp[s];
	}
	int &ans = dp[s];
	ans = 0;
	for(int i = 3;i <= s;i++){
		if(s - i >= 0){
			ans = add(ans,dfs(s-i));
		}
	}
	return ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	cin >> n;
 	memset(dp,-1,sizeof(dp));
 	if(n <= 2){
 		cout << 0 << "\n";
 		return 0;
 	}   
 	cout << dfs(n) << "\n";
    return 0;
}



Measured memory_bytes: 3640
def f():
    h, w, n = map(int, input().split())
    md = 10 ** 9 + 7
    k = [list(map(int, input().split())) for _ in range(n)] + [[h, w]]

    # 壁をマンハッタン距離順に
    k.sort(key=lambda x: x[0] + x[1])

    # 階乗と逆元とコンビネーションを事前準備
    fct = [1] * (h + w + 1)
    re_fct = [1] * (h + w + 1)
    fct_i = 1
    for i in range(1, h + w + 1):
        fct_i = fct_i * i % md
        fct[i] = fct_i
    # fct_i**(md-2)が逆元re_i
    re_i = 1
    p = md - 2
    while p:
        if p & 1:
            re_i = re_i * fct_i % md
        p >>= 1
        fct_i = fct_i ** 2 % md
    for i in range(h + w, 1, -1):
        re_fct[i] = re_i
        re_i = re_i * i % md
    cmb = lambda a, b: fct[a] * re_fct[b] * re_fct[a - b] % md

    # こっから本体
    dp = [0] * (n + 1)
    for i, [r, c] in enumerate(k):
        dpi = cmb(r + c - 2, r - 1) % md
        for j in range(i):
            dr, dc = r - k[j][0], c - k[j][1]
            if dr >= 0 and dc >= 0:
                dpi = (dpi - dp[j] * cmb(dr + dc, dr)) % md
        dp[i] = dpi
    print(dp[-1])


f()


Measured memory_bytes: 50928
#include <stdio.h>

int main() {
  int a, b, c, d, e, k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);
  if (e - a <= k) {
    printf("Yay!\n");
  }else {
    printf(":(\n");
  }
  return 0;
}


Measured memory_bytes: 128
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

x,y = iim()
if y>=x:
    if x*y>=0:
        ans = y-x
    else:
        ans = abs(x+y)+1
else:
    if y == 0:
        ans = x+1
    elif x*y>0:
        ans = x-y+2
    else:
        ans = abs(y+x)+1
print(ans)


Measured memory_bytes: 9176
gets.to_i.times do
  n, k = gets.split.map(&:to_i)
  x = gets.split.map(&:to_i).sort
  diff = x.each_cons(2).map{|a, b| b - a}.sort!
  p x[-1] - x[0] - diff.last(k.pred).inject(0,:+)
end

Measured memory_bytes: 19880
#include <iostream>
#include <algorithm>

using namespace std;

int main () {

    int n;
    string s;

    cin >> n >> s;

    int res = 0;

    int mx = 0;

    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'I') ++res;
        else --res;
        mx = max(res, mx);
    }

    cout << mx;



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int Ans[4]={1,7,9,4};
	int i,f,N;
	
	for(i=0;i<4;i++){
	scanf("%d",&N);
		for(f=0;f<4;f++){
			if(Ans[f]==N){
			Ans[f]=99;
			
			}
		
		}
	}
	
	if(Ans[0]==99&&Ans[1]==99&&Ans[2]==99&&Ans[3]==99){
	printf("YES\n");
	}else{
	printf("NO\n");
	}
	
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll n, a, b;
    cin >> n >> a >> b;

    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    ll ans = 0;
    for(int i = 1; i < n; i++){
        ll d = v[i] - v[i-1];
        if( a * d > b ) ans += b;
        else ans += a*d;
    }
    cout << ans << endl;

}

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

#define PI acos(-1.0)
#define pi 3.14159265359
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define el "\n"

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

    int a[n+2];
    int ans[n+2]={0};

    for(int i=2; i<=n; i++) {
        cin >> a[i];
        ans[a[i]]++;
    }

    for(int i=1; i<=n; i++) cout << ans[i] << el;

    return 0;
}



Measured memory_bytes: 5212
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll K, N;
vector<long double> p(200010);
long double ans = 0, tmp = 0;

int main() {
    cin >> N >> K;
    rep(i, N) cin >> p[i];

    rep(i, K) {
        //まず最初にぶっこむ
        ans += (1 + p[i]) / 2;
        tmp += (1 + p[i]) / 2;
        //cout << (1 + p[i]) / 2 << endl;
    }

    //double tmp = ans;
    REP(i, K, N) {
        tmp -= (1 + p[i - K]) / 2;
        tmp += (1 + p[i]) / 2;
        ans = max(ans, tmp);
        //cout << ans << endl;
    }

    cout << fixed << setprecision(6) << ans << endl;
}

Measured memory_bytes: 6288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> dp(n + 1, 0);

  dp[0] = 1000;

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

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int rudi;
int n,k;
int l;
int a[1000005];
int mini[200005];
int sum;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(a[i+1]!=a[i]) rudi++;
    }
    if(rudi<=k){
        cout<<0;
        return 0;
    }
    if(rudi>k){
        for(int i=1;i<=n;i++){
             mini[a[i]]++;
        } 
    }
        sort(mini+1,mini+a[n]+1);    
        for(int i=1;i<=n;i++){
            if(mini[i]!=0){
                l=i;
                break;
            }
        }    
        for(int j=1;j<=rudi-k;j++){ 
        sum+=mini[l+j-1];
    }
    cout<<sum;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  char s[200100];
  cin >> s;

  cout << strrchr(s, 'Z') - strchr(s, 'A')  + 1 << endl;


  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val red = br.readInt()
    var green = br.readInt()
    var blue = br.readInt()
    var k = br.readInt()
    while (red >= green){
        green *= 2
        k--
    }
    while (green >= blue){
        blue *= 2
        k--
    }
    if(k >= 0){
        print("Yes")
    } else {
        print("No")
    }
}


private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 34188
n=int(input())
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
c=0
for i in range(n):
  c1=0
  for j in range(i+1):
    c1+=l1[j]
  for j in range(i,n):
    c1+=l2[j]
  if c1>c:
    c=c1
print(c)
        

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

int main() {
    string str;

    vector<string> button{" ",
            "',.!?",
            "abcABC",
            "defDEF",
            "ghiGHI",
            "jklJKL",
            "mnoMNO",
            "pqrsPQRS",
            "tuvTUV",
            "wxyzWXYZ"};

    while (getline(cin,str)) {
        if (str == "") {
            cout << endl;
            continue;
        }
        string seq;
        vector<int> count;
        seq += str[0];
        count.push_back(1);
        for (int i = 1; i < str.size(); i++) {
            if (seq[seq.size()-1] == str[i]) {
                count[count.size()-1]++;
            } else {
                if (str[i] == '0') i++;
                seq += str[i];
                count.push_back(1);
            }
        }

        string ret;
        for (int i = 0; i < seq.size(); i++) {
            int b = seq[i] - '0';
            int c = (count[i]-1) % (int)(button[b].size());
            if (b == 0)
                for (int j = 0; j < count[i]; j++) ret += ' ';
            else
                ret += button[b][c];
        }
        cout << ret << endl;
    }

    return 0;
}

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

#define MAX 100005
#define NIL -1

struct Node{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL)       cout << "root";
    else if(T[u].l == NIL)  cout << "leaf";
    else                    cout << "internal node";
    cout << ", ";

    cout << "[";

    int c;
    for(int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p){
    D[u] = p;
    if(T[u].l != NIL)   rec(T[u].l, p+1);
    if(T[u].r != NIL)   rec(T[u].r, p);
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for(int i = 0; i < n; i++){
        int v, d, c, l;
        cin >> v >> d;
        for(int j = 0; j < d; j++){
            cin >> c;
            if(j == 0){
                T[v].l = c;
            }else{
                T[l].r = c;
            }
            l = c;
            T[c].p = v;
        }
    }

    int r;
    for(int i = 0; i < n; i++){
        if(T[i].p == NIL)   r = i;
    }

    rec(r, 0);

    for(int i = 0; i < n; i++){
        print(i);
    }

    return 0;
}



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

int main(void){
    int N;
    scanf("%d",&N);
    long long shun[N];
    for(int i=0;i<N;i++){
        scanf("%lld",&shun[i]);
    }
    long long sum=0;
    long long max=shun[0];
    for(int i=0;i<N;i++){
        if(shun[i]>=max){
            sum+=0;
            max=shun[i];
        }else{
            sum+=max-shun[i];
        }
    }
    printf("%lld",sum);
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  string a;
  cin>>a;
  ll b=0;
  ll c=0;
  for(ll i=0;i<4;i++){
    if(a.at(i)=='+'){
      b+=1;
    }
    else{
      c+=1;
    }
  }
  cout<<b-c<<endl;
    
  return 0;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main(){
	int n;
	int min,max;
	int x;

	min = 10000;
	max = -1;
	
	cin >> n;

	for(int i = 0;i < n;i++){
		cin >> x;

		if(x > max){
			max = x;
		}

		if(x < min){
			min = x;
		}
	}

	cout << max-min << endl;

	return 0;
}


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

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

int main() {
    int N, K;
    string s;
    cin >> N >> K >> s;

    vector<int> Nums;
    int now = 1;
    int cnt = 0;
    rep(i, N){
        if(s[i] == (char)('0' + now)) cnt++;
        else {
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) Nums.push_back(cnt);

    if(Nums.size() % 2 == 0) Nums.push_back(0);

    int Add = 2 * K + 1;
    
    int ans = 0;

    int left = 0;
    int right = 0;
    int tmp = 0;
    
    for (int i = 0; i < Nums.size(); i += 2) {
        int Nextleft = i;
        int Nextright = min(i + Add, (int)Nums.size());

        while (Nextleft > left) {
            tmp -= Nums[left];
            left++;
        } 
        
        while (Nextright > right) {
            tmp += Nums[right];
            right++;
        }
        ans = max(tmp, ans);
    }

    cout << ans << endl;
}

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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;
const int INF = 1000000000;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int heights[n];
    rep(i,n) cin>>heights[i];
    int dp[n];
    rep(i,n) dp[i] = 1e9;
    dp[0] = 0;
    rep(i,n){
    	for(int j = i+1;j<=i+2;j++)
    	{
    		if(j < n)
    			dp[j] = min(dp[j],dp[i] + abs(heights[i] - heights[j]));
    	}

    }
    //rep(i,n+1) cout<<dp[i]<<endl;
    cout<<dp[n-1]<<endl;

    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=1005;

int n, m, r, ans;
int E[maxn][maxn], data[maxn];

int main()
{
    int n;
    while(~scanf("%d%d%d", &n, &m, &r)){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                E[i][j]=inf;
                if(i==j)E[i][j]=0;
            }
        }
        for(int i=0;i<r;i++){
            scanf("%d", &data[i]);
        }
        int u, v, cost;
        for(int i=0;i<m;i++){
            scanf("%d%d%d", &u, &v, &cost);
            E[u][v]=E[v][u]=cost;
        }
        for(int k=1;k<=n;k++){
            for( int i=1;i<=n;i++){
                for(int j=1;j<=n;j++){
                    E[i][j]=min(E[i][j], E[i][k]+E[k][j]);
                }
            }
        }
        sort(data, data+r);
        ans=0;
        for(int i=1;i<r;i++){
            ans+=E[data[i-1]][data[i]];
        }
        while(next_permutation(data, data+r)){
            int tans=0;
            for(int i=1;i<r;i++){
                tans+=E[data[i-1]][data[i]];
            }
            ans=min(ans, tans);
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        System.out.println(lcm(A, B));
    }


    static long gcd(long a, long b) {
        long max = Math.max(a, b);
        long min = Math.min(a, b);

        long r = max % min;
        if (r == 0) {
            return min;
        } else {
            return gcd(min, r);
        }
    }

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


Measured memory_bytes: 22736
#include <iostream>

using namespace std;

int main() {
    int n, r = 0, b = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') ++r;
        if (s[i] == 'B') ++b;
    }
    if (r > b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end(), greater<char>());
	int ans = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (i < s.size() / 2) {
			if ('g' == s[i]) ++ans;
		}
		else {
			if ('p' == s[i]) --ans;
		}
	}
	cout << ans;
}

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

int n;

int main()
{
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; i++)
    {
        if (i == n - 1)
            cout << a[i] << endl;
        else
            cout << a[i] << " ";
    }
}


Measured memory_bytes: 3108
import kotlin.math.min

fun main() = abc167f()

@OptIn(ExperimentalStdlibApi::class)
fun abc167f() {
    data class Bracket(val lowestHeight: Int, val transition: Int)

    val n = readLine()!!.toInt()
    val brackets = (1..n).map {
        val s = readLine()!!
        var currHeight = 0
        var lowestHeight = 0
        for (c in s) {
            when (c) {
                '(' -> currHeight++
                else -> currHeight--
            }
            lowestHeight = min(lowestHeight, currHeight)
        }
        Bracket(lowestHeight, currHeight)
    }

    var currHeight = 0
    val (positives, negatives) = brackets.partition { it.transition >= 0 }

    fun simulate(list: List<Bracket>): Boolean {
        for ((lowestHeight, transition) in list) {
            if (currHeight + lowestHeight < 0) return false
            currHeight += transition
        }
        return true
    }

    if (!simulate(positives.sortedByDescending { it.lowestHeight })) return println("No")
    if (!simulate(negatives.sortedBy { it.lowestHeight - it.transition })) return println("No")

    val answer = if (currHeight == 0) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 98004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MAX = (int)Math.pow(10, 8)+1;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			boolean[] isPrime = new boolean[MAX];
			isPrime = new boolean[MAX];
			Arrays.fill(isPrime, true);
			isPrime[0] = isPrime[1] = false;
			for (int i = 2; i <= Math.sqrt(isPrime.length); i++) {
				if (!isPrime[i])
					continue;
				for (int j = i + i; j < isPrime.length; j += i) {
					isPrime[j] = false;
				}
			}

			int count = 0;
			for (int i = 0; i < n; i++) {
				if (isPrime[in.nextInt()]) {
					count++;
				}
			}

			out.println(count);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct zabuton { int h; int p; };

int main() {
  int N; cin >> N;
  zabuton z[N]; rep(i,N) cin >> z[i].h >> z[i].p;
  sort(z,z+N,[](const zabuton &x, const zabuton &y){ return x.h+x.p<y.h+y.p; });
  // rep(i,N) cout << z[i].h << "->" << z[i].p << " "; cout << endl;

  ll dp[N+1][N+1] = {}; rep(i,N+1) fill_n(dp[i],N+1,LLINF);
  rep(i,N+1) {
    dp[i][0] = 0;
    repr(j,1,i+1) {
      dp[i][j] = dp[i-1][j];
      if (dp[i-1][j-1]<=z[i-1].h) {
        dp[i][j] = min(dp[i][j], dp[i-1][j-1]+z[i-1].p);
      }
    }
  }

  // rep(i,N+1) debug(dp[i],dp[i]+N+1);
  ll result = N; while (dp[N][result]==LLINF) result--;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 195712
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  string S;
  VB used(26, false);

  cin >> S;
  REP(i, S.size()) {
    used[static_cast<int>(S[i]) - 'a'] = true;
  }

  REP(i, 26) {
    if (!used[i]) {
      cout << static_cast<char>('a' + i) << endl;
      return 0;
    }
  }

  cout << "None" << endl;
  return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
const LL mod=(1E9)+7;
LL a[2009];

int main()
{
  LL n;
  cin>>n;
  a[0]=1;
  for(LL i=3;i<=n;i++)
  {
      for(LL j=3;i-j>=0;j++)
      {
          a[i]+=a[i-j];
          a[i]%=mod;
      }
  }
//  for(int i=1;i<=n;i++)cout<<a[i]<<" ";
//  cout<<endl;
  cout<<a[n];

}


Measured memory_bytes: 3600
package main

import "fmt"

func sort(a []int) int {
	done := true
	n := len(a)
	c := 0
	for done {
		done = false
		for j := n - 1; j >= 1; j-- {
			if a[j] < a[j-1] {
				a[j-1], a[j] = a[j], a[j-1]
				c++
				done = true
			}
		}
	}
	return c
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	x := sort(a)
	for i, e := range a {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", e)
	}
	fmt.Printf("\n")
	fmt.Println(x)
}



Measured memory_bytes: 1112