akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main() {
  long long n, m, l, fr, to, w, s, f, qa;
  cin >> n >> m >> l;
  vector<vector<long long> > g(n + 1, vector<long long>(n + 1, 1e18));
  
  for(int i = 1; i <= n; ++i) g[i][i] = 0;

  for(int i = 0; i < m; ++i){
    cin >> fr >> to >> w;
    g[fr][to] = g[to][fr] = w;
  }
  for (int k = 1; k <= n; ++k)
	  for (int i = 1; i <= n; ++i)
		  for (int j = 1; j <= n; ++j)
			  g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  
  vector<vector<long long> > d(n + 1, vector<long long>(n + 1, 1e9));
  for(int i = 1; i <= n; ++i){
    queue<int> q;
    q.push(i);
    vector<bool> used(n + 1, false);
    d[i][i] = 0;
    used[i] = true;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (size_t j=1; j<=n; ++j) {
        if (!used[j] && g[v][j] <= l) {
          used[j] = true;
          q.push(j);
          d[i][j] = d[i][v] + 1;
        }
      }
    }
  }

  cin >> qa;
  for(int asd = 0; asd < qa; ++asd){
    cin >> s >> f;
    if(d[s][f] == 1e9) cout << -1 << endl;
    else cout << d[s][f] - 1 << endl;
  }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
// URLD
double dx[4]={0,1,-1,0};
double dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);


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

    int n;
    cin>>n;
    double ans = 1e18;
    double xma=-1e9,xmi=1e9,yma=-1e9,ymi=1e9;
    vector<vector<array<double,2>>> v(4);
    for(int i=0;i<n;i++){
        double x,y;
        char d;
        cin>>x>>y>>d;
        chmin(xmi,x);
        chmin(ymi,y);
        chmax(xma,x);
        chmax(yma,y);
        if(d=='U') v[0].push_back({x,y});
        if(d=='R') v[1].push_back({x,y});
        if(d=='L') v[2].push_back({x,y});
        if(d=='D') v[3].push_back({x,y});
    }
    ans = (xma - xmi) * (yma - ymi);
    double low=0,up=1e9,m[2];
    for(int r=0;r<100;r++){
        m[0] = (low*2 + up)/3.0;
        m[1] = (low + up*2) / 3.0;
        double xma[2],xmi[2],yma[2],ymi[2];
        double sum[2] = {};
        for(int i=0;i<2;i++){
            xma[i] = -1e18;
            xmi[i] = 1e18;
            yma[i] = -1e18;
            ymi[i] = 1e18;
            for(int k=0;k<4;k++){
                for(auto a:v[k]){
                    double x = a[0] + m[i]*dx[k], y = a[1] + m[i]*dy[k];
                    chmin(xmi[i],x);
                    chmax(xma[i],x);
                    chmin(ymi[i],y);
                    chmax(yma[i],y);
                }
            }
            sum[i] = (xma[i] - xmi[i]) * (yma[i] - ymi[i]);
        }
        if(sum[0] < sum[1]) up=m[1];
        else low = m[0];
    }
    xma=-1e9,xmi=1e9,yma=-1e9,ymi=1e9;
    for(int k=0;k<4;k++){
        for(auto a:v[k]){
            double x = a[0] + low*dx[k], y = a[1] + low*dy[k];
            chmin(xmi,x);
            chmax(xma,x);
            chmin(ymi,y);
            chmax(yma,y);
        }
    }
    chmin(ans,(xma-xmi)*(yma-ymi));
    cout << ans << endl;
}

Measured memory_bytes: 5372
import sys

n, m = map(int, input().split(' '))
a = [True] * (n+1)

for i in range(m):
  num = int(input())
  a[num] = False

dp = [0] * (n+1)
dp[0] = 1
for i in range(n+1):
  
  if (i+1) <= (n):
    if a[i+1]:
      dp[i+1] = dp[i] + dp[i+1]
      dp[i+1] = dp[i+1] % (10**9 + 7)
  if (i+2) <= (n):
    if a[i+2]:
      dp[i+2] = dp[i] + dp[i+2]
      dp[i+2] = dp[i+2] % (10**9 + 7)
  

# print(a)
print(dp[n])

Measured memory_bytes: 45656
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (a.charAt(i) == b.charAt(i) && a.charAt(i) == c.charAt(i)) {

			} else if (a.charAt(i) == b.charAt(i) || a.charAt(i) == c.charAt(i) || c.charAt(i) == b.charAt(i)) {
				count++;
			} else {
				count += 2;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 25172
let () =
  let rec read total qty_total cnt =
    try let unit_price, qty = Scanf.scanf " %f,%f\n" (fun x y -> x,y) in
        let price = unit_price*.qty in
        read (total+.price) (qty_total+.qty) (cnt+.1.)
    with
      End_of_file ->
      let favg = qty_total/.cnt in
      let avg =
        if int_of_float favg |> float |> (-.) favg >= 0.5 then
          (int_of_float favg)+1
        else
          (int_of_float favg)
      in
      Printf.printf "%d\n" (int_of_float total);
      Printf.printf "%d\n" avg
  in read 0. 0. 0.
;;

Measured memory_bytes: 2392
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,k,n) for(int i = k ; i < n ; i++ )
double G[101][101];
int main(){
  int n,m;
  while( cin >> n >> m,n+m){

    rep(i,1,n+1)
      rep(j,1,n+1)cin >> G[i][j];

    double dp[101][101];

    fill(dp[0],dp[101],0);

    rep(j,0,n+1)dp[1][j] = 1;

    double mx = 0;

    rep(i,2,m+1){
      rep(j,1,n+1){
	rep(k,1,n+1){
	  dp[i][j] = max(dp[i][j],dp[i-1][k] * G[k][j]);
	}
      }
    }

    rep(j,1,n+1)mx = max(mx,dp[m][j]);
    printf("%.2f\n",mx);

  }
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define vi vector<long long>
#define vvi vector<vector<long long>>
int main(void){
  long long N, K;
  cin >> N;
  cin >> K;
  long long A[N];
  for(long long i = 0 ; i < N; i++){
    cin >> A[i];
  }
  sort(A,A+N);
  
  long long sum = 0;
  for(long long i = 0; i < N-K; i++){
    sum += A[i];
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 1792
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////
int main(){
    string S;
    int Q;
	cin >> S >> Q;
    string ans;
    REP(i,S.size())ans.push_back(S[i]);

    int reco = 0;
    REP(i,Q){
        int ot;
        cin >> ot;
        if(ot==1){
            reco++;
        }else{
            int pa; string pb;
            cin >> pa >> pb;
            if(pa == 1){
                if(reco%2 == 0) ans.insert(0,pb);
                else ans.push_back(pb[0]);
            }else{
                if(reco%2 == 0) ans.push_back(pb[0]);
                else ans.insert(0,pb);
            }
        }
    }

    if(reco%2 == 1)reverse(all(ans));
	REP(i,ans.size())cout << ans[i];
    cout << endl;
	return 0; 
}

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

int main(){
    int N; cin >> N;
  
  	long long int MOD = pow(10,9) + 7;
    long long int power = 1;
    for(int i=1;i<=N;i++){
        power = (power*i) % MOD;
    }
    cout << power % MOD;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	printf("%.9f ", h*w/2.0);
	if(2*x==w && 2*y==h) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = ReadAndParseInt();
            var v = ReadAndParseIntArr();

            int ans = 0;
            int num0, total0;
            FindMost(v, 0, -1, out num0, out total0);
            ans = v.Length / 2 - total0;

            FindMost(v, 1, num0, out num0, out total0);
            ans += v.Length / 2 - total0;

            int ans1 = 0;
            FindMost(v, 1, -1, out num0, out total0);
            ans1 = v.Length / 2 - total0;

            FindMost(v, 0, num0, out num0, out total0);
            ans1 += v.Length / 2 - total0;

            ans = Math.Min(ans, ans1);
            Console.WriteLine(ans);
        }

        private static void FindMost(int[] v, int offset, int ignoreNum ,out int num,out int total)
        {
            var hash = new Dictionary<int, int>();// key 数値、value 個数
            for(int i=offset;i<v.Length;i+=2)
            {
                if(hash.ContainsKey(v[i])){
                    hash[v[i]]++;
                }else{
                    hash.Add(v[i], 1);
                }
            }
            num = -1;
            total = 0;
            foreach(var pair in hash)
            {
                if(pair.Value > total && pair.Key != ignoreNum)
                {
                    num = pair.Key;
                    total = pair.Value;
                }
            }
        }
    }
}

Measured memory_bytes: 28896
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;


int main()
{
    IOS
    ll n;
    cin>>n;
    map<ll,ll>mp;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        mp[i+1]=x;
    }
    ll c[n];
    for(ll i=1;i<=n-1;i++)
    {
        cin>>c[i];
    }
    ll ans=0;
    ll prev=-1;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==prev+1)
        {
            ans+=c[prev];
        }
        prev=a[i];  
        ans+=mp[a[i]];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;

  cout << (H-h)*(W-w) << endl;
  
  return 0;
}


Measured memory_bytes: 384
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())

    if N % 2 == 0:
        for i in range(M):
            x = i + 1
            y = N - i - 1
            if y - x > (N - y + x):
                print(x, y)
            else:
                print(x, y - 1)
    else:
        for i in range(M):
            print(i + 1, N - i)


if __name__ == "__main__":
    main()


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

template<typename T>
int sgn(T val){
  return (T(0)<val)-(val<T(0));
}

tuple<long long,long long,long long> egcd(long long a,long long b){
  if(a==0||b==0)return std::make_tuple(0LL,0LL,0LL);
  long long sa=sgn(a),sb=sgn(b);
  a=std::abs(a);b=std::abs(b);
  long long p=1,q=0,r=0,s=1;
  while(b>0){
    long long c=a/b;
    long long d;
    d=a;a=b;b=d%b;
    d=p;p=q;q=d-c*q;
    d=r;r=s;s=d-c*s;
  }
  return std::make_tuple(a,p*sa,r*sb);
}

long long inverse(long long a,long long m){
  auto b=egcd(a,m);
  if(std::get<0>(b)!=1)return 0;
  return (std::get<1>(b)<0)?std::get<1>(b)+m:std::get<1>(b);
}

long long factorial(long long a,long long m){
  long long ret=1;
  for (long long i = 1; i <= a; i++) {
    ret*=(i%m);
    ret%=m;
  }
  return ret;
}
long long partial_factorial(long long a,long long n,long long m){
  long long ret=1;
  for (long long i = 0; i < n; i++) {
    ret*=(a-i)%m;
    ret%=m;
  }
  return ret;
}
long long combination_prime(long long n,long long r,long long m){
  long long ret;
  long long fact_r=factorial(r,m);
  ret=inverse(fact_r,m);
  long long pfact_n=partial_factorial(n,r,m);
  ret*=pfact_n;
  ret%=m;
  return ret;
}
long long cache_cmb[1000000],cache_inv_fact[1000000];
bool cached=false;
long long combination_cached(long long n,long long r,long long m){
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i <= n; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    cache_cmb[0]=1;
    for (long long i = 1; i <= n/2; i++) {
      cache_cmb[i]=cache_cmb[i-1]*(n-i+1)%m*cache_inv_fact[i]%m;
    }
  }
  r=min(r,n-r);
  return cache_cmb[r];
}

ll N,A,B,K;
vector<pair<ll,ll> > pat;
const long long mod=998244353;
ll inv[300005],c[300005];
int main()
{
        ll n,a,b,k,ans=0;
  cin>>n>>a>>b>>k;
        inv[1]=1;for(ll i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
        c[0]=1;for(ll i=1;i<=n;i++) c[i]=c[i-1]*(n-i+1)%mod*inv[i]%mod;
        for(ll i=0,j;i<=n;i++)
        {
                if(a*i>k) break;
                if((k-a*i)%b==0) j=(k-a*i)/b; else continue;
                if(j>n) continue;
                ans+=combination_cached(n,i,mod)*combination_cached(n,j,mod)%mod,ans%=mod;
        }
        printf("%lld\n",ans);
        return 0;
}


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

int main() {

  int R, G, B, N, count, rest;
  cin >> R >> G >> B >> N;
  int ma, mid, mi;
  ma = max(R, max(G, B));
  mi = min(R, min(G, B));
  mid = R + G + B - ma - mi;
  for(int i=0; i<N/ma+1; i++) {
    for (int j=0; j<N/mid+1; j++) {
      rest = N - ma * i - mid * j;
      if (rest % mi == 0 && rest >= 0) {
        count += 1;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    dp = [0] * 101

    dp[0] = 1
    for i in range(1,101):
        if i-4>=0 and dp[i-4]>0:
            dp[i] = dp[i-4]
        if i-7>=0 and dp[i-7]>0:
            dp[i] = dp[i-7]
    
    if dp[n]:
        print('Yes')
    else:
        print('No')

solve()


Measured memory_bytes: 3064
n,w = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(n)]
dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if j >= L[i][0]:
            dp[i+1][j] = max(dp[i][j-L[i][0]]+L[i][1],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[n][w])

Measured memory_bytes: 171912
H,W,K=[int(s) for s in input().split()]
ls=[input() for i in range(H)]
ans=[[] for i in range(H)]
num=1
s=[] ##イチゴがあるかないか
for i in range(H):
  if '#' in ls[i]:
    s.append(1)
    p=0
    for j in range(W):
      if ls[i][j]=='#':
        if p==0:
          p=1
        else:
          num+=1
      ans[i].append(num)
    num+=1
  else:
    s.append(0)
for i in range(H):
  if s[i]==0:
    for k in range(1,H):
      if i+k>=H: break
      if s[i+k]==1:
        ans[i]=ans[i+k]
        break
for i in range(1,H):
  if s[-i]==0:
    for k in range(1,H):
      if i+k>H: break
      if s[-i-k]==1:
        ans[-i]=ans[-i-k]
        break
  else:
    break
for i in range(H):
  print(*ans[i])
  

Measured memory_bytes: 45404
s = input()
dp = []
n = len(s)
mod = 10 ** 9 + 7
dp = [[] for _ in range(n + 1)]
for i in range(n + 1):
    for j in range(4):
        dp[i].append(0)
dp[0][0] = 1
for i in range(n):
    for j in range(4):
        dp[i + 1][j] += dp[i][j] % mod
        if s[i] == "?":
            dp[i + 1][j] += dp[i][j] * 2 % mod
    if s[i] == "A":
        dp[i + 1][1] += dp[i][0] % mod
    elif s[i] == "B":
        dp[i + 1][2] += dp[i][1] % mod
    elif s[i] == "C":
        dp[i + 1][3] += dp[i][2] % mod
    elif s[i] == "?":
        dp[i + 1][1] += dp[i][0] % mod
        dp[i + 1][2] += dp[i][1] % mod
        dp[i + 1][3] += dp[i][2] % mod

print(dp[n][3] % mod)

Measured memory_bytes: 28596
import java.util.Scanner;

/**
 * Created by Harry on 3/31/20.
 */
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] weight = new int[n];
        int[] value = new int[n];
        for(int i=0; i<n; i++){
            weight[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }
        System.out.print(findMaxValue(n, w, weight, value));
    }

    public static long findMaxValue(int n, int w, int[] weight, int[] value){
        long[] dp = new long[w+1];
        for(int i=0; i<n; i++){
            for(int j=w; j>=weight[i]; j--){
                dp[j] = Math.max(dp[j], dp[j-weight[i]]+value[i]);
            }
        }
        return dp[w];
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
#include<vector>
using namespace std ;
typedef long long ll;

// N K
// A_1, ..., A_N
int main(){
  string S ;
  cin >> S ;
  int a, b, c, d;

  a = S[0] - '0' ;
  b = S[1] - '0' ;
  c = S[2] - '0' ;
  d = S[3] - '0' ;

  for(int i=0; i<2; ++i){
    for(int j=0; j<2; ++j){
      for(int k=0; k<2; ++k){
        int sum = a ;
        char opt1 ;
        char opt2 ;
        char opt3 ;

        if(i==0){
          sum += b ;
          opt1 = '+';
        }else{
          sum -= b ;
          opt1 = '-';
        }

        if(j==0){
          sum += c ;
          opt2 = '+';
        }else{
          sum -= c ;
          opt2 = '-';
        }

        if(k==0){
          sum += d ;
          opt3 = '+';
        }else{
          sum -= d ;
          opt3 = '-';
        }

        if(sum==7){
          cout << a << opt1 << b << opt2 << c << opt3 << d << "=7" << endl ;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int ll
typedef long long ll;
const int N=2e5+5;
ll ma[N*4];
int n,q;

void update(int l,int r,int id,int i,int v){
    if(l==r){
        ma[id]=v;
        return;
    }
    int mid=(l+r)>>1;
    ma[id]=0;
    if(i<=mid)update(l,mid,id*2,i,v);
    else update(mid+1,r,id*2+1,i,v);
    if(ma)
    ma[id]=max(ma[id*2],ma[id*2+1]);
}
/*
ll query_mi(int l,int r,int ql,int v,int id){
    if(r<ql)return -1;
    if(l==r){
        if(ma[id]>=v)return l;
        else return -1;
    }
    int mid=(l+r)>>1;
    int ans=-1;
    if(ql<mid)ans=query_mi(l,mid,ql,v,id*2);
    if(ans!=-1)return ans;
    ans=query_mi(mid+1,r,ql,v,id*2+1);
    return ans;
}
*/vector<int> a;
ll mi(int x,int v){
    for(int i=x;i<=n;i++){
        if(a[i]>=v)return i;
    }
    return n+1;
}
/*
ll query_ma(int l,int r,int ql,int qr,int id){
    if(l>qr||r<ql)return -1;
    if(l>=ql&&r<=qr)return ma[id];
    int mid=(l+r)>>1;
    if(ql<mid)query_ma(l,mid,ql,qr,id*2);
    if(qr>mid)query_ma(mid+1,r,ql,qr,id*2+1);
    ma[id]=max(ma[id*2],ma[id*2+1]);
    return ma[id];
}
*/
ll query_ma(int l,int r,int ql,int qr,int id){
    if(l>=ql&&r<=qr)return ma[id];
    int mid=(l+r)>>1;
    int ret=0;
    if(qr<=mid){
        ret=max(ret,query_ma(l,mid,ql,qr,id*2));
    }
    else if(ql>=mid+1){
        ret=max(ret,query_ma(mid+1,r,ql,qr,id*2+1));
    }
    else{
        int a=query_ma(l,mid,ql,qr,id*2),b=query_ma(mid+1,r,ql,qr,id*2+1);
        ret=max(a,b);
    }
    return ret;
}
signed main(){
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);

    cin>>n>>q;
    a.resize(n+1);
    for(int i=1;i<=n;i++){
        int x;cin>>x;
        a[i]=x;
        update(1,n,1,i,x);
    }
    while(q--){
        int mode,x,y;cin>>mode>>x>>y;
        if(mode==1){
            update(1,n,1,x,y);
            a[x]=y;
        }
        else if(mode==2){
            cout<<query_ma(1,n,x,y,1)<<endl;
        }
        else if(mode==3){
            /*
            ll ans=query_mi(1,n,x,y,1);
            if(ans==-1)cout<<n+1<<endl;
            else cout<<ans<<endl;
            */
            cout<<mi(x,y)<<endl;
        }
    }
}


Measured memory_bytes: 8992
#include<iostream>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N,M;
main()
{
	cin>>N>>M;
	int ans=1;
	UF uf(N);
	for(int i=0;i<M;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		uf.unite(a,b);
		int now=uf.size(a);
		if(ans<now)ans=now;
	}
	cout<<ans<<endl;
}

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

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

	cin >> a >> b >> c;

	if (a > b) {
	d=a;
	a=b;
	b=d;
	}
	if (b > c) {
		d=b;
		b=c;
		c=d;
	}
	if (a > b) {
		d=a;
		a=b;
		b=d;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;

}


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

using namespace std;

using ll = long long;


class segment_tree {
    public:
        ll size;
        vector<ll> arr;

        segment_tree(ll size);
        void add(ll i, ll x);
        ll get_sum(ll s, ll t);
        ll get_sum_sub(ll s, ll t, ll k, ll x, ll y);
};


segment_tree::segment_tree(ll size)
{
    ll n = 1;
    while (n < size)
        n *= 2;
    this->size = n;
    arr.resize(n * 2, 0);
}


void segment_tree::add(ll i, ll x)
{
    ll now = i + size - 1;
    arr[now] += x;

    while (now > 0) {
        now = (now - 1) / 2;
        arr[now] += x;
    }
}


ll segment_tree::get_sum_sub(ll s, ll t, ll k, ll x, ll y)
{
    if (y <= s || t <= x)
        return 0;
    else if (s <= x && y <= t) {
        return arr[k];
    } else {
        ll l, r;
        l = get_sum_sub(s, t, k * 2 + 1, x, (x + y) / 2);
        r = get_sum_sub(s, t, k * 2 + 2, (x + y) / 2, y);
        return l + r;
    }
}


ll segment_tree::get_sum(ll s, ll t)
{
    return get_sum_sub(s, t, 0, 0, size);
}


int main() {
    ll n, q;
    cin >> n >> q;
    segment_tree sg(n);
    for (ll i = 0; i < q; i++) {
        ll c, x, y;
        cin >> c >> x >> y;
        switch(c) {
            case 0:
                sg.add(x - 1, y);
                break;
            case 1:
                ll tmp = sg.get_sum(x - 1, y);
                cout << tmp << endl;
                break;
        }
    }
}



Measured memory_bytes: 4932
w[]={5,7,5,7,7};char s[40][12];i,j,a,c,f;
main(n)
{
	for(;i=scanf("%d\n",&n)*n;printf("%d\n",n))
	{
		for(i=0;i++<n;gets(s[i]));
		for(i=0;i<n;n=f?n:i)for(a=c=f=0,j=i++;j++<n&&c<5;a>w[c]?f=1:a==w[c]?a-=w[c++]:0)a+=strlen(s[j]);
	}
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

const int MAX_N = 10010;
using TYPE = long long; // ?????¢???????????\??????
vector<pair<int, TYPE> > G[MAX_N];
vector<TYPE> dijkstra(int start){
	vector<TYPE> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=???start->i?????§??????????????¢
	priority_queue<pair<TYPE, int>, vector<pair<TYPE, int> >, greater<pair<TYPE, int> > >  que;
	que.push(make_pair(0, start));
	while(!que.empty()){
		TYPE cost; int u;//????????§???????????£????????? ?????¨?????????
		cost = que.top().first, u = que.top().second;
		que.pop();
		if(dist[u] < cost) continue;
		for (auto tmp : G[u]){
			int v = tmp.first; TYPE time = tmp.second;//??£??\???????????? ?????????????????§????????????
			if(dist[v] > dist[u] + time){//u->v
				dist[v] = dist[u] + time;
				que.push(make_pair(dist[v], v));
			}
		}
	}
	return dist;
}

int main(void) {
	while(1) {
		int N, M; scanf("%d %d", &N, &M);
		if(N == 0 && M == 0) break;
		rep(i, MAX_N) G[i].clear();

		int u[20010], v[20010], d[20010], c[20010];
		rep(i, M) scanf("%d %d %d %d", &u[i], &v[i], &d[i], &c[i]);
		rep(i, M) u[i]--, v[i]--;

		map<pair<int, int>, int> ma;

		rep(i, M) G[u[i]].pb(mp(v[i], d[i])), G[v[i]].pb(mp(u[i], d[i]));
		rep(i, M) ma[make_pair(u[i], v[i])] = c[i], ma[make_pair(v[i], u[i])] = c[i];
		auto dist = dijkstra(0);

		ll ans = 0;
		reps(v, 1, N) { // 0->v ?????§???????????????
			ll mi = INFF;
			for(auto t : G[v]) {
				int u = t.fi, d = t.se;
				int cost = ma[make_pair(u, v)];
				if(dist[v] == dist[u] + d){
					chmin(mi, cost);
				}
			}
			ans += mi;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

int main() {
    /*ll n,m;
    cin >>n>>m;
    vector<ll> a;
    for(ll i=0;i<n;i++) {
        ll tmp;
        cin >>tmp;
        a.push_back(tmp);
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<m;i++) {
        ll b,c;
        cin>>b>>c;
        for(ll j=0;j<b;j++) {
            if(a[j]>=c)break;
            a[j]=c;
        }
        sort(a.begin(),a.end());
    }
    ll sum=0;
    for(ll i=0;i<n;i++) {
        sum+=a[i];
    }
    cout<<sum<<endl;*/
    ll n,m;
    cin >>n>>m;
    ll min=1;
    ll max=n;
    for(ll i=0;i<m;i++) {
        ll q,w;
        cin >>q>>w;
        if(q>min)min=q;
        if(w<max)max=w;
    }
    if(max>=min) {
        cout <<max-min+1<<endl;
    }else{
        cout <<0<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,T;
  cin >> N >> T;
  
  vector<int>c(N);
  vector<int>t(N);
  int M = 1000;
  int m = 0;
  for (int i = 0; i < N; i++) {
    cin >> c.at(i) >> t.at(i);
    if (T >= t.at(i) && M >= c.at(i)){
      M = c.at(i);
      m++;
    }
  }
  if (m == 0){
    cout << "TLE" << endl;
    return 0;
  }
  cout << M << endl;
}

  
  
 

Measured memory_bytes: 3596
import math
a,b,c=map(int,input().split())
#if ((a + b + (2 * math.sqrt(a*b))) < c):
#  print("Yes")
#else:
#  print("No")
if (((c-a-b) >= 0) and (4*a*b < ((c-a-b)*(c-a-b)) )):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	_ = readLine()
	astr := strings.Split(readLine(), " ")

	var a []int
	var ncount int

	for _, v := range astr {
		avalue, _ := strconv.Atoi(v)
		a = append(a, avalue)
		if avalue < 0 {
			ncount++
		}
	}

	var ans int

	if ncount%2 == 0 {
		for _, v := range a {
			if v < 0 {
				ans += -v
			} else {
				ans += v
			}
		}
	} else {
		amin := 1000000000
		var aminindex int
		for i, v := range a {
			if amin > int(math.Abs(float64(v))) {
				amin = int(math.Abs(float64(v)))
				aminindex = i
			}
		}
		for i, v := range a {
			if i == aminindex {
				if v > 0 {
					ans += -v
				} else {
					ans += v
				}
			} else {
				if v < 0 {
					ans += -v
				} else {
					ans += v
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7936
/*input
WED
*/
#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;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=100000000;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b,ll MOD){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
string arr[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main(){
    string s;
    cin>>s;
    REP(i,7) if(arr[i]==s){
        int ans=1;
        i=(i+1)%7;
        while(arr[i]!="SUN"){
            ++ans;
            i=(i+1)%7;
        }
        cout<<ans;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(x) cout << (x) << "\n";
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n";
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i];
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n)
    Cins(int, n, as);
    Cusum(ll, n, as, sas);

    int l = 1, r = 3;
    ll ans = 1e15;
    for(int c = 2; c <= n-2; c ++){
        while(l+1 < c && abs((sas[l+1] - sas[0]) - (sas[c] - sas[l+1])) < abs((sas[l] - sas[0]) - (sas[c] - sas[l]))) l ++;
        while(r+1 < n && abs((sas[r+1] - sas[c]) - (sas[n] - sas[r+1])) < abs((sas[r] - sas[c]) - (sas[n] - sas[r]))) r ++;
        vector<ll> ts {sas[l] - sas[0], sas[c] - sas[l], sas[r] - sas[c], sas[n] - sas[r]};
        Sort(ts);
        ans = min(ans, ts[3] - ts[0]);
    }
    Cout(ans);
}


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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int a_max = 0;
            for(var i=0;i<N;i++){
                a_max = Math.Max(a_max,a[i]);
            }
            int[] count = new int[a_max+1];
            for(var i=0;i<N;i++){
                count[a[i]]++;
            }
            int max_X = 0;
            for(var i=1;i<a_max;i++){
                int sum = count[i-1] + count[i] + count[i+1];
                max_X = Math.Max(sum,max_X);
            }
            max_X = Math.Max(count[0],max_X);
            max_X = Math.Max(count[a_max],max_X);
            Console.WriteLine(max_X);
        }
    } 
}

Measured memory_bytes: 19296
import sys
sys.setrecursionlimit(1000000)
from operator import itemgetter

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

A=sorted(A,key=itemgetter(1))
cnt = 0
bridge = 0

for i in range(M):
    #print(i,A[i][0])
    if A[i][0] > bridge:# or A[i][1] < bridge:
        cnt += 1
        bridge = A[i][1] - 1
        
print(cnt)

Measured memory_bytes: 29916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x, n, p[102], vis[110];
  memset(vis, 0, sizeof vis);
  cin >> x >> n;
  for(int i=0; i<n; i++){
    cin >> p[i];
    vis[p[i]] = 1;
  }
  for(int i=0; i<=108; i++) {
    if(!vis[x-i]){
      cout << x-i;
      return 0;
    }
    if(!vis[x+i]){
      cout << x+i << '\n';
      return 0;
    }

  }
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll memo[1000][1000];
int H, W;
char a[1000][1000];
const int mod = 1000000007;

ll dp() {
	REP(i, H) {
		REP(j, W) {
			if (i == 0 && j == 0) memo[i][j] = 1;
			else if (a[i][j] == '.') {
				if (j > 0 && memo[i][j - 1]) memo[i][j] += memo[i][j - 1];
				if (i > 0 && memo[i - 1][j]) memo[i][j] += memo[i - 1][j];
			}
			memo[i][j] %= mod;
		}
	}
	return memo[H - 1][W - 1];
}

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

	cin >> H >> W;
	REP(i, H)REP(j, W) cin >> a[i][j];
	cout << dp() << "\n";

	
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  string s, t;
  cin >> s >> t;

  int snt = 0;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) ++snt;
  }

  cout << snt << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 3772
N, M = map(int, input().split())
S = []
C = []
for _ in range(M):
    s, c = map(int, input().split())
    S.append(s-1)
    C.append(c)
import sys
for i in range(1000):
    tmp = str(i)
    if len(tmp) != N:
        continue
    flag = True
    for j in range(M):
        if tmp[S[j]] != str(C[j]):
            flag = False
    if flag:
        print(tmp)
        sys.exit(0)
print(-1)

Measured memory_bytes: 39280
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            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()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Integer>[] edges;
	public static long[] fac,inv;
	public static int mod = (int) (1e9+7),MAX = (int) (1e5+1);
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
	
		long a = sc.nextLong();
		long b = sc.nextLong();
		List<Long> diva = getdiv(a);
		List<Long> divb = getdiv(b);
		Set<Long> set = new HashSet<>(diva);
		long ans = 1;
		for(int i=0;i<divb.size();++i) {
			long x = divb.get(i);
			if(set.contains(x)) {
				if(BigInteger.valueOf(x).isProbablePrime(20)) ++ans;
			}
		}
		out.print(ans);
        out.close();
		
	}
	
	
	private static List<Long> getdiv(long n) {
		List<Long> ans = new ArrayList<>();
		long root = (long) Math.sqrt(n);
		for(long i=1;i<=root;++i) {
			if(n%i == 0) {
				if(i != n/i) ans.add(n/i);
				ans.add(i);
			}
		}
		return ans;
	}


	static class Pair implements Comparable<Pair>{
		int u;
		int v;
		int c;
		Pair(int u,int v){
			this.u = u;
			this.v = v;
		}
		@Override
		public int compareTo(Pair arg0) {
			// TODO Auto-generated method stub
			return this.u - arg0.u;
		}
	}
	
}


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

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> h(N+1);

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

  int answer = 0;

  vector<int> dp(N+1);

  fill(dp.begin(), dp.end(), 1000000000);

  dp[1] = 0;

  for (int i = 2; i <= N; i++) {
    for (int j = 1; j <= K && 1 <= i - j; j++) {
      dp[i] = min(dp[i], abs(h[i - j] - h[i]) + dp[i - j]);
    }
  }

  cout << dp[N] << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ; 
#define rep(i,N) for(int i = 0 ; i < (N) ; i++ )

int main() {
  int64_t L , R ; 
  cin >> L >> R ; 
  
  R = min(R , L+2019) ; 
  int ans = 2018 ; 
  for(int64_t i = L ; i <= R ; i++){
    for( int64_t j = i+1 ; j <=R ; j++ ){
      int x = (i*j)%2019 ; 
      ans = min(ans , x) ; 
    }
  }
  
  cout << ans << endl ; 

  return 0 ; 
}

Measured memory_bytes: 3672
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

int main()
{
    priority_queue<double, vector<double>, greater<double>> q;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        double v;
        cin >> v;
        q.push(v);
    }

    while (q.size() > 1)
    {
        double a = q.top();
        q.pop();
        double b = q.top();
        q.pop();
        q.push((a + b) / 2);
    }

    double result = q.top();
    cout << setprecision(20) << result << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		int[] primes = getPrimesTable();
		while(sc.hasNext()){
			int n = sc.nextInt(), sum = 0;
			for(int i = 0; i < n; i++){
				if(primes[i] == 1)
					sum++;
			}
			System.out.println(sum);
		}
	}
	
	int[] getPrimesTable(){
		int max = 999999;
		int[] primes = new int[max];
		for(int i=0;i<max;i++)
			primes[i] = 1;
		
		primes[0] = 0;
		
		for(int i = 1; i<max ; i++){
			if(primes[i] == 1){
				for(int j = 2; (i+1)*j <= max; j++){
					primes[(i+1)*j-1] = 0;
				}
			}
		}
		
		return primes;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 24376
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const long INF = 1000000007;
    public static void Main()
    {
        int[] n = IntLine();
        if ((n[0] * n[1]) % 2 == 0) Console.WriteLine("No");
        else Console.WriteLine("Yes");
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 11348
using System;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] str = line.Split(' '); 
            int N = int.Parse(str[0]);
            int A = int.Parse(str[1]);
            int B = int.Parse(str[2]);

            int ans1;
            int ans2;

            if (A >= B)
            {
                ans1 = B;
            }
            else
            {
                ans1 = A;
            }

            var sum = A + B;

            if (sum - N >= 0)
            {
                ans2 = sum - N;
            }
            else
            {
                ans2 = 0;
            }

            Console.WriteLine("{0} {1}", ans1, ans2);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll N,A,B,ans=0;
  cin >> N >> A >> B;
  int X[N];
  FOR(i,0,N)cin >> X[i];
  FOR(i,0,N-1){
    ans += min(A*(X[i+1]-X[i]),B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int ans = INF;
    for (int i = 1; i <= 5; i++) {
        int x; cin >> x;
        if (x == 0) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
int w, h;
int kw, kh;
bool field[100][100];

int main() {
	while (cin >> n&&n) {
		rep(i, 100)rep(j, 100)field[i][j] = 0;
		cin >> w >> h;
		rep(i, n) {
			int x, y;
			cin >> x >> y;
			x--; y--;
			field[y][x] = 1;
		}
		cin >> kw >> kh;
		int ans = 0;
		rep(i, h - kh+1) {
			rep(j, w - kw+1) {
				int sum = 0;
				for (int y = i; y < i + kh; y++) {
					for (int x = j; x < j + kw; x++) {
						sum += field[y][x];
					}
				}
				ans = max(ans, sum);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3084
import sys
from pprint import pprint

def solve(a, b):
    ans = 0
    emp = 1
    while emp < b:
        emp += a - 1
        ans += 1
    print(ans)

if __name__ == '__main__':
  a, b = map(int, sys.stdin.readline().strip().split(" "))
  solve(a, b)


Measured memory_bytes: 38256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        static final long inf = (long) 1e17;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int x = Integer.parseInt(in.next());
            int[] c = new int[n];
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                c[i] = Integer.parseInt(in.next());
                for (int j = 0; j < m; j++) {
                    a[i][j] = Integer.parseInt(in.next());
                }
            }
            long ans = inf;

            for (int bit = 0; bit < (1 << n); ++bit) {
                long cost = 0;
                long[] skill = new long[m];
                for (int i = 0; i < n; ++i) {
                    if ((bit & (1 << i)) == 0) {
                        cost += c[i];
                        for (int j = 0; j < m; j++) {
                            skill[j] += a[i][j];
                        }
                    }
                    boolean ok = true;
                    for (int j = 0; j < m; j++) {
                        if (skill[j] < x) ok = false;
                    }
                    if (ok) ans = Math.min(ans, cost);
                }
            }

            if (ans == inf) {
                // 出力
                out.println(-1);
            } else {
                out.println(ans);
            }

        }

    }
}



Measured memory_bytes: 37588