akhauriyash/Code-Regression huggingface dataset:
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces_279B
//o(n * log(n))
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.lang.Math.*;
import java.math.*;

public class Main{

	static PrintWriter go = new PrintWriter(System.out);
	
	public static void main(String args[]) throws IOException,FileNotFoundException {
		BufferedReader gi = new BufferedReader(new InputStreamReader(System.in, "ISO-8859-1"));
		int[] l = parseArray(gi);
		int n = l[0];
		int m = l[1];
		int[][] jobs = new int[n][];
		for ( int k = 0; k < n; k++ ){
			jobs[k] = parseArray(gi);
		}
		Arrays.sort(jobs, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				return a[0] - b[0];
			}
		});
		int ans = 0;
		int cur = 0;
		Queue<pair> q = new PriorityQueue<>();
		for ( int k = 1; k <= m; k++ ){
			while (cur < n && jobs[cur][0] <= k) {
				q.add(new pair(jobs[cur][1], cur));
				cur++;
			}
			if (!q.isEmpty()) ans += q.poll().x;
		}
		go.println(ans);
		go.close();
	}

	static class pair implements Comparable {
		public int x, y;
		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(Object p) {
			return ((pair)p).x - this.x;
		}
	}

	static int[] parseArray(BufferedReader gi) throws IOException{
		String[] line = gi.readLine().split(" ");
		int[] rez = new int[line.length];
		for ( int k = 0; k < line.length; k++){
			rez[k] =  Integer.parseInt(line[k]);
		}
		return rez;
	}

}



Measured memory_bytes: 48236
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif
}
int n;
char s[N];
void input()
{
	scanf("%s",s+1);
	n=strlen(s+1);
}
int last[30],num[30];
void work()
{
	int x;
	For(i,1,n)
	{
		x=s[i]-'a';
		cmax(num[x],i-last[x]-1);
		last[x]=i;
	}
	For(i,0,25)cmax(num[i],n-last[i]);
	write(*min_element(num,num+26),'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        if(B==1){
            System.out.println(0);
        }
        else{
            for(int i=1; i<B; i++){
                if((A-1)*(i-1)+A>=B){
                    System.out.println(i);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int ans = 0;
    M = 2*M+1;
    if((N+M)%M == 0){
        cout << (N+M)/M-1 << endl;
        return 0;
    }
    cout << (N+M)/M << endl;
}

Measured memory_bytes: 256
N = int(input())
q = [sorted(list(map(int, input().split()))) for _ in range(N-1)]

ans = 0

for i in range(1, N+1):
    ans += i * (N - i + 1)
for qi in q:
    u, v = qi[0], qi[1]
    ans -= u * (N - v + 1)

print(ans)


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

int main(){
    int n, h, w, a[1001], b[1001];
    cin >> n >> h >> w;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] >= h && b[i] >= w) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
L = [int(x) for x in input().split()]

D = [0]*(n+1)
for i in range(n):
    D[i+1] = D[i]+L[i]
    if D[i+1] > x:
        print(i+1)
        break
    if i == n-1:
        print(n+1)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a, b , c, d; cin >> a >> b >> c >> d;
  ll time = c * 60 + d - a * 60 - b;
  ll k; cin >> k;
  ll ans = time - k;
  cout << ans << endl;


}


Measured memory_bytes: 3624
import sys
import numpy as np 

n = int(sys.stdin.readline().rstrip())
graph = [None] * n
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    if not a: continue
    graph[i] = np.array([sys.stdin.readline().split() for _ in range(a)], dtype=np.int16).T

def main():
    comb = (np.arange(1 << n)[:, None] >> np.arange(n) & 1).astype(np.bool)
    ok = np.full(1 << n, True, dtype=np.bool)
    for i in range(n):
        if graph[i] is None: continue
        x, y = graph[i]
        ok &= ~comb[:, i] | np.all(comb[:, x-1] == y.astype(np.bool), axis=1)

    print(np.amax(comb[ok].sum(axis=1)))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 20196
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void solve() {
    int n, m;
    vector <int> t(n);
    int pi,xi;

    cin >> n;
    int sum = 0;
    for (int i=0; i < n; ++i) {
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    for (int i=0; i < m; ++i) {
        cin >> pi >> xi;
        cout << (sum - t[pi-1] + xi) << endl;
    }

}

int main() {

    solve();
    return 0;
}


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

struct Data{
  string name;
  int page;

  bool operator < (const Data &data)const{
    if(name==data.name){
      if(page<data.page) return true;
      else return false;
    }else{
      if(name<data.name) return true;
      else return false;
    }
  }
};

int main(){

  Data a[110];
  string s;
  int n, i=0;

  while(cin>>s>>n){
    a[i]=(Data){s, n};
    i++;
  }

  sort(a, a+i);

  string key="";

  n=i;
  for(i=0;i<n;i++){
    if(key!=a[i].name){
      key=a[i].name;
      if(i>0){
	cout<<endl;
      }
      cout<<key<<endl;
      cout<<a[i].page;
    }else{
      cout<<" "<<a[i].page;
    }
  }

  cout<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int64_t L0 =2, L1=1, L2;
    int count;

    cin >> count;

if(count == 1){
    cout << L1 << endl;
}else{
    for (size_t i = 2; i < count + 1; i++)
    {
        L2 = L0 + L1;
        L0 = L1;
        L1 = L2;
    }
    cout << L2 << endl;
}
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << x << endl;

// template starts
typedef long long int ll;

// template ends here

// TO ADD: LCA, Dijkstra's

ll N, M; // no of vertices and no of edges
vector<vector<pair<int,int>>> adj;
vector<bool> vis;
vector<ll> dist;
vector<ll> tin,tout;
ll T_of_tin= 0;

void resizeAll(){
	vis.clear();
	dist.clear();
	adj.clear();
	tin.clear();
	tout.clear();
	
	vis.resize(N);
	dist.resize(N);
	adj.resize(N);
	tin.resize(N);
	tout.resize(N);
	
	for(int i = 0; i < N; i++){
		vis[i] = false;
		dist[i] = 1e7;
	}
}

int N2, M2;
int startx,starty,endx,endy;
vector<string> g;
int ans = INT_MAX;

bool valid(int i, int j){
	if(i < 0 || j < 0 || i >= N2 || j >= M2) return false;
	return g[i][j] != '#';
}
// IMPORTANT: Everything here is 0 based index!!!!

int dij(){
	set<pair<int,int>> s;
	int start = startx*M2 + starty;
	
	dist[start] = 0;
	s.insert(mp(0,start));
	
	while(s.size() > 0){
		auto p  = *s.begin();
		s.erase(s.begin());
	
		
		int node = p.second;
		int d = p.first;
		
			//debug(node);
			
		for(int i = 0; i < (int)adj[node].size(); i++){
			int child = adj[node][i].first;
			int w = adj[node][i].second;
			
			if(dist[child] > w+d){
				dist[child] = w+d;
				s.insert(mp(dist[child],child));
			}
		}
	}
	
	if(dist[endx*M2+endy] >= 1e7) return -1;
	else return dist[endx*M2+endy];
}
void solve(){
	// code starts from here
	
	
	cin >> N2 >> M2 >> startx >> starty >> endx >> endy;
	
	startx--;starty--;
	endx--;endy--;
	g.resize(N2);
	
	input(g,N2);
	
	N = N2*M2;
	resizeAll();
	
	for(int i = 0; i < N2; i++){
		for(int j = 0; j < M2; j++){
			if(g[i][j] == '#') continue;
			for(int k = -2; k < 3; k++){
				for(int l = -2; l < 3; l++){
					if(k == 0 && l == 0) continue;
					
					//if(i == 2 && j == 2){
						//debug(k);
						//debug(l);
						//cout << valid(i+k,j+l) << endl;
						//cout << endl;
					//}
					if(!valid(i+k,j+l)) continue;
					
					int w = 1;
					if(k*l == 0 && (abs(k) == 1 || abs(l) == 1)) w= 0;
					adj[i*M2+j].pb(mp((i+k)*M2+j+l,w));
				}
			}
		}
	}
	
	//for(int i = 0; i < N; i++){
		//cout << i << ": ";
		//for(int j = 0; j < (int)adj[i].size(); j++){
			//cout << "(" << adj[i][j].first << "," << adj[i][j].second<< ")" << " "; 
		//}
		//cout << endl;
	//}
	
	cout << dij() << endl;
	
	// thing to remember:
	// Make sure everything is zero based indexing
	// Make sure to check each component of the graph
	// Memory overflow. Try making ll to int
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 121316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();

		if(str.charAt(0) != str.charAt(1) && str.charAt(1) != str.charAt(2)) {
			if(str.charAt(0) != str.charAt(2)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23892
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    if(s[5]=='1') cout<<"TBD";
    else{
        if(s[6]<='4'){
            cout<<"Heisei";
        }else if(s[6]>'4') cout<<"TBD";
    }
}

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

N = int(input())

piv = 0
while True:
    if 26*(26**piv-1)/25 >= N:
        break
    piv += 1
N -= 26*(26**(piv-1)-1)/25 + 1
for i in reversed(range(piv)):
    x = int(N//(26**i)%26)
    print(chr(x+97), end='')
print()


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, a, b;
    cin >> n >> a >> b;
    ll g = n/(a+b);
    n -= g*(a+b);
    ll res = g*a;
    res += min(a, n);
    cout << res;
    return 0;
}


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

using namespace std;
int vis[10];
int judge(int x)
{
    while(x>0)
    {
        int num=x%10;
        x/=10;
        if(vis[num]==1)return 0;
    }
    return 1;
}
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        int x;
        cin>>x;
        vis[x]=1;
    }
    for(int i=n;;i++)
    {
        if(judge(i)==1)
        {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll unsigned long long
#define all(a) (a).begin(),(a).end()

using namespace std;
ll gcd(ll,ll);

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d",&N);
  std::vector<ll> v(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> v[i];
  }
  sort(all(v));

  ll lcm=v[0];
  for (size_t i = 1; i < N; i++) {
    ll temp=gcd(lcm,v[i]);
    lcm=lcm/temp*v[i];
    //printf("%lld %lld\n",temp,lcm);
  }

  printf("%llu\n",lcm);
  return 0;
}

ll gcd(ll a,ll b){
  if(a<b){
    ll tmp=a;
    a=b;
    b=tmp;
  }

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


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0012&lang=jp
//????§£?????????

#include<iostream>
#include<complex>
using namespace std;

typedef complex<double> xy_t;

double cross(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
double x[4], y[4];
int main()
{
    while (true) {
        for (int i = 0; i < 4; i++) {
            cin >> x[i] >> y[i];
        }
        if (!cin)break;
        xy_t a(x[0], y[0]), b(x[1], y[1]), c(x[2], y[2]), p(x[3], y[3]);
        double pab=cross(a - p, b - p);
        double pbc=cross(b - p, c - p);
        double pca=cross(c - p, a - p);
        if (abs(pab - pbc) < abs(pab + pbc) &&
            abs(pbc - pca) < abs(pbc + pca) &&
            abs(pca - pab) < abs(pca + pab))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <cstdio>

using namespace std;

int main()
{
	for(int t,e;~scanf("%d%d",&t,&e);){
		double c[2*t+1];
		for(int i=0;i<2*t+1;i++)
			scanf("%lf",c+i);
		for(int s=2;s<=t;s++){
			if(c[t+(t-s+1)]>c[t+(t-s+2)])
				c[t+(t-s+1)]=(c[t+(t-s+1)]+(s-1)*c[t+(t-s+2)])/s;
			if(c[t-(t-s+1)]>c[t-(t-s+2)])
				c[t-(t-s+1)]=(c[t-(t-s+1)]+(s-1)*c[t-(t-s+2)])/s;
		}
		if(c[t]>c[t-1]+c[t+1])
			c[t]=(c[t]+t*(c[t-1]+c[t+1]))/(t+1);
		printf("%.13f\n",e/c[t]);
	}
}

Measured memory_bytes: 2640
#include<stdio.h>

void BubleSort(int w[],int n,char W[]){
	
	int i,j,t,count,cp;
	char c;
	
	count=0;
	t=0;
	
	for(j=0; j<n; j++){
		for(i=n-1; i>=1; i--){
			if(w[i] < w[i-1]){
				cp = w[i-1];
				c  = W[i-1];
				
				w[i-1] = w[i];
				W[i-1] = W[i];
				
				w[i] = cp;
				W[i] = c;
				
				count++;
		    }
		}
	}
	
	for(i=0; i<n; i++){
		printf("%c%d",W[i],w[i]);
		if(i != n-1){
			printf(" ");
		}
	}
	printf("\n");
	
	
}

void SelectionSort(int w[],int n,char W[]){
	
	int i,j,s,count,min;
	char c;
	
	count=0;
	min=100;
	
	
	for(j=0; j<n-1; j++){
		for(i=j; i<n; i++){
			if(w[i] < min){
				min = w[i];
				c   = W[i];
				
				s=i;
			}
		}
		
		if(s != j){
			w[s]=w[j];
			W[s]=W[j];
			
			w[j]=min;
			W[j]=c;
			
			count++;
		}
		min = 100;
	}
	
	for(i=0; i<n; i++){
		printf("%c%d",W[i],w[i]);
		if(i != n-1){
			printf(" ");
		}
	}
	printf("\n");
	
}

int main(void){
	
	int i, n, N[36];
	char M[36];
	
	int N2[36];
	char M2[36];
	
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
	scanf(" %c%d",&M[i],&N[i]);
		M2[i]=M[i];
		N2[i]=N[i];
		
	}
	
	BubleSort(N,n,M);
	printf("Stable\n");
	
	SelectionSort(N2,n,M2);
	
	for(i=0; i<n; i++){
		if(M[i] != M2[i]){
			printf("Not stable\n");
			break;
		}
	if(i == n-1) printf("Stable\n");
	}
	
		
	return 0;
}





Measured memory_bytes: 2092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vector<ll> v(4005,0);
    vi e(n);
    rep(i,n){
      ll p,q;
      cin>>e[i]>>p>>q;
      v[e[i]]+=p*q;
    }
    vector<bool> used(4005,true);
    rep(i,n)
      if(v[e[i]]>=1000000 && used[e[i]]){
        cout<<e[i]<<endl;
        used[e[i]]=false;
        used[0]=false;
      }
    if(used[0])cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,T,Ans=0;
    int t[214514];
    cin >> N >> T;
    REP(i,N){
        cin >> t[i];
    }
    REP(i,N-1){
        Ans+=min(t[i+1]-t[i],T);
    }
    cout<<Ans+T<<Endl;
    return 0;
}   



Measured memory_bytes: 1792
// E - Red and Green Apples
#include <bits/stdc++.h>
using namespace std;
#define allr(x) (x).rbegin(),(x).rend()

int main(){
	int X, Y, A, B, C; cin>>X>>Y>>A>>B>>C;
	vector<int> E(A);
	while(A--) cin>>E[A];
	sort(allr(E));
	E.resize(X+B);
	while(B--) cin>>E[X+B];
	sort(E.begin()+X, E.end(), greater<int>());
	E.resize(X+Y+C);
	while(C--) cin>>E[X+Y+C];
	sort(allr(E));
	cout<< accumulate(E.begin(), E.begin()+X+Y, 0LL) <<endl;
}

Measured memory_bytes: 2040
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int K = cin.nextint;
        if (N % K == 0)
        {
            WriteLine(0);
        }
        else
        {
            WriteLine(1);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long int i64;
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(__attribute__((unused)) istream_iterator<string> it) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, K;
  cin >> N >> K;
  using ld = long double;
  ld ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i >= K) {
      ans += 1;
    } else {
      ld add = 1;
      int j = i;
      while (j < K) {
        add *= 0.5;
        j <<= 1;
      }
      ans += add;
    }
  }
  ans /= N;
  cout.precision(15);
  cout << fixed << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int n, x;
int a[100001];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(x);
    ll ans=0;
    FOR(i, 1, n){
        read(a[i]);
        if(a[i]>x){
            ans+=a[i]-x;
            a[i]=x;
        }
    }
    FOR(i, 2, n) if(a[i]>x-a[i-1]){
        ans+=a[i]-x+a[i-1];
        a[i]=x-a[i-1];
    }
    write(ans);
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(A.at(i)-1)==i+1){
      count++;
    }
  }
  cout << count/2 << endl;
} 

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    vector<double> p(n+1);
    p[0] = 0;
    rep(i, n) {
        double num; cin >> num;
        p[i + 1] = p[i] + (num + 1) / 2;
    }

    double max_num = 0;
    rep(i, n - k + 1) {
        max_num = max(p[i + k] - p[i], max_num);
    }

    printf("%.12f\n", max_num);

    return 0;
}

Measured memory_bytes: 1792
/*******************************
Author:galaxy yr
LANG:C++
Created Time:2019年01月25日 星期五 21时24分21秒
*******************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int n,l,t,cnt,st,dis[maxn];
struct ants{
        long long dir,id,loc;
}m[maxn];
int main()
{
  //      freopen("Ants_on_a_circle.in","r",stdin);
//        freopen("Ants_on_a_circle.out","w",stdout);
        cin>>n>>l>>t;
        for(int i=1;i<=n;i++) cin>>m[i].loc>>m[i].dir,m[i].id=i;
        for(int i=1;i<=n;i++) m[i].dir==2?m[i].dir=-1:m[i].dir=1;
        for(int i=1;i<=n;i++)
        {
                dis[i]=m[i].loc+m[i].dir*t;
                if(dis[i]>=l) (cnt+=(dis[i]/l))%=n;
                if(dis[i]<0) (cnt+=(dis[i]+1)/l-1)%=n;
                dis[i]=(dis[i]%l+l)%l;
        }
        cnt=(cnt+n)%n+1;
        sort(dis+1,dis+n+1);
        for(int i=1;i<=n;i++)
        {
                cout<<dis[cnt++]<<endl;
                if(cnt>n)cnt-=n;
        }
        return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main(){ 
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> dp(n,INF);
  dp[0] = 0;
  for (int i = 0; i < n-1; i++) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    if (i+2 < n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int N,Q;
  cin >> N >> Q;
  int c[N];
  int las[N];
  int ans[Q];
  int l[Q];
  int r[Q];
  vector<int> point[500010];
  vector<P> query[500010];
  BIT<int> bit(500010);
  for (int i = 0; i < N; i++) {
    cin >> c[i];
    c[i]--;
    las[i] = -1;
  }
  for (int i = 0; i < N; i++) {
    if (las[c[i]] == -1) {
      las[c[i]] = i;
    } else {
      point[las[c[i]]].push_back(i);
      las[c[i]] = i;
    }
  }
  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
    l[i]--; r[i]--;
    query[l[i]].emplace_back(r[i],i);
  }

  for (int i = 500008; i >= 0; i--) {
    for (int j = 0; j < (int)point[i].size(); j++) {
      bit.add(point[i][j]);
    }
    for (int j = 0; j < (int)query[i].size(); j++) {
      ans[query[i][j].S] = (r[query[i][j].S] - l[query[i][j].S] + 1) - bit.sum(query[i][j].F);
    }
  }

  for (int i = 0; i < Q; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 63896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int main()
{
    int a,b,x;
    cin >> a >> b >> x;
    if (x - a >= 0 && a + b - x >= 0) {
        YES;
    }else{
        NO;
    }
    return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll a, b, c;
ll ret = 0;
vector<ll> v;


void input() {
  IN(a);
  IN(b);
  IN(c);
}

void solve() {
  if ((a < c && c < b) || (b < c && c < a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main(void){
  input();
  solve();
}


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


bool solve(int year,int month,int date){
 	if(year < 2019)
      return true;
  	else if(year > 2019)
      return false;
  	else if(month < 4)
      return true;
  	else if(month > 4)
      return false;
  	else if(date <= 30)
      return true;
  	else
      return false;
}

int main(){
	int year,month,date;
    scanf("%d/%d/%d",&year,&month,&date);
    if(solve(year,month,date)){
    	cout << "Heisei" << endl;
    }else
    	cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<double> x(n), y(n);
    for(int i=0; i<n; ++i){cin >> x[i] >> y[i];}
    vector<int> v(n); for(int i=0; i<n; ++i){v[i] = i;}
    
    double res = 0;
    do{
        double sum = 0;
        for(int i=0; i+1<n; ++i){
            int s = v[i], t = v[i+1];
            double isum = (x[s]-x[t])*(x[s]-x[t]);
            isum += (y[s]-y[t])*(y[s]-y[t]); 
          	isum = sqrt(isum);
          	sum += isum; //cout << isum << endl;
        } 
        
        res += sum;
    }while(next_permutation(v.begin(), v.end()));

    double k = 1;
    for(int i=1; i<=n; ++i){k *= i;}
    res /= k;
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 3852
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    X = int(input())
    dp = [False] * (X+1)
    # dp[i+1] := i円、そのお金で払えますか?
    # dp[i - 100], ... がTrue なら Trueだあ
    MENU = [100,101,102,103,104,105]
    dp[0] = True # 0円は買える
    for i in range(X):
        for v in MENU:
            if i + 1 - v < 0:
                continue
            dp[i+1] |= dp[i+1-v]
    print(1 if dp[X] else 0)
if __name__ == '__main__':
  main()


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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    cout << fixed << setprecision(16);

    ll n, q;
    cin >> n >> q;
    vector<tuple<ll,ll,ll>> ev;
    for(ll i=0; i<n; i++) {
        ll s, t, x;
        cin >> s >> t >> x;
        ev.push_back(make_tuple(s-x, 1, x));
        ev.push_back(make_tuple(t-x, 0, x));
    }
    for(ll i=0; i<q; i++) {
        ll d;
        cin >> d;
        ev.push_back(make_tuple(d, 2, i));
    }

    sort(ev.begin(), ev.end());

    vector<ll> res(q, -1);

    set<ll> s;
    s.insert(5e9);

    for(auto &t: ev) {
        ll a, x;
        tie(ignore, a, x) = t;

        if(a == 2) {
            res[x] = *s.begin();
            if(res[x] == 5e9) res[x] = -1;
        }
        if(a == 1) {
            s.insert(x);
        }
        if(a == 0) {
            s.erase(x);
        }
        
    }
    for(auto &e: res)
        cout << e << endl;
}


Measured memory_bytes: 27620
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    long double sum=0;
    cin>>n>>k;
    vector<long long> P(n);
    vector<double> p(n);
    for(int i=0; i<n; i++){
        cin>>P[i];
        p[i]=P[i]/2.0+0.5;
        
    }
    for(int i=0; i<k; i++){
        sum+=p[i];
    }
    long double ans=sum; 
    int count =0;
    for(int i=k; i<n; i++){
        sum+=p[i]-p[count];
        count++;
        ans=max(ans,sum);
    }
    cout<<fixed<<setprecision(12);
    cout<<ans<<endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  int i;
  vector<int> h(n);
  for(i = 0; i < n; i++){
    cin >> h.at(i);
  }
  
  sort(h.begin(), h.end());
  
  int ans = 1000000009;
  for(i = 0; i < n - k + 1; i++){
    ans = min(ans, h.at(i + k - 1) - h.at(i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
x = list(map(int,list(input())))
n = len(x)
dp = [[0,1] for _ in range(n+1)]
for i in range(n):
    dp[i+1][0] = min(dp[i][0]+x[i],dp[i][1]+10-x[i])
    dp[i+1][1] = min(dp[i][0]+x[i]+1,dp[i][1]+9-x[i])
print(dp[n][0])


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

int main() {
	int L, R;
	cin >> L >> R;
	if (R-L >= 2019) {
		cout << 0 << endl;
	} else {
		int min = 2020;
		for (int i = L; i <= R; i++) {
			for (int j = i+1; j <= R; j++) {
				int r = ((i%2019) * (j%2019)) % 2019;
				min = std::min(min, r);
			}
		}
		cout << min << endl;
	}
}


Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

n,m=nii()

tree=[[] for i in range(n)]
for i in range(m):
  a,b=nii()
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

ans=[-1 for i in range(n)]
ans[0]=1

que=deque()
que.append(0)

while que:
  x=que.popleft()
  for i in tree[x]:
    if ans[i]==-1:
      ans[i]=x
      que.append(i)

if -1 in ans:
  print('No')
else:
  print('Yes')
  for i in ans[1:]:
    print(i+1)

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

int main()
{
    int A, B;
    cin >> A >> B;

    if ((A <= 8) && (B <= 8)) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 2010
const int p=1e9+7;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,K,f[maxn];
void Add(int &x,int y)
{
	x+=y;
	if(x>=p)
		x-=p;
}
int mul(int x,int y)
{
	return 1ll*x*y%p;
}
int fpow(int x,int y)
{
	if(y<0)return 1;
	int res=1;
	while(y)
	{
		if(y&1)
			res=mul(res,x);
		x=mul(x,x);
		y>>=1;
	}
	return res;
}
int main()
{
	read(n,K);
	f[n+1]=1;
	for(int i=1;i<=K;i++)
	{
		for(int j=n;j>=1;j--)
		{
			if(n-j+1>=i)
				Add(f[j],f[j+1]);
			else
				f[j]=0;
		}
	}
	printf("%d\n",mul(f[1],fpow(2,n-K-1)));
    return 0;
}


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

#define sz(s)               (int)s.size()


using namespace std;
int main()
{

	//Rabee_Adel
		string s; cin >> s;
	int l = 0, r = sz(s)- 1;
	int f = 0;
	while (l<r)
	{
		if (s[l] != s[r])f = 1;;
		l++; r--;
	}

	l = 0;	r = ((sz(s) - 1) / 2)-1;
	//cout << l << " " << r << endl;
	while (l <r)
	{
		if (s[l] != s[r])f = 1;
		l++; r--;
	}
	l = ((sz(s) + 3)/2)-1;	r = sz(s) - 1;
//	cout << l << " " << r << endl;
	while (l < r)
	{
		if (s[l] != s[r])f = 1;
			
		l++; r--;
	}
	if (f == 1)cout << "No";
	else
	cout << "Yes";

	 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;
// const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// struct edge {int to, cost;};
// vector<edge> graph[MAX];
// bool visited[MAX];
// int dist[MAX];

int main() {
    // input
    int n, m;
    cin >> n >> m;
    // solve
    vector<bool> ac(n, false);
    vector<int> wa(n, 0);
    int cnt_ac = 0, cnt_wa = 0;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (ac[p]) continue;
        if (s == "AC") {
            ac[p] = true;
            cnt_ac++;
            cnt_wa += wa[p];
        } else if (s == "WA") {
            wa[p]++;
        }
    }
    // output
    printf("%d %d\n", cnt_ac, cnt_wa);
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;cin>>N;
  long long ans=N-1;
  for(long long i=1;i<=sqrt(N)+1;i++){
    if(N%i==0)ans=min(ans,(i-1)+(N/i-1));  
  }
  cout<<ans;
  /*
  Nの因数分解
  
  
  
  */
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[200005];
long long ans;
int main()
{
	cin>>n;
	for (int i=0;i<n;++i) cin>>a[i],a[i]-=i+1;
	sort(a,a+n);
	int b=a[n/2];
	for (int i=0;i<n;++i) ans+=abs(a[i]-b);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
int cnt[9] = {};

signed main(){
	int N;
	cin >> N;
	for (int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		if (1 <= tmp&&tmp <= 399) cnt[0]++;
		else if (400 <= tmp&&tmp <= 799) cnt[1]++;
		else if(800 <= tmp&&tmp <= 1199) cnt[2]++;
		else if (1200 <= tmp&&tmp <= 1599) cnt[3]++;
		else if (1600 <= tmp&&tmp <= 1999) cnt[4]++;
		else if (2000 <= tmp&&tmp <= 2399) cnt[5]++;
		else if (2400 <= tmp&&tmp <= 2799) cnt[6]++;
		else if (2800 <= tmp&&tmp <= 3199) cnt[7]++;
		else if (3200 <= tmp)cnt[8]++;
	}
	int min = 0 , max = 0,now=0;
	for (int i = 0; i < 8; i++){
		if (cnt[i]!=0) now++;
	}
	if (now == 0 && cnt[8] != 0){
		cout << "1" <<" "<<cnt[8]<< endl;
		return 0;
	}
	max = now + cnt[8];
	min = now;
	cout << min <<" "<< max << endl;
}

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

void solve() {
  int n, x, y, dx, dy, tx, ty;
  int buf, dis;
  //FILE *fp = fopen("input", "r");
  fscanf(stdin, "%d", &n);
  while (0 < n--) {
    x = y = tx = ty = dis = 0;
    while (1) {
      fscanf(stdin, "%d %d", &dx, &dy);
      if (dx == 0 && dy == 0) break;
      x += dx;
      y += dy;
      buf = pow(x, 2) + pow(y, 2);
      if (buf > dis) {
        dis = buf;
        tx = x; ty = y;
      } else if (buf == dis && x > tx){
        tx = x; ty = y;
      }
    }
    printf("%d %d\n", tx, ty);
  }
  //fclose(fp);
}

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

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define mid ((s + e) / 2)
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define comp(x) (lower_bound(vec.begin(), vec.end(), x) - vec.begin())
#define lc (v * 2)
#define rc (v * 2 + 1)
long long M = 1e9 + 7;
//>>>>>>>>>>>>>>>>>>>

#define int long long

int a, b;

int lg(int x) {
	for (int j = 61; j >= 0; j--)
		if ((1ll << j) <= x)
			return j;
}

int32_t main() {
//	cout << (1ll << 59) << ' ' << (1ll << 60) - 1 << endl;
	cin >> a >> b;
	if (a == b) {
		cout << 1;
		return 0;
	}
	while (1) {
		int k = lg(b);
		if ((1ll << k) < a) {
			b -= (1ll << k);
			a -= (1ll << k);
		}
		else
			break;
	}
	int k = lg(b);
//	cout << " > " << a << ' ' << b << ' ' << k << endl;
	int l = (1ll << (k + 1)) - ((1ll << k) - a);
//	cout << " L : " << l << endl;
	if (l <= b) {
		cout << (1ll << (k + 1)) - a;
		return 0;
	}
	int t = b - (1ll << k);
	int p = lg(t);
	int r = (1ll << k) + (1ll << (p + 1));
	if (b == (1ll << k))
		r = b + 1;
//	cout << " ? " << t << ' ' << p << ' ' << r << endl;
	cout << r - a + (1ll << (k + 1)) - max(r, l); 

}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
using namespace std;
ll a,b,c,x,y,ans;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>c>>x>>y;
	if(a+b<=2*c)rc(x*a+y*b);
	ans=min(x,y)*c*2;
	if(min(x,y)==x && x<y)ans+=(y-x)*min(2*c,b);
	else if(min(x,y)==y && y<x)ans+=(x-y)*min(2*c,a);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int sum = 0;
    rep(i, n)
    {
        sum += a.at(i);
    }
    int count = 0;
    rep(i, n)
    {
        if (a.at(i) * 4 * m >= sum)
        {
            count++;
        }
    }
    if (count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		// x[i]を加えた時、j枚で合計kである組み合わせ
		long[][] dp = new long[n + 1][n * 50 + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j > 0; j--) {
				for (int k = n * 50; k >= x[i]; k--) {
					dp[j][k] += dp[j - 1][k - x[i]];
				}
			}
		}

		long ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += dp[i][a * i];
		}
		out.println(ans);
		out.flush();
	}

	static int dp(int i, int j) {
		return 1;
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22100
N,M = map(int,input().split())
XY = []
for _ in range(M):
    x,y = map(int,input().split())
    xy = (x,y)
    XY.append(xy)
XY.sort(key = lambda x:x[0]) # x sort

*minY, = range(N)
*maxY, = range(N)

for _,y in XY:
    y0,y1 = y-1, y
    minY[y1] = minY[y0]
    maxY[y0] = maxY[y1]


ans = [maxY[i] - minY[i]+1 for i in range(N)]
print(*ans)


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

using namespace std;

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

#define EACH(i,a) for(auto&i:a)
#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for(ll i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x, vec) is >> x;
    return is;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, N; cin >> A >> B >> N;
    ll ans = linf;
    FOR(C, 1, N+1) FOR(D, 1, N+1) {
        if (C * B % D == 0) {
            ans = min(ans, abs(A - C*B/D));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3172
N,K = gets.split.map &:to_i
Mod = 10**9 + 7

def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def invmod(f, mod)
  powmod(f, mod-2, mod)
end

def factorial(n, mod)
  fs = [1]
  (1..n).each{ |k| fs << (fs[-1] * k) % mod }
  fs
end

# modular-inverse of factorial by mod (assuming prime for every 1..n); O(n * log(mod))
def inv_factorial(n, mod)
  fs = [1]
  f = 1
  (1..n).each{ |k|
    f = f * k % mod
    fs << invmod(f, mod)
  }
  fs
end

def comb(n,r)
  return 0 if r < 0
  return 0 if r > n
  a = $fs[n] * $is[n-r] % Mod * $is[r] % Mod
  $stderr.puts [n,r,a] * " "
  a
end

$fs = factorial(N+1,Mod)
$is = inv_factorial(N+1,Mod)

(1..K).each{ |i|
  blue_sep = i - 1
  blue_fixed = i
  red_sep = i
  red_fixed = i - 1
  p comb(K - blue_fixed + blue_sep, blue_sep) * comb(N - K - red_fixed + red_sep, red_sep) % Mod
}


Measured memory_bytes: 2044
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
 
    int W;
    int H;
    int x;
    int y;
    int r;
     
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (x-r < 0 || x+r > W ||  y-r < 0 || y+r > H) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
        return 0;
}

Measured memory_bytes: 584