akhauriyash/Code-Regression huggingface dataset:
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn gcd(a: i32, b: i32) -> i32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn check(s: &[i32]) {
    let sum: i32 = s.iter().sum();

    for i in 0..s.len() {
        let g = gcd(sum - s[i], s[i]);
        if g == 1 {
            panic!("seq = {:?}, gcd({}, {}) = {}", s, sum - s[i], s[i], g);
        }
    }
}

fn main() {
    let n: i32 = reads()[0];

    if n == 3 {
        println!("2 5 63");
        return;
    } else if n == 4 {
        println!("2 5 20 63");
        return;
    }

    let mut ms = [0; 6];

    for i in 2..30001 {
        if i % 2 == 0 || i % 3 == 0 {
            ms[i % 6] += 1;
        }
    }

    let mut us = [0; 6];
    us[0] = 1;
    us[2] = 1;
    us[3] = 2;
    us[4] = 1;
    let mut rest = n - 5;

    while rest > 0 {
        // println!("rest: {}, us: {:?}, ms{:?}", rest, us, ms);

        if rest >= 2 && us[2] < ms[2] && us[4] < ms[4] {
            us[2] += 1;
            us[4] += 1;
            rest -= 2;
        } else if rest >= 2 && us[3] + 2 <= ms[3] {
            us[3] += 2;
            rest -= 2;
        } else if us[0] < ms[0] {
            us[0] += 1;
            rest -= 1;
        }
    }

    let mut ans = vec![];

    for i in 2..30001 {
        if i % 2 == 0 || i % 3 == 0 {
            if us[i % 6] > 0 {
                us[i % 6] -= 1;
                ans.push(i as i32);
            }
        }
    }

    check(&ans);

    for i in 0..ans.len() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}


Measured memory_bytes: 4476
#include <stdio.h>

int main(void)
{
	int vehicle[10];
	int i = 0;
	
	while (scanf("%d", &vehicle[i]) != EOF){
		if (vehicle[i] == 0){
			i--;
			printf("%d\n", vehicle[i]);
		}
		else {
			i++;
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int r1=n/r,g1=n/g;
  ll ans=0;
  for(int i=0;i<=r1;i++){
    for(int j=0;j<=g1;j++){
      ll p=n-i*r-j*g;
      if( p>=0 &&p%b==0){
        
        ans++;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3608
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int A,B;
vector<int> pop[1001];
int bs[5000];
int main() {
	cin >> A >> B;
	for(int i=1;i<=A;i++){
		int a;
		cin >> a;
		pop[a].push_back(i);
	}
	for(int i=0;i<B;i++){
		cin >> bs[i];
	}
	int ret=0;
	for(int i=0;i<B;i++){
		int p=0;
		int j=i;
		for(;j<B;j++){
			auto it=upper_bound(pop[bs[j]].begin(),pop[bs[j]].end(),p);
			if(it==pop[bs[j]].end()){
				break;
			}
			p=*it;
		}
		ret=max(ret,j-i);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1308
#include<stdio.h>

int main(void)
{
  int a,b,c;

  if(scanf("%d",&a)==1){

    b=a/100;
    c=a%100;

    if(b==0){
      if(c==0 || c>12){puts("NA");}
      else{puts("YYMM");}
    }
    else if(b>12){
      if(c==0 || c>12){puts("NA");}
      else{puts("YYMM");}
    }
    else if(b<=12){
      if(c==0 || c>12){puts("MMYY");}
      else{puts("AMBIGUOUS");}
    }
  }else{
    puts("error");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m;
    cin>>n>>m;
    ll l,r;
    ll arr[n+1]={0};
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        l--;
        arr[l]++;
        arr[r]--;
    }
    for(i=1;i<n+1;i++) arr[i]+=arr[i-1];
    ll count=0;
    for(i=0;i<n+1;i++) if(arr[i]==m) count++;
    cout<<count;
}

Measured memory_bytes: 4396
#include<stdio.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define chmin(p,q)(p=min(p,q))
#define max3(p,q,r)max(max(p,q),r)
#define min3(p,q,r)min(min(p,q),r)
#define INF ((1LL<<62)-(1LL<<31))

ll x,y;
ll g(ll h,ll w){
	//2つに割って割った結果をx,yに格納
	if(h*w%2==0){
		x=y=h*w/2;
	}else{
		//長い方を割る
		if(h>w){ll t=h;h=w;w=t;}
		x=h*(w/2);
		y=h*(w-w/2);
	}
}

ll f(ll h,ll w){
	//3つに割って差の最小値を答える
	ll ans=INF;
	rep(hh,h/3,h/3+2){
		g(h-hh,w);
		chmin(ans,max3(hh*w,x,y)-min3(hh*w,x,y));
	}
	return ans;
}

int main(){
	ll h,w;
	scanf("%lld%lld",&h,&w);
	//縦に1/3を取る場合と横に1/3を取る場合
	printf("%lld\n",min(f(h,w),f(w,h)));
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N = int(input())
A = [0]+list(map(int, input().split()))+[0]
ans = 0

for i in range(N+1):
    ans += abs(A[i+1]-A[i])
    
for i in range(1, N+1):
    print(ans-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

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

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

    int N, M; cin >> N >> M;
    int maxL = 0, minR = INT_MAX;

    rep(i, 0, M) {
        int L, R; cin >> L >> R;
        --L; --R;
        maxL = max(maxL, L);
        minR = min(minR, R);
    }

    int res = 0;
    if (maxL <= minR) res = minR-maxL+1;

    cout << res << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")
	nk := strings.Split(tmp, " ")

	n, _ := strconv.Atoi(nk[0])
	x, _ := strconv.Atoi(nk[1])

	tmp2, _ := reader.ReadString('\n')
	tmp2 = strings.Trim(tmp2, "\n")
	l := strings.Split(tmp2, " ")

	count := 0

	sum := make([]int, n+1)
	sum[0] = 0
	for i, li := range l {
		step, _ := strconv.Atoi(li)
		sum[i+1] = sum[i] + step
	}

	for i := 0; i < len(sum); i++ {
		if sum[i] > x {
			break
		} else {
			count++
		}
	}

	fmt.Println(count)
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string str;
  cin >> str;

  for(char &c : str) {
    if(c == '9') {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}


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

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

  vector<string> s(N);
  for (int i = 0; i < N; i++)
  {
    string S;

    cin >> S;
    s.at(i) = S;
  }

  
  sort(s.begin(), s.end());
  //reverse(s.begin(), s.end());
  string sn = s.at(0);
  for (int i = 1; i < N; i++)
  {
    sn += s.at(i);
  }
  cout << sn << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %.5lf\n",d,r,f);
    return 0;


}



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

using namespace std;

int main()
{
string s;
cin >> s;

for (int i = 0; i < 26; i++)
    if (s.find((char)('a'+i)) == -1)
{
cout << (char)('a'+i);
return 0;
}
cout << "None";
}

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

int main(){
    int n; cin >> n;
    ll power = 1;
    ll dis = 1000000007;
    for(int i=1; i<=n; i++){
        power = power*i;
        power = power % dis;
    }
    cout << power << endl;
    return 0;

}

Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	char a;
	cin >> a;
	if (a== 'A')cout << 'T';
	if (a == 'C')cout << 'G';
	if (a == 'G')cout << 'C';
	if (a == 'T')cout << 'A';
	return		(0);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    res = 1
    for v, c in E[u]:
        if p != c:
            res += dfs(v, c)
    X[p] = res
    return res

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = - inv * N - I[N] + 1
for e in range(N - 1):
    ans += (1 - I[X[e]]) * (1 - I[N - X[e]])
    ans %= mod

print(ans)

Measured memory_bytes: 214424
/*
    アスキー文字
    https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0405?year=2019
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;

    // 65 - 90
    if (65 <= n && n <= 90) {
        cout << 1 << endl;
    } else if (97 <= n && n <= 122) {
        // 97 - 122
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n;
	cin >> n;
	int a[10005], b[10005];
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	map<int, int>maxmp;
	map<int, int>mp[10005];
	rep(i, n) {
		int j = 2;
		while (j * j <= a[i]) {
			if (a[i] % j == 0) {
				mp[i][j]++;
				a[i] /= j;
			}
			else j++;
		}
		mp[i][a[i]]++;
	}
	rep(i, n) {
		for (auto p : mp[i]) {
			maxmp[p.first] = max(maxmp[p.first], p.second);
		}
	}
	int lc = 1;
	for (auto p : maxmp) {
		lc *= mod_pow(p.first, p.second, MOD);
		lc %= MOD;
	}
	int ans = 0;
	rep(i, n) {
		ans += lc * modinv(b[i], MOD);
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3968
n,m=map(int,input().split())
sa=set()
sb=set()
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:
    sa.add(b)
  if b==n:
    sb.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE") 



Measured memory_bytes: 57944
#include<stdio.h>

int main(void){
	int a,n[101]={0},m=0;
	while(~scanf("%d",&a)){
		n[a]++;
		m=m>n[a]?m:n[a];
	}
	for(int i=0;i<101;i++)if(m==n[i])printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 0
#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)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

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

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
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' };
*/


int main() {
	vector<lint>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	rep(i, 3) {
		if (V[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << V[0] * V[1] << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		ArrayList<Long> list = new ArrayList<>();

		for (int i = 0; i < N; i++) {
			list.add(sc.nextLong());
		}

		Collections.sort(list);

		long[] dif = new long[N-K+1];

		for (int i = 0; i < N-K+1; i++) {
			long min = list.get(i);
			long max = list.get(i+K-1);

			dif[i] = max - min;
		}

		Arrays.sort(dif);

		System.out.println(dif[0]);
	}

}


Measured memory_bytes: 62104
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

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

int main()
{

  int n; cin >> n;
  cout << 1110 - n << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    static FastIO io = new FastIO("in.txt");

    public static void main(String[] args) throws Exception {

        String s = io.next();
        if(s.indexOf('R') < 0){
            io.println(0);
        }else{
            if(s.equals("RRR")){
                io.println(3);
            }else if(s.equals("RRS") || s.equals("SRR")){
                io.println(2);
            }else{
                io.println(1);
            }
        }
        io.flush();
    }

    static class FastIO {
        static StringBuilder sb = new StringBuilder();
        static BufferedReader br;
        static StringTokenizer st;
        static PrintStream ps = new PrintStream(System.out);

        public FastIO(String fname) {
            try {
                File input = new File(fname);
                if (input.exists()) {
                    System.setIn(new FileInputStream(fname));
                }
            }catch (Exception e){
                e.printStackTrace();
            }

            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        void flush(){
            System.out.print(sb.toString());
            sb.setLength(0);
        }

        void print(Object o){
            sb.append(o);
        }

        void println(Object o){
            sb.append(o);
            sb.append('\n');
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 32592
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  unordered_map<string,ll> m;
  m["SAT"]=1;
  m["FRI"]=2;
  m["THU"]=3;
  m["WED"]=4;
  m["TUE"]=5;
  m["MON"]=6;
  m["SUN"]=7;
  
  string s;
  cin>>s;
  cout << m[s] << endl;
  
  

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int k;  cin >> k;
  int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
  cout << s[k - 1] << endl;
}

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

int main() {
	int N, D;
	int i=0;
	int ans=0;
	int flag = 0;
	cin >> N >> D;
	while (flag == 0)
	{
		if (i >= N) {
			flag = 1;
		}
		else {
			i += D * 2 + 1;
				ans +=1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,m;cin>>n>>m;
    int a[n][2];rep(i,n)cin>>a[i][0]>>a[i][1];
    int c[m][2];rep(i,m)cin>>c[i][0]>>c[i][1];
    vector<int>ans;
    rep(i,n){
        int tmp=0;
        int index = 0;
        int mn = 1000000000;
        rep(j,m){
            tmp = abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]);
            if(mn>tmp){mn=tmp;index=j+1;}
        }
        ans.push_back(index);
    }
    for(auto i=ans.begin();i!=ans.end();i++){
        co(*i);
    }
}

Measured memory_bytes: 256
N=int(input())
p_list=list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if p_list[i] == i+1:
    ans += 1
    tmp = p_list[i]
    p_list[i] = p_list[i+1]
    p_list[i+1] = tmp
if p_list[-1] == N:
  print(ans+1)
else:
  print(ans)

Measured memory_bytes: 14008
#include <iostream>
#include <vector>

using namespace std;
int main() {
	int n;
	int vl;
	vector<int> ln[2];
	cin >> n;
	int cs=0;
	for(int i=0;i<n;i++) {
		cin >> vl;
		ln[cs].push_back(vl);
		cs=1-cs;
	}
	for(int i=ln[1-cs].size()-1;i>=0;i--) {
		if(i<ln[1-cs].size()-1) cout << " ";
		cout << ln[1-cs][i];
	}
	for(int i=0;i<ln[cs].size();i++) {
		cout << " " << ln[cs][i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL, *test;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
     
    while(x!=NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == test) {
        root = z;
    } else {
        if(z->key < y->key) {
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        cin >> com;
        if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 26704
from collections import defaultdict
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))


Group = defaultdict(list)
keys = set()
for x in X:
    Group[x % M].append(x)
    keys.add(x % M)


ans = 0
for surplus in keys:
    s, t = Group[surplus], Group[M - surplus]
    s_size, t_size = len(s), len(t)
    # tの方が小さくなるようにswap
    if t_size > s_size:
        s, t = t, s
        s_size, t_size = len(s), len(t)
        surplus = M - surplus

    if (surplus == 0) or (surplus == M - surplus):
        ans += s_size // 2
    else:
        size_diff = s_size - t_size
        i = 0

        while i + 1 < s_size:
            if (s[i] == s[i + 1]) and (size_diff - 2 >= 0):
                size_diff -= 2
                ans += 1
                i += 1
            i += 1
        ans += t_size
    Group[surplus], Group[M - surplus] = [], []

print(ans)


Measured memory_bytes: 29260
s = input()
t = input()

a = [[0 for _ in range(26)] for _ in range(26)]
b = [[0 for _ in range(26)] for _ in range(26)]
for i, j in zip(s, t):
    a[ord(i) - 97][ord(j) - 97] = 1
    b[ord(j) - 97][ord(i) - 97] = 1

for i, j in zip(a, b):
    if sum(i) >= 2 or sum(j) >= 2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
  int i, n, a;
  int min, max;
  long int sum;

  scanf("%d", &n);
  sum = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (i == 0) min = max = a;
    if (min > a) min = a;
    if (max < a) max = a;
    sum += a;
  }
  printf("%d %d %ld\n", min, max, sum);

  return 0;
}

Measured memory_bytes: 600
#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 n;
    cin >> n;
    vector<int> x(n);
    vector<int> b(n);
    rep(i,n){
        cin >> x[i];
        b[i] = x[i];
    }
    int l = n/2;
    sort(b.begin(),b.end());
    int s = b[l-1];
    int t = b[l];
    if(s == t){
        rep(i,n)cout << s << endl;
    }
    else{
        rep(i,n){
            if(x[i] <= s)cout << t << endl;
            if(x[i] >= t)cout << s << endl;
        }
    }
}

Measured memory_bytes: 3712
import itertools
n,m=map(int,input().split())
l=[]
for i in range(m):
    a,*b=list(map(int,input().split()))
    l.append(b)
p=list(map(int,input().split()))
cnt=0
for x in itertools.product([0,1], repeat=n):
    onl=[0]*m
    for i in range(n):
        for j in range(m):
            if x[i]==1 and i+1 in l[j]:onl[j]+=1
    for i in range(m):
        if p[i]!=onl[i]%2:
            break
    else:cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(void){
    int n;string s;cin>>n>>s;
    int count=0,ans=0;
    rep(i,n){
        if(s[i]==')')count--;
        else count++;
        if(count<0){ans++;count++;}
    }
    string A="";
    rep(i,ans){
        A+='(';
    }
    A+=s;
    rep(i,count)A+=')';
    cout<<A;
}

Measured memory_bytes: 256
while true
    n = gets.to_i
    break if n == 0
    arr = gets.chomp.split.map(&:to_i)
    diff = []
    arr[0...-1].each_with_index{|x, i| diff << arr[i + 1] - x}
    i = diff.index(0)
    if i
        puts arr[i]
        next
    end
    h = Hash.new(0)
    diff.each{|d| h[d] += 1}

    if h.length == 2 && h.values.min == 1
        puts (diff[0] == diff[1]) ? arr[-1] : arr[0]
    else
        hen = diff.find_all{|x| h[x] == 1}
        k = h.keys
        hen << (k[0] * 2 == k[1] ? k[0] : k[1]) if hen.empty?
        i = diff.index{|x| hen.include? x}
        puts arr[i + 1]
    end
end


Measured memory_bytes: 7184
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = [list(input().rstrip()) for _ in range(H)]

    dp = [[f_inf] * W for _ in range(H)]
    dp[0][0] = 1
    for h in range(H):
        for w in range(W):
            if A[h][w] != "#":
                if h - 1 >= 0 and w - 1 >= 0:
                    dp[h][w] = min(dp[h][w], ((dp[h - 1][w] if A[h - 1][w] == "." else 0) + (dp[h][w - 1] if A[h][w - 1] == "." else 0)) % mod)
                elif h - 1 >= 0:
                    dp[h][w] = min(dp[h][w], (dp[h - 1][w] if A[h - 1][w] == "." else 0) % mod)
                elif w - 1 >= 0:
                    dp[h][w] = min(dp[h][w], (dp[h][w - 1] if A[h][w - 1] == "." else 0) % mod)

    print(dp[H - 1][W - 1] % mod)


if __name__ == '__main__':
    resolve()


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

int main() {
  int q, c, a, n;
  cin >> q;
  while (q--) {
    int ans = 0;
    cin >> c >> a >> n;
    while (true) {
      if (c && a && n) {
        c--;
        a--;
        n--;
        ans++;
      } else if (c >= 2 && a) {
        c -= 2;
        a--;
        ans++;
      } else if (c >= 3) {
        c -= 3;
        ans++;
      } else {
        break;
      }
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<ctype.h>
int main(void)
{
    char ch;
    while(1)
    {
        scanf("%c",&ch);
        if(islower(ch))
        {
            ch=toupper(ch);
        } else {
            ch=tolower(ch);
        }
        printf("%c",ch);
        if(ch=='\n')break;
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p){
  auto sorted = p;
  sort(p.begin(), p.end());

  bool f = false;

  if (sorted == p) f = true;
  REP(x, N) {
    FOR(y, x+1, N) {
      auto copy = p;
      int tmp = copy.at(x);
      copy.at(x) = copy.at(y);
      copy.at(y) = tmp;

      if (sorted == copy) f = true;
    }
  }

  cout << (f ? YES : NO) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> p(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  solve(N, std::move(p));
}


Measured memory_bytes: 256
import Control.Monad

factorT = 1000

solve :: Int -> Int -> [Int] -> Int
solve t a hs = minByIdx (map d hs) where
    minByIdx = iter 1 0 (10000000*factorT)
    iter _ mi _ [] = mi
    iter i mi mx (x:xs)
        | mx > x    = iter (i+1) i  x  xs
        | otherwise = iter (i+1) mi mx xs   
    d h = abs (factorT*a - averageT t h) 
averageT t h = t*factorT - h*6 

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines = flip replicateM readLine
    
main :: IO() 
main = do
    [n]    <- readLine
    [t, a] <- readLine
    [l] <- readLines 1
    let ans = solve t a l
    print ans


Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000

int a[MAX_N];
int b[MAX_N];


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N, A, B;
  cin >> N >> A >> B;

  ll hoge = A+B;
  ll amari, syou, result;
  
  //ll syou = N / (A + B);
  if ( A+B > N) {

    if (A >= N) result = N;
    else result = A;
    
  }
  else {
    amari = N % (A + B);
    syou = (N - amari) / (A+B);
    //cout << amari << endl;
    //cout << syou << endl;  
    
    //result = A * syou + amari;

    if (amari <= A) result = A * syou + amari;
    else result = A * syou + A;
  }

  cout << result << endl;

  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=2e9+7;



int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	int cnt=INF;
	for(int i=0;i<=n-k;i++)
		cnt=min(cnt,a[i+k-1]-a[i]);
	cout<<cnt;
	
	
}

Measured memory_bytes: 640
import java.util.*;

public class Main{

  static int h=0;
  static long[] a;

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    a = new long[3000000];
    while (true){
      String inst = sc.next();
      if (inst.equals("end")) break;
      switch (inst){
        case "insert":
          insert(sc.nextLong());
          break;
        case "extract":
          System.out.println(extract());
          break;
      }
    }
  }

  public static void insert(long k){
    h++;
    a[h] = k;
    int i = h;
    while (i > 1 && a[parent(i)] < a[i]){
      long t = a[i];
      a[i] = a[parent(i)];
      a[parent(i)] = t;
      i = parent(i);
    }
  }

  public static long extract(){
    long ret = a[1];
    a[1] = a[h];
    h--;
    maxHeapify(1);
    return ret;
  }

  public static int left(int i){
    return 2*i;
  }

  public static int right(int i){
    return 2*i+1;
  }

  public static int parent(int i){
    return i/2;
  }

  public static void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= h && a[l]>a[i]){
      largest = l;
    } else {
      largest = i;
    }
    if (r <= h && a[r] > a[largest]){
      largest = r;
    }

    if (largest != i){
      long t = a[i];
      a[i] = a[largest];
      a[largest] = t;
      maxHeapify(largest);
    }
  }

  public static void buildMaxHeap(){
    for (int i=h/2; i>0; i--){
      maxHeapify(i);
    }
  }
}


Measured memory_bytes: 571632
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    if ((b<2*a)||(b>4*a)||(b%2!=0)){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 35660
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

queue<char> que[3];

int main()
{
    int n;
    int a[100005];
    int ans = 0;

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

    for (int i = 0; i < n; i++) {
        if (a[a[i]] == i && i < a[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#define MOD 1000000007

LL N, K;
LL dp[102][32000];
LL sum[102][32000],keisu[102][32000];
int main(){
	cin >> N >> K;
	for(int i=K+1; i>=0; i--){
		sum[i][0] = 0;
		keisu[i][0] = 0;
		for(int j=1; j<=sqrt(N); j++){
			if(i >= K){
				dp[i][j] = 1;
			}
			else{
				dp[i][j] = 0;
				dp[i][j] += sum[i+1][min((LL)sqrt(N),N/j)];
				if(j*(LL)sqrt(N) <= N){
					if(i == K-1){
						dp[i][j] += dp[i+2][1] * max(0LL, N/j-(LL)sqrt(N));
					}
					else{
						dp[i][j] += sum[i+2][j]*max(0LL, N/j-(LL)sqrt(N));
						dp[i][j] += keisu[i+2][(LL)sqrt(N)]-keisu[i+2][j];
					}
				}
				dp[i][j] += 2*MOD;
				dp[i][j] %= MOD;
			}

			sum[i][j] = (dp[i][j] + sum[i][j-1]) % MOD;
			keisu[i][j] = (dp[i][j]*max(0LL,(N/j-(LL)sqrt(N))) + keisu[i][j-1]) % MOD;
		}
	}
	cout << dp[0][1] << endl;
}


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

int main() {
  using namespace std;

  int N, K, ans = 0;
  cin >> N >> K;

  int balls[N + 1];
  for (int i = 0; i < N + 1; i += 1) {
    balls[i] = 0;
  }

  for (int i = 0; i < N; i += 1) {
    int tmp;
    cin >> tmp;
    balls[tmp] += 1;
  }

  sort(balls, balls + N + 1);

  for (int i = N - K; i > 0; i -= 1) {
    if (balls[i] == 0) {
      break;
    }
    ans += balls[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	vector<ll> d(n);
	rep(i, n) cin>>d[i];
	sort(all(d));
	reverse(all(d));
	map<ll, ll> e;
	rep(i, n) ++e[d[i]];
	bool ok = true;
	for(int i = d[0]; i > d[0]/2; i--){
		if(e[i]<2) ok = false;
	}
	if(d[0]%2==0 && e[d[0]/2]!=1) ok = false;
	if(d[0]%2==1 && e[d[0]/2+1]!=2) ok = false;
	if(d[n-1]<=(d[0]-1)/2) ok = false;
	cout<<(ok?"Possible":"Impossible")<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
        cout<<min(a*b,c)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
if n<105:
    ans=0
elif n<135:
    ans=1
elif n<165:
    ans=2
elif n<189:
    ans=3
elif n<195:
    ans=4
else:
    ans=5
print(ans)


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

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector< long long > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sp(x) setprecision(x)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define deb(x) cout<<#x <<x <<endl
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
        ll n,k;
        cin>>n>>k;
        ll a[n+1];
        fill(a,0);
        ll d,x;
        while(k--){
        	cin>>d;
        	while(d--){
        		cin>>x;
        		a[x]=1;
        	}
        }
        ll count=0;
        rep(i,n)
        if(a[i+1]==0)
        	count++;
        cout <<  count<< '\n';
        

}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

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

        if (a <= 8 && b <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }

        sc.close();
    }

}


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

using namespace std;

#define ll long long

bool s[100010];

vector <ll> g[100010];
ll r[100010];

ll dfs(ll a)
{
    int i, c;
    if(g[a].size()==0) return 0;
    if(s[a]==1) return r[a];

    for(i=0; i<g[a].size(); i++)
        {
            c=dfs(g[a][i])+1;
            if(c>r[a]) r[a]=c;
            s[a]=1;
        }
    return r[a];
}

main()
{
    ll n, m, i, j, ans=0, u, v;

    cin>>n>>m;

    for(i=0; i<m; i++)
    {
        cin>>u>>v;

        g[u].push_back(v);
    }

    for(i=1; i<=n; i++)
    {
        if(s[i]==1) continue;

        dfs(i);
    }

    for(i=1; i<=n; i++) if(ans<r[i]) ans=r[i];

    cout<<ans<<endl;

}


Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  string s = to_string(n);
  ll wa = 0;
  for(int i = 0;i < (int)s.size();i++){
    wa += s[i] - '0';
  }
  if(n % wa == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3692
N = int(input())
A = list(map(int, input().split()))
B = {}
for i in range(0, 13):
    B[i] = 0
for i in A:
    B[i//400] += 1
ansA = 0
ansB = 0
for i in range(0, 13):
    if i < 8:
        if B[i] > 0:
            ansA += 1
            ansB += 1
    else:
        if B[i] > 0:
            ansB += B[i]
if min(A) >= 3200:
    ansA += 1
print(ansA, ansB)


Measured memory_bytes: 3064
from itertools import compress, product

s = input()
n = len(s)

total = 0
for index_masks in product((0,1), repeat=n-1):
  indices = [0] + list(compress(range(1, n), index_masks)) + [n]
  ijs = zip(indices, indices[1:])
  numbers = (int(s[i:j]) for i, j in ijs)
  total += sum(numbers)
print(total)

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  int l = S.length();
  vector<int> b(l + 1, 0);

  for (int i = 0; i < l; ++i) {
    if (S.at(i) == '<') {
      b.at(i + 1) = b.at(i) + 1;
    }
  }

  for (int i = l - 1; i >= 0; --i) {
    if (S.at(i) == '>') {
      b.at(i) = max(b.at(i), b.at(i + 1) + 1);
    }
  }

  // REP(i, l + 1) { cout << b.at(i) << ","; }
  // cout << endl;

  // REP(i, l + 1) { cout << b.at(i) << ","; }
  // cout << endl;

  ll ans = accumulate(b.begin(), b.end(), 0ll);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    char s[11], t[11], u[11];
    int a, b;
    scanf("%s %s %d %d %s", s, t, &a, &b, u);
    if (!strcmp(s, u))
    {
        printf("%d %d", a - 1, b);
    }
    if (!strcmp(t, u))
    {
        printf("%d %d", a, b - 1);
    }
    return 0;
}

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

int dy[]={0,1,0,-1};
int dx[]={1,0,-1,0};
char m[50][51];
int w,h;

bool visit[50][50];
int flag;
int dfs(int y,int x){
	if(y<0||h<=y||x<0||w<=x || visit[y][x])return 0;
	if(m[y][x]=='B'){
		flag|=1;
		return 0;
	}
	if(m[y][x]=='W'){
		flag|=2;
		return 0;
	}
	visit[y][x]=true;
	int res=1;
	for(int i=0;i<4;i++){
		res += dfs(y+dy[i],x+dx[i]);
	}
	return res;
}
int main(){
	while(cin>>w>>h,w|h){
		int black=0,white=0;
		for(int i=0;i<h;i++)cin>>m[i];
		memset(visit,false,sizeof(visit));
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				if(visit[y][x]||m[y][x]!='.')continue;
				flag=0;
				int s=dfs(y,x);
				if(flag==1)black+=s;
				else if(flag==2)white+=s;
			}
		}
		cout<<black<<' '<<white<<endl;
	}
	return 0;
}

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

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

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
 ll a,b,c,d; cin>>a>>b>>c>>d;
 ll ans=a*c;
 if(a*d>ans)ans=a*d;
 if(b*c>ans) ans=b*c;
 if(b*d>ans) ans=b*d;
 cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
int main(){
  int i,j,n,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if(i%3==0)printf(" %d",i);
    else{
      for(j=0;j<4;j++){
    if(x%10==3){
      printf(" %d",i);
      break;
    }
    x/=10;
      }
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000


 int main(){

 int n ; cin>>n;
 string s; cin>>s;

  int ans=0;

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

    int ani[26] = {0},lin[26] = {0};
      for(int j=0;j<i;j++){
            ani[s[j]-'a'] = 1;
      }

      for(int k=i;k<n;k++){
            lin[s[k]-'a'] = 1;
      }

   int cnt=0;
      for(int i=0;i<26;i++){
            if(ani[i] == 1 && lin[i] == 1)
                  cnt++;
      }

      ans = max(ans,cnt);

  }

  cout<<ans<<endl;

 return 0;
 }


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

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

    int pl = a+b;
    int pl2 = a-b;
    int pl3 = a*b;

    int ans = 0;
    ans = max({pl,pl2,pl3});


    cout << ans << endl;
}

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

int main(void) {
    int A,B;
    string s;
    bool check = true;
    cin >> A >> B >> s;
    for(int i=0;i<A;i++) {
        if(!isdigit(s[i])) check = false;
    }
    if(s[A] != '-') check = false;
    for(int i=A+1;i<(A+B);i++) {
        if(!isdigit(s[i])) check = false;
    }

    if(check) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256