akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		Map<Integer,Integer> map = new HashMap<>();
		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if(map.containsKey(x)) {
				map.put(x, map.get(x)+1);
			}else {
				map.put(x, 1);
			}
		}
		int all = map.size();
		int[] a = new int[all];
		int i = 0;
		for(Integer num : map.values()){
			a[i] = num;
			i++;
		}
		Arrays.sort(a);
		long ans = 0;
		for(int j = 0; j < all-k; j++) {
			ans += a[j];
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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

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


Measured memory_bytes: 67796
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  // スペース区切りの整数の入力
	  int N= sc.nextInt();
      int K=sc.nextInt();
      int X=sc.nextInt();
      int Y=sc.nextInt();
	  int Sum=0;
		// 出力
      if (N>=K){
      Sum=K*X+(N-K)*Y;
      }else{
      Sum=N*X;
      }
      System.out.println(Sum);
   }
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
void vshow(int v[], int n)
{
    return;
    rep(i, n)
    {
        cerr << v[i] << (i < n - 1 ? "," : "");
    }
    cerr << endl;
}

int binarySearch(int v[], int n, int t, bool eq)
{
    int r = n;
    int l = -1;
    while (l + 1 != r)
    {
        int med = (r + l) / 2;
        if (v[med] > t || (eq && v[med] == t))
        {
            r = med;
        }
        else
        {
            l = med;
        }
    }
    return r;
}
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    ll ans = 0;
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    rep(i, n)
    {
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    vshow(a, n);
    vshow(b, n);
    vshow(c, n);
    rep(i, n)
    {

        ll acandidate = binarySearch(a, n, b[i], true);
        ll ccandidate = n - binarySearch(c, n, b[i], false);
        dumpl(acandidate);
        dumpl(ccandidate);
        ans += acandidate * ccandidate;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
import java.util.*;
public class Main{
	private static Scanner sc=new Scanner(System.in);
	public static void  main(String[]agrs){
		double x1,x2,x3,y1,y2,y3,x4,y4;
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
		x1=sc.nextDouble();
		y1=sc.nextDouble();
		x2=sc.nextDouble();
		y2=sc.nextDouble();
		x3=sc.nextDouble();
		y3=sc.nextDouble();
		x4=sc.nextDouble();
		y4=sc.nextDouble();
		double a1,a2,b1,b2;
		a1=x2-x1;a2=y2-y1;
		b1=x4-x3;b2=y4-y3;
		double ans1 = Math.abs(a1*b2-a2*b1);
		
		
		if(ans1 <= 1e-10)System.out.println("YES");
		else System.out.println("NO");  
		}
		
	}
}

Measured memory_bytes: 21488
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	int n;
	cin >> n;
	map<int, int>a;
	rep(i, n - 1) {
		int temp;
		cin >> temp;
		a[temp-1]++;
	}
	rep(i, n) {
		cout << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 12960
#include <iostream>
#include <queue>
#include <vector>
 
using namespace std;
 
int main()
{
	string s;
 
	int n;
	int ans = 0;
	cin >> n >> s;
	for (int offset = 1; offset < n; offset++) {
		int m = 0;
		for (int i = 0; i + offset < n; i++)
		{
			if (s[i] == s[i + offset]) {
				m++;
				ans = max(ans, min(offset, m));
			}
			else {
				m = 0;
			}			
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a[5],b[5],i,j,h,bl;

while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
h=0;
for(i=0;i<4;i++){
   if(a[i]==b[i])h++;
   }
bl=0;
for(i=0;i<4;i++){
   for(j=0;j<4;j++){
      if(a[j]==b[i] && i!=j)bl++;
   }
}
printf("%d %d\n",h,bl);
}
return 0;

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<int> w(n);
    ll sum = 0;
    rep(i,n) {
        cin >> w[i];
        sum+= w[i];
    }
    ll s1 = 0,s2 = 0,res = INF ;
    rep(i,n) {
        s1 += w[i];
        s2 = sum - s1;
        res = min(res,abs(s1-s2));
    }
    cout << res << endl;
}


Measured memory_bytes: 384
def printGraph graph
  graph.each do |d|
    p d
  end
end

def isTurn before, size
  before > size
end

def createGraph
  graph = Array.new

  before = -1
  while input = $stdin.gets do
    buf = Array.new
    n = input.chomp.split(",").map(&:to_i)
    (0...n.size).each do |j|
      l = ((t = isTurn(before,n.size)) && j == 0)? nil : ((t)? j - 1 : j)
      r = ((t = isTurn(before,n.size)) && j == n.size - 1)? nil : ((t)? j : j + 1)
      buf << [n[j], l, r , -1]
    end
    before = n.size
    graph << buf
  end

  #中央の行を更新
  line = graph[graph.size / 2]
  line.each do |d|
    d[1] -= 1
    d[2] -= 1
  end
  line[0][1] = nil
  line[line.size - 1][2] = nil
  graph
end

def solve graph
  max = 0
  stack = Array.new
  stack.push([0, 0, 0])

  while ! stack.empty? do
    y, x, sum = stack.pop
    sum += graph[y][x][0]
    if graph[y][x][3] < sum
      graph[y][x][3] = sum
      stack.push([y + 1, graph[y][x][1], sum]) if graph[y][x][1]
      stack.push([y + 1, graph[y][x][2], sum]) if graph[y][x][2]
      unless graph[y][x][1] || graph[y][x][2]
        max = sum if max < sum
      end
    end
  end
  max
end

p solve(createGraph)

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

A.sort()
B.sort()
C.sort()

mem = []
for b in B:
    mem.append(N - bisect.bisect(C,b))

mem2 = [mem[-1]]
for i in reversed(range(N-1)):
    mem2.append(mem2[-1] + mem[i])

ans = 0
for a in A:
    i = bisect.bisect(B,a)
    if i >= N: continue
    ans += mem2[N-1-i]

print(ans)


Measured memory_bytes: 24528
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string a,b;cin>>a>>b;
  int sum=stoi(a+b);
  int p=sqrt(sum);
  string ans="No";
  if(p*p==sum)ans="Yes";
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

n, x = list(map(int, input().split()))
b = list(map(int, input().split()))

a = []
for i in b:
    if i != x:
        a.append(abs(i-x))
print(gcd(a))

Measured memory_bytes: 16284
from itertools import permutations
from math import hypot

n = int(input())
cnt = 0
dis = 0

li = []
for i in range(n):
    x,y = map(int,input().split())
    li.append([x, y])

ptn = list(range(n))

for a in permutations(ptn):
    cnt += 1
    for i, j in zip(a,a[1:]):
        x1, y1 = li[i]
        x2, y2 = li[j]
        dis += hypot(x1-x2, y1-y2)

print(dis/cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
const int N = 1000001;


// array to store inverse of 1 to N
ll factorialNumInverse[N + 1];

// array to precompute inverse of 1! to N!
ll naturalNumInverse[N + 1];

// array to store factorial of first N numbers
ll fact[N + 1];
void InverseofNumber(ll p)
{
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (int i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
// Function to precompute inverse of factorials
void InverseofFactorial(ll p)
{
    factorialNumInverse[0] = factorialNumInverse[1] = 1;

    // precompute inverse of natural numbers
    for (int i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}

// Function to calculate factorial of 1 to N
void factorial(ll p)
{
    fact[0] = 1;

    // precompute factorials
    for (int i = 1; i <= N; i++) {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

// Function to return nCr % p in O(1) time
ll Binomial(ll N, ll R, ll p)
{
    // n C r = n!*inverse(r!)*inverse((n-r)!)
    ll ans = ((fact[N] * factorialNumInverse[R])
              % p * factorialNumInverse[N - R])
             % p;
    return ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll p = 1000000007;
    InverseofNumber(p);
    InverseofFactorial(p);
    factorial(p);
int n,k;
cin>>n>>k;
int x=min(n,k);
int mod=pow(10,9)+7;
/// choose the positions where u want to put 0.
int ans=0;
for(int i=0;i<=x;i++)
{if(i==n)
continue;
   int val=Binomial(n,i,mod);
   val*=Binomial(n-1,n-i-1,mod);
   val%=mod;
   ans+=val;
   ans%=mod;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 23680
//比赛结束试试那个wa代码 看看哪错了 
/*#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int n ;
struct seg
{
    int l , r ;
	bool operator <(const seg &s) const
	{
	    if(r != s.r)  return r < s.r ;
		else  return l < s.l ;	
	}	
} a[maxn] ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    cin >> n ;
    for(int i = 1 ; i <= n ; i ++)
    {
    	int x , y ;
    	cin >> x >> y ;
    	a[i].l = x - y ;
    	a[i].r = x + y ; 
	}
	sort(a + 1 , a + n + 1) ;
	int ans = 1 ;
	int last = a[1].r ;
	for(int i = 2 ; i <= n ; i ++)
	   if(a[i].l >= last)  ans ++ , last = a[i].r ;	
    cout << ans << '\n' ;
    return 0 ;
}*/
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int n ;
struct seg
{
    int l , r ;
	bool operator <(const seg &s) const
	{
	    if(r != s.r)  return r < s.r ;
		else  return l < s.l ;	
	}	
} a[maxn] ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    cin >> n ;
    for(int i = 1 ; i <= n ; i ++)
    {
    	int x , y ;
    	cin >> x >> y ;
    	a[i].l = x - y ;
    	a[i].r = x + y ; 
	}
	sort(a + 1 , a + n + 1) ;
	int ans = 0 ;
	int last = a[1].r ;
	for(int i = 2 ; i <= n ; i ++)
	{
	   if(a[i].l < last)  ans ++ ;
	   else  last = a[i].r ;	
	}
    cout << n - ans << '\n' ;
    return 0 ;
}

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

int main() {
    int n; cin >> n;
    long long sum = 0;
    map <int, int> m;

    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        m[x]++;
        sum += x;
    }

    int q; cin >> q;
    for(int i = 0; i < q; i++) {
        long long b1, b2; cin >> b1 >> b2;
        sum -= m[b1] * b1;
        sum += m[b1] * b2;
        m[b2] += m[b1];
        m[b1] = 0;
        cout << sum << "\n";
    }

    return 0;
}

Measured memory_bytes: 8032
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	
	ll ans = 0;
	for(int ri = 0; ri <= n; ++ri) {
		for(int gi = 0; gi <= n; ++gi) {
			int bi = n - ri * r - gi * g;
			
			if( bi >= 0 && bi % b == 0 ) ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3592
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int K[200001];
int zentai, N;
ll kotae[200001];
int C[200001];
vector<int> E[200001];

void dfs(int p, int mae) {


	int k = K[C[p]] + zentai;
	int k0 = k;

	for (int to : E[p]) {
		if (mae != to) {
			dfs(to, p);
			int sa = K[C[p]] + zentai - k;
			kotae[C[p]] -= ll(sa) * (sa + 1) / 2;
			k += sa;
		}
	}

	zentai++;
	K[C[p]] = k0 - zentai;
}


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


	cin >> N;
	rep1(i, N) cin >> C[i];
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;

		E[a].pb(b);
		E[b].pb(a);
	}

	dfs(1, -1);
	ll n = ll(N) * (N + 1) / 2;
	rep1(i, N) {
		int sa = K[i] + zentai;
		co(n + kotae[i] - ll(sa) * (sa + 1) / 2);
	}

	Would you please return 0;
}

Measured memory_bytes: 33288
N=int(input())
A=[]
B=[]
C=[]
for i in range(N):
  l1,l2,l3=map(int,input().split())
  A+=[l1]
  B+=[l2]
  C+=[l3]
dp=[[0,0,0] for i in range(N)]#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
dp[0][0]=A[0]
dp[0][1]=B[0]
dp[0][2]=C[0]
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+B[i],dp[i-1][0]+B[i])
  dp[i][0]=max(dp[i-1][1]+A[i],dp[i-1][2]+A[i])
  dp[i][2]=max(dp[i-1][1]+C[i],dp[i-1][0]+C[i])
ans=max(dp[N-1])
print(ans)

Measured memory_bytes: 34680
import math
a,b,x=map(int,input().split())
y=2*(b-x/a/a)
th=math.asin(y/math.sqrt(y*y+a*a))*180/math.pi
if th>math.asin(b/math.sqrt(b*b+a*a))*180/math.pi:
    y=2*x/a/b
    th=math.asin(b/math.sqrt(y*y+b*b))*180/math.pi
print(th)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    bool flag = false;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == N) flag = true;
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}






Measured memory_bytes: 504
#include<stdio.h>
 
int main(void){
 
  int i;
 
  /* 文字 */
  char moji;
 
  /* 文字を入力 */
  scanf("%c", &moji);
 
  /* アルファベットの小文字か大文字かを判定 */
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
  else {}
 
  return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> cnt(K+1,0);
    for(ll i = K; i>0; i--){
        ll c = K/i;
        cnt[i] = pow(c,N,mod);
        for(ll j = 2; i*j<=K; j++){
            cnt[i] = (cnt[i] - cnt[j*i])%mod;
        }
    }
    ll ans = 0;
    rep(i,K+1){
        ans = (ans + i*cnt[i])%mod;
    }
    if(ans<0) ans += mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 4032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int dp[216000][5], a, l;

int main(){
  cin >> l;
  for(int i = 0;i < l;i++)
    for(int j = 0;j < 5;j++)
      dp[i][j] = INF;
  dp[0][0] = dp[0][1] = dp[0][2] = dp[0][3] = dp[0][4] = 0;
  for(int i = 1;i <= l;i++){
    cin >> a;
    dp[i][0] = dp[i-1][0] + a;
    dp[i][1] = min(dp[i][0], dp[i-1][1] + (a==0?2:(a%2)));
    dp[i][2] = min(dp[i][1], dp[i-1][2] + !(a%2));
    dp[i][3] = min(dp[i][2], dp[i-1][3]  +(a==0?2:(a%2)));
    dp[i][4] = min(dp[i][3], dp[i-1][4] + a);
  }
  cout << dp[l][4] << endl;
  return 0;
}


Measured memory_bytes: 8448
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int n; int m;
	while(~scanf("%d%d", &n, &m)) {
		vector<int> a(m);
		for(int i = 0; i < m; ++ i)
			scanf("%d", &a[i]), -- a[i];
		int ans = max(a[0], n - 1 - a[m-1]);
		rep(i, m - 1)
			amax(ans, (a[i + 1] - a[i]) / 2);
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;
const int MAXN = 1e5 + 5;

int h, w, k;
char c[10][10];
int ta[MAXN][10];

int main(int argc, char* argv[]) {
    scanf("%d %d %d", &h, &w, &k);
    for (int i = 0; i < h; i++)
        scanf("%s", c[i]);
    int ans = 0;
    for (int i = 0; i < (1 << 6); i++) {
        int cc = i;
        for (int j = 0; j < 6; j++) {
            if (cc & 1) ta[i][j] = 1;
            cc >>= 1;
        }
    }
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {

            int sum = 0;
            for (int x = 0; x < h; x++) {
                if (ta[i][x] == 1) continue;
                for (int y = 0; y < w; y++) {
                    if (ta[j][y] == 1)
                        continue;
                    else if (c[x][y] == '#')
                        sum++;
                }
            }
            if (sum == k) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int a, p;
  cin>>a>>p;
  p+=a*3;
  cout<<p/2;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

int a, b;
const int MAXN = (int)5e6;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> a >> b;
for(int i = 1 ; i <= MAXN ; ++i){
	if((int)(i * 0.08) == a && (int)(i * 0.1) == b){
		cout << i << endl;
		return 0;
	}
}
cout << -1 << endl;

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

int n, k;
int dp[N][2];
int arr[105];

int main() {
	scanf("%d %d", &n, &k);
	dp[0][0] = 1;
	dp[0][1] = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", arr + i);
	}
	for (int i = 1; i <= k; i++) {
		dp[i][0] = 1;
		dp[i][1] = 0;
		for (int j = 0; j < n; j++) {
 			if (i < arr[j]) {
				dp[i][0] = min(1, dp[i][0]);
				dp[i][1] = max(0, dp[i][1]);
 			}
			else {
				dp[i][0] = min(dp[i][0], dp[i - arr[j]][1]);
				dp[i][1] = max(dp[i][1], dp[i - arr[j]][0]);
			}
		}
		// cout << dp[i][0] << dp[i][1] << endl;
	}
	if (dp[k][0] == 0)
		puts("First");
	else puts("Second"); 
	return 0;
}
		

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;


int main()
{
  cin>>N;
  vector<int> b(N);
  REP(i,0,N){
    cin>>b[i];
  }
  int ans[N];

  for(int i=N-1;i>=0;i--){
    bool flag=false;
    for(int j=i;j>=0;j--){
      if(j+1==b[j]&&!flag){
        ans[i]=j+1;
        flag=true;
        b.erase(b.begin()+j);
      }
    }
    if(!flag){
      cout<<"-1"<<endl;
      return 0;
    }
  }

  REP(i,0,N){
    cout<<ans[i]<<endl;
  }



  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a;
int main(){
	scanf("%d",&a);
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++){
			if(i*j==a){
				printf("Yes");
				return 0;
			}
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc110_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(input);
            Array.Reverse(input);

            WriteLine(input[0]*10+input[1]*1+input[2]);
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, M;
    cin >> N >> M;
    map<pair<ll, string>,ll> mp;
    
    rep(_,M){
        ll p; string S;
        cin >> p >> S;
        if(!mp.count({p,"AC"})) mp[{p, S}]++;
    }

    ll cor = 0, pen = 0;
    rep1(i, N){
        ll x = mp[{i, "WA"}];
        cor += mp.count({i, "AC"});
        pen += mp[{i, "WA"}] * mp.count({i,"AC"});
    }

    cout << cor << " " << pen << '\n';
    return 0;
}

Measured memory_bytes: 22144
//******\\
**udc321**	 
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fr(e,r,v) for(int e=r;e<v;e++)
#define bc(e,r,v) for(int e=r;e>v;e--)
#define all(n) (n.begin(),n.end())
#define ft first
#define sd second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mpr make_pair
#define dbl  double
using namespace std;
ll mod=1000000007;

int main()
{
	ll k;cin>>k;
	fr(i,0,k)
	{cout<<"ACL";}
	

}







Measured memory_bytes: 3552
#include<iostream>

using namespace std;
int main()
{
int h,w;
char a[100][100];
int i,j;
cin>>h>>w;

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

for(i=0;i<=w+1;i++)
{
	cout<<'#';
}
cout<<'\n';
cout<<'#';

for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cout<<a[i][j];
}
cout<<"#\n#";
}

for(i=0;i<=w;i++)
{
	cout<<"#";
	}
	cout<<'\n';
	return 0;
	}

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

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    for(int bit=0;bit<(1<<2);++bit){
        vector<bool> isSheep(N,false);
        for(int i=0;i<2;i++){
            if((bit>>i) &1){
                isSheep[i] = true;
            }
        }
        for(int i=1;i<N-1;i++){
            if(isSheep[i]){
                if(S[i] == 'o'){
                    isSheep[i+1] = isSheep[i-1];
                }else{
                    isSheep[i+1] = !isSheep[i-1];
                }
            }else{
                if(S[i] == 'x'){
                    isSheep[i+1] = isSheep[i-1];
                }else{
                    isSheep[i+1] = !isSheep[i-1];
                }
            }
        }
        bool ok = true;
        for(int i=0;i<2;i++){
            int t = (N-1+i)%N;
            int next = (N+i)%N;
            int prev = (N-2+i)%N;
        if(isSheep[t]){
            if(S[t] == 'o'){
                if(isSheep[next] != isSheep[prev]){
                   ok = false;
                }
            }else{
                if(isSheep[next] == isSheep[prev]){
                    ok = false;
                }
            }
        }else{
            if(S[t] == 'o'){
                if(isSheep[next] == isSheep[prev]){
                    ok = false;
                }
            }else{
                if(isSheep[next] != isSheep[prev]){
                    ok = false;
                }
            }
        }
        }
        if(!ok){
            continue;
        }
        for(int i=0;i<N;i++){
            if(isSheep[i]){
                cout <<"S";
            }else{
                cout <<"W";
            }
        }
        cout <<endl;
        return 0;
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 512
# A - Airport Bus

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans = 0
c = 0
dead_time = 0

for i in range(N):
    if c==0 or T[i]>dead_time:
        dead_time = T[i]+K
        ans += 1
        c = 0
    c = (c+1)%C

print(ans)

Measured memory_bytes: 7388
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
s

10^5
 */
string s;

int main(){
  cin>>s;

  int l = s.size();
  int a[] = {0,0};
  
  REP(i, l){
    a[s[i]-'0']++;
  }

  cout<< min(a[0],a[1]) * 2 <<endl;

  return 0;
}


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

int main() {
  string S;
  cin >> S;
  int min_d = 1000;
  for (int i = 0; i < S.size() - 2; ++i) {
    int X = stoi(S.substr(i, 3));
    int d = X - 753;
    if (d < 0) d = -d;
    if (d < min_d) min_d = d;
  }
  cout << min_d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n ;

  string s;
  bool b = false;
  for (int i = 0; i < n; i++) {
    cin >> s ;
    if (s == "Y") b = true;
  }

  if (b) {
    cout << "Four" << endl;
  }else {
    cout << "Three" << endl;
  }
}

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

   typedef long long ll;

   const double EPS = (1e-7);
   const ll INF =(1e9);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

ll A, B, K;

void exchange(ll &x, ll &y){
    x /= 2;
    y += x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> A >> B >> K;
    REP(i, K){
        if (i % 2 == 0) exchange(A, B);
        else exchange(B, A);
    }
    cout << A << ' ' << B << endl;



}

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  vi warikiru;
  for(int i = 1; i<a+b; i++){
    if(a%i == 0 && b%i == 0) warikiru.push_back(i);
  }
  sort(warikiru.rbegin(),warikiru.rend());
  cout << warikiru[k-1] << endl;
}


Measured memory_bytes: 3580
N=int(input())
AL=list(map(int, input().split()))
L=[]
for i in range(N-1,0,-1):
    s=AL[i]
    for j in range((i+1)*2-1,N,i+1):
        s^=AL[j]
    AL[i]=s
    if AL[i]==1:
        L.append(i+1)
AL[0]^=(len(L)%2)
if AL[0]==1:
    L.append(1)
print(len(L))
if L:
    print(*L)


Measured memory_bytes: 65244
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;

    s = "." + s;

    auto exist = [&](int x, int y, int k, char c) {
        int t = 0;
        for (int i = x; i <= y; ++i)
        {
            if (s[i] == c)
                ++t;
            else
                t = 0;
            if (t == k)
                return true;
        }
        return false;
    };

    if (exist(a, c, 2, '#') || exist(b, d, 2, '#'))
    {
        cout << "No" << endl;
        return 0;
    }

    if (c < d)
    {
        cout << "Yes" << endl;
        return 0;
    }

    if (!exist(b - 1, d + 1, 3, '.'))
    {
        cout << "No" << endl;
        return 0;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    cout << (N-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n; int m=1000001;
    int a[n]; std::vector<int>v(m) ;;
    for(int i=0; i<n; i++){
        cin>>a[i];
        v[a[i]]++;
    }int ans=0;
    //for(int i=1; i<25; i++)cout<<i<<":"<<v[i]<<" "; cout<<endl;
    for(int i=0; i<m; i++){
        if(v[i]==1){ans++;}
        if(v[i]>0){
            for(int j=2; i*j<m; j++)v[i*j]=0;
        }//cout<<i<<": ";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8012
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

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

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

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

			long k = in.nextLong();

			Set<Long> set = new TreeSet<>();
			long base = 1;
			for (int i = 0; i < 15; i++) {
				for (int j = 1; j < 150; j++) {
					long num = (j*base)-1;
					if (1 <= num && num <= pow(10, 15)) {
						set.add(num);
					}
				}
				base *= 10;
			}

			List<Long> list = new ArrayList<>();
			for (long n : set) {
				boolean not = false;
				for (long m : set) {
					if (n < m && isNotSunuke(n, m)) {
						not = true;
						break;
					}
				}
//				not = not || isNotSunuke(n, n+1) || isNotSunuke(n, n+10) || isNotSunuke(n, n+100) || isNotSunuke(n, n+1000) || isNotSunuke(n, n+10000);
				if (!not) list.add(n);
			}

			for (int i = 0; i < k; i++) {
				out.println(list.get(i));
			}


		}

		long s(long n) {
			long ret = 0;

			while (n > 0) {
				ret += n % 10;
				n /= 10;
			}
			return ret;
		}

		boolean isNotSunuke(long n, long m) {
			return n*s(m) > m*s(n);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

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

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

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

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

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

}


Measured memory_bytes: 20616
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
#[fastout]
fn main() {
    input!{
        mut x: i64,
        k: i64,
        d: i64,
    }

    x = x.abs();

    let r = x % d;
    let e = x / d;

    if k < e {
        println!("{}", x - k*d);
        return;
    }

    if k%2 == e%2 {
        println!("{}", r.abs());
    } else {
        println!("{}", (r as i64 - d).abs());
    }
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
int l[100100],r[100100];

int le,ri;

int main(){
	cin>>n>>m;
	REP(i,m)
		cin>>l[i]>>r[i];
	
	le=1,ri=n;
	
	for(int i=0;i<m;i++){
		if(le<=l[i]&&r[i]<=ri){
			le=l[i],ri=r[i];
		}else if(le<=l[i]&&l[i]<=ri){
			le=l[i];
		}else if(le<=r[i]&&r[i]<=ri){
			ri=r[i];
		}else if(l[i]<=le&&ri<=r[i]){
		}else{
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<ri-le+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
function Main(input) {
  input = input.split('\n');
	var n = Number(input[0]);
	var k = Math.floor(n/100);
  if(100*k<=n && n<=105*k){
  console.log('1');
  }else{
  console.log('0');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	cin >> n;
	
	if (n[0] == '1') {
		cout << '9' ;
	}else {
		cout << '1';
	}

	if (n[1] == '1') {
		cout << '9' ;
	}
	else {
		cout << '1' ;
	}

	if (n[2] == '1') {
		cout << '9' << endl;
	}
	else {
		cout << '1' << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n, 0), dp(n+5, 10000000000000);
    dp[0] = 0;
    rep(i, n) cin >> h[i];
    rep(i, max((n - k + 1), n)) {
        for(int j = 1; j <= k; j++) {
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }

    cout << dp[n-1] << endl;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 998244353;

template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

// v[i][j] := iCj
std::vector<std::vector<ll>> comb2(int n)
{
    std::vector<std::vector<ll>> v(n + 1, std::vector<ll>(n + 1, 0));
    for (int i = 0; i < (int)v.size(); i++)
    {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < (int)v.size(); j++)
    {
        for (int k = 1; k < j; k++)
        {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
            v[j][k] %= MOD;
        }
    }
    return v;
}

auto comb = comb2(4040);

// nHk = n+k-1 C k
ll H(int n, int k)
{
    if (k < 0)
        return 0;
    return comb[n + k - 1][k];
}

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

    int K, N;
    cin >> K >> N;
    for (int i = 2; i <= 2 * K; i++)
    {
        ll ret = 0;
        int p = 0;
        for (int j = 1; 2 * j <= i; j++)
        {
            if (K < i - j)
                continue;
            p++;
        }
        for (int q = 1; q <= p; q++)
        {
            ll sum = comb[p][q];
            sum = sum * H(K, N - 2 * q) % MOD;
            if (q % 2)
            {
                ret += sum;
                ret %= MOD;
            }
            else
            {
                ret = ret + MOD - sum;
                ret %= MOD;
            }
        }
        cout << (H(K, N) + MOD - ret) % MOD << endl;
    }
}


Measured memory_bytes: 128000
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	int cnt = 0;
	for (; accumulate(a.begin(), a.end(), 0) > 0;)
	{
		int old = -1;
		vector<int> b = a;
		for (int i = 0; i < n; i++)
		{
			if (a.at(i) == 0 && old > 0)
			{
				cnt++;
			}

			old = a.at(i);
		}

		if (a.back() > 0)
		{
			cnt++;
		}

		for (int i = 0; i < n; i++)
		{
			a.at(i) = max(0, a.at(i) - 1);
		}
	}

	cout << cnt << endl;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<int> v = {0, 0};
  for (auto e : s) {
    if (e - '0' == (v.size() + 1) % 2) {
      (*rbegin(v))++;
    } else {
      v.push_back(1);
    }
  }
  v.push_back(0);
  for (int i = 0; i + 1 < v.size(); i++) {
    v[i + 1] += v[i];
  }

  int w = min((int)v.size() - 1, 2 * k + 1);
  int r = 0;
  for (int i = 0; i + w < v.size(); i += 2) {
    r = max(r, v[i + w] - v[i]);
  }
  cout << r << endl;
}


Measured memory_bytes: 1020