akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll A[110000],B[110000],C[110000],numB[110000],ans=0;


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

  for(int i=0;i<N;i++) cin>>A[i];

  for(int i=0;i<N;i++) cin>>B[i];

  for(int i=0;i<N;i++) cin>>C[i];

  sort(A,A+N); sort(B,B+N); sort(C,C+N);

  for(int i=0;i<N;i++){
    numB[i]=C+N-upper_bound(C,C+N,B[i]);
    //cout<<numB[i]<<endl;
  }
  for(int i=N-2;i>=0;i--){
    numB[i]+=numB[i+1];
  }

  for(int i=0;i<N;i++){
    ans+=numB[upper_bound(B,B+N,A[i])-B];
    //cout<<ans<<endl;
    //cout<<upper_bound(B,B+N,A[i])-B<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
k = gets.to_i
if k % 2 == 0 || k % 5 == 0
  puts "-1"
  return
end

mod = 7
pmod = 7
for i in 1..k+1
  if mod%k == 0
    puts i
    return
  end
  mod += pmod * 10
  mod %= k
  pmod *= 10
  pmod %= k
end

puts "-1"

Measured memory_bytes: 14392
#N=int(input())
#N,M=map(int, input().split())
#L=list(map(int, input().split()))
N,K,Q = map(int, input().split())
K-=Q

Kl = [K]*N

for i in range(Q):
  Kl[int(input())-1]+=1

Co=0
for j in range(N):
  if Kl[j]>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 6616
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(b>a)
    {
        for(int i=0;i<b;i++)
        printf("%d",a);
    }
    else
    {
        for(int j=0;j<a;j++)
        printf("%d",b);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;

int main(){
    double n;
    int x;
    cin>>n;
    x=n/1.08;
    if((int)(x*1.08)==n){
        cout<<x<<endl;
    }else if((int((x+1)*1.08))==n){
        cout<<x+1<<endl;
    }else if((int)((x-1)*1.08)==n){
        cout<<x-1<<endl;
    }else{
        cout<<":("<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
set<int>Set;
set<int>::iterator it;
int n, Num[101000], LCP[101000];
int st[101000][2], ed[101000];
char p[101000];
struct A{
	int num;
	string S;
	bool operator <(const A &p)const{
		return S < p.S;
	}
}w[101000];
int main(){
	int i, j, s1, s2, top = 0, Q, typ, a, t;
	scanf("%d", &n);
	for (i = 1; i <= n; i++){
		scanf("%s", p);
		w[i].S = p;
		w[i].num = i;
	}
	sort(w + 1, w + n + 1);
	for (i = 1; i <= n; i++)Num[w[i].num] = i;
	for (i = 1; i < n; i++){
		s1 = w[i].S.size(), s2 = w[i + 1].S.size();
		for (j = 0; j < min(s1,s2); j++){
			if (w[i].S[j] != w[i + 1].S[j])break;
		}
		LCP[i] = j;
	}
	for (i = 1; i <= n; i++){
		while (top && st[top][0] > LCP[i - 1]){
			ed[st[top][1]] = i - 1;
			top--;
		}
		top++;
		st[top][0] = w[i].S.size(); st[top][1] = i;
	}
	while (top){
		ed[st[top][1]] = n;
		top--;
	}
	scanf("%d", &Q);
	while (Q--){
		scanf("%d%d", &typ, &a);
		if (typ == 1){
			Set.insert(Num[a]);
		}
		if (typ == 2){
			Set.erase(Set.find(Num[a]));
		}
		if (typ == 3){
			it = Set.lower_bound(Num[a]);
			if (it == Set.end() || *it > ed[Num[a]]){
				printf("-1\n");
			}
			else{
				printf("%d\n", w[*it].num);
			}
		}
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a=-1, z=-1;
	string s; cin>>s;
	int n=s.size();
	for (int i=0; i<n; i++)
		if(s[i]=='A') { a=i; break; }
	for (int i=n-1; i>=0; i--)
		if(s[i]=='Z') { z=i; break; }
	cout << z-a+1 << endl;
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
void tree(vector<set<int>> &g,vector<vector<int>> &t,int p){
  while(!g.at(p).empty()){
    int cp=*begin(g.at(p));
    t.at(p).push_back(cp);
    g.at(p).erase(cp);
    g.at(cp).erase(p);
    tree(g,t,cp);
  }
}
void sum(vector<vector<int>> &t,vector<int> &c,int p){
  for(int cp:t.at(p)){
    c.at(cp)+=c.at(p);
    sum(t,c,cp);
  }
}
int main(){
  int n,q;
  cin>>n>>q;
  vector<set<int>> g(n);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    g.at(a-1).insert(b-1);
    g.at(b-1).insert(a-1);
  }
  vector<vector<int>> t(n);
  tree(g,t,0);
  vector<int> c(n,0);
  for(int i=0;i<q;i++){
    int p,x;
    cin>>p>>x;
    c.at(p-1)+=x;
  }
  sum(t,c,0);
  for(int i=0;i<n;i++)
    cout<<c.at(i)<<(i<n-1?" ":"");
  cout<<endl;
}

Measured memory_bytes: 48640
#!/usr/bin/env python3
import sys


def solve(S: str):
    weekday = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
    print(weekday[S])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let a:i64=read();
    let b:i64=read();
    if(b%a==0){
        println!("{}",a+b);
    }else{
        println!("{}",b-a);
    }
}

Measured memory_bytes: 2128
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MOD 998244353
const int N=1e6;

long long fact[N];
long long n,a,b,k;

void pre(){

      fact[0] = 1;
	  for(long long i=1;i<=n;i++)
	   fact[i] = fact[i-1] * i % MOD;
 }

 long long modPow(long long  b, long long e) {

	if(e == 0) return 1;

	if(e == 1) return b;

	return modPow(b*b % MOD, e >> 1) * modPow(b, e & 1) % MOD;

}
 long long C(long long n, long long k) {

	return fact[n] * modPow(fact[k], MOD-2) % MOD * modPow(fact[n-k], MOD-2) % MOD;
}

int main()
{





    cin>>n>>a>>b>>k;
     pre();

    long long ans=0;


     for(long long i=0;i<=n&&i*a<=k;i++){

           if ( ((k-i*a)%b)) continue;

               long long j=(k-i*a)/b;

             if(j>=0&&j<=n){
                  long long rest=(k-(i*a))/b;
                 ans+= C(n,i) * C(n,rest) % MOD;
                 ans%=MOD;

            }



     }

     printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    while (cin >> n && n) {
        int cnt = 0;
        for (int i=2; i<1000; ++i) {
            if (2 * n % i == 0 && 0 < (2 * n / i - i + 1) && (2 * n / i - i + 1) % 2 == 0) {
                cnt ++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys
from collections import deque
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	UVW = [MAP() for _ in range(N-1)]
	
	G = [[] for _ in range(N)]
	for u, v, w in UVW:
		G[u-1].append([v-1, w])
		G[v-1].append([u-1, w])
		
	C = [-1] * N
	C[0] = 0
	queue = deque()
	for i in range(N):
		queue.append(i)
		while queue:
			v = queue.popleft()
			for child in G[v]:
				nv, dist = child
				if C[nv] != -1: continue
				if not dist % 2:
					# print('iro onaji', v, child)
					C[nv] = C[v]
				else:
					# print('iro kaeru', v, child)
					C[nv] = C[v] ^ 1
				queue.appendleft(nv)
	
	for c in C:
		print(c)

if __name__ == '__main__':
	main()

Measured memory_bytes: 94684
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>;

signed main(){
  int N, M;
  cin >> N >> M;
  
  Graph G(N);
  for( int i = 0; i < M; i++ ){
    int A, B;
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  
  vector<int> dist(N, -1);
  queue<int> que;
  
  dist.at(0) = 0;
  que.push(0);
  
  while( !que.empty() ){
    int v = que.front();
    que.pop();
    
    for( int nv : G.at(v) ){
      if( dist.at(nv) != -1 ) continue;
      dist.at(nv) = v+1;
      que.push(nv);
    }
  }
  
  cout << "Yes" << endl;
  for( int i = 1; i < N; i++ ) cout << dist.at(i) << endl;
  
}


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

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

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

size_t get_largest_rectangle(vector<vector<int>> &g) {
    size_t h=g.size(), w=g[0].size();

    vector<vector<int>> dp(h, vector<int>(w+1));
    for (size_t i=0; i<h; ++i)
        for (size_t j=0; j<w; ++j)
            dp[i][j] = !g[i][j];

    for (size_t i=1; i<h; ++i)
        for (size_t j=0; j<w; ++j)
            if (dp[i][j])
                dp[i][j] += dp[i-1][j];

    size_t max_area=0;
    for (size_t i=0; i<h; ++i)
        for (size_t j=0; j<w; ++j) {
            if (!dp[i][j]) continue;

            int min_height=dp[i][j];
            for (size_t k=j+1; k<=w; ++k) {
                if (max_area < (k-j)*min_height)
                    max_area = (k-j)*min_height;

                if (!dp[i][k])
                    break;

                if (min_height > dp[i][k])
                    min_height = dp[i][k];
            }
        }

    return max_area;
}

int main() {
    size_t h, w;
    scanf("%zu %zu", &h, &w);

    vector<vector<int>> g(h, vector<int>(w));
    for (size_t i=0; i<h; ++i)
        for (size_t j=0; j<w; ++j)
            scanf("%d", &g[i][j]);

    printf("%zu\n", get_largest_rectangle(g));
    return 0;
}

Measured memory_bytes: 17756
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vi x,y;

int main(){
	cin>>n;
	x=y=vi(n);
	for(int i=0;i<n;i++) cin>>x[i]>>y[i];
	for(int i=0;i<n;i++){
		vd a;
		for(int j=0;j<n;j++) if(i!=j){
			double sx=x[j]-x[i],sy=y[j]-y[i],A=atan(sy/sx);
			if(sy<0) A+=pi;
			if(sy<0&&sx>=0) A+=pi;
			if(sx<0&&sy>=0) A+=pi;
			a.push_back(A);
		}
//		for(auto j:a) cout<<j<<' ';
//		cout<<endl;
		sort(a.begin(),a.end());
		double m=0;
		for(int j=0;j<n-1;j++){
			m=max(m,(j==n-2?2*pi+a[0]:a[j+1])-a[j]);
		}
//		cout<<m<<endl;
		m-=pi;
		cout<<syosu(9)<<max(0.0,m)/(2*pi)<<endl;
	}
}

Measured memory_bytes: 256
void main() {
    int a = readln.chomp.to!int;
    int b = readln.chomp.to!int;
    int c = readln.chomp.to!int;
    int x = readln.chomp.to!int;
    int cnt;
    foreach (i; 0 .. a+1) {
        foreach (j; 0 .. b+1) {
            int tmp = (x - 500 * i - 100 * j) / 50;
            if (0 <= tmp && tmp <= c) ++cnt;
        }
    }
    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
a = list(map(int, input().split()))
W = a[0]
H = a[1]
x = a[2]
y = a[3]
r = a[4]
if(x + r > W or x - r < 0): print("No")
elif(y + r > H or y - r < 0): print("No")
else: print("Yes")

Measured memory_bytes: 7684
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll h,n;
    cin >> h >> n;
    vector<ll>a(n);
    ll total = 0;
    REP(i,n){
        cin >> a[i];
        total += a[i];
    }
    if(total >= h)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

int n,p[100001];

int main(int argc,char** argv) {
	int x,a,b;
	cin >> x >> a >> b;
	if(abs(x-a) < abs(x-b)) cout << "A";
	else cout << "B";
}


Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	A := make([]int, N)
	for idx := range A {
		A[idx] = io.NextInt()
	}
	R := make([]int, N)
	var AA int
	for _, v := range A {
		AA = AA ^ v
	}
	for idx := range R {
		R[idx] = AA ^ A[idx]
	}
	io.PrintIntLn(R)
}


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

int main()
{
  int n, m;
  std::cin >> n >> m;
  std::vector<std::string> a(n);
  for (auto& itr : a)
  {
    std::cin >> itr;
  }
  std::vector<std::string> b(m);
  for (auto& itr : b)
  {
    std::cin >> itr;
  }
  for (int a_row = 0; a_row < n - m + 1; ++a_row)
  {
    for (int a_column = 0; a_column < n - m + 1; ++a_column)
    {
      bool match = true;
      for (int b_row = 0; b_row < m; ++b_row)
      {
        for (int b_column = 0; b_column < m; ++b_column)
        {
          if (b[b_row][b_column] != a[a_row + b_row][a_column + b_column])
          {
            match = false;
          }
        }
      }
      if (match == true)
      {
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "No" << std::endl;
  
  return 0;
}

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

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

  if(s[2]==s[3] && s[4]==s[5]){
    prt("Yes");
  } else {
    prt("No");
  }
}


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

using namespace std;
typedef long long ll;

ll n,arr[100005],dp[100005],k;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<(int)n;i++)cin>>arr[i];
    for(int i=0;i<(int)n;i++){
        dp[i]=1000000000;
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=i-1;j>=(max((ll)0,i-k));j--){
            dp[i]=min(dp[i],dp[j]+abs(arr[j]-arr[i]));
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
import java.util.Scanner;


public class Main {

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

        int[] a = new int[100];
        int cnt = 0;

        for(int i=1;i<=9;i++)
            for(int j=i;j<=9;j++)
                a[cnt++] = i*j;

        int n = cin.nextInt();

        for(int i=0;i<cnt;i++){
            if(a[i]==n){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23892
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define db double
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
const int maxn=2e5+7;
int n,m,p,ans;

char cc;ll ff;
template<typename T>void read(T& aa) {
	aa=0;ff=1; cc=getchar();
	while(cc!='-'&&(cc<'0'||cc>'9')) cc=getchar();
	if(cc=='-') ff=-1,cc=getchar();
	while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
	aa*=ff;
}

struct Node{
	int l,r;
	bool operator < (const Node& b) const{return r>b.r;}
}node[maxn];

int num[4*maxn],laz[4*maxn],ql,qr;

int pd(int pos,int l,int r) {
	int mid=(l+r)>>1;
	if(!laz[pos]) return mid;
	laz[pos<<1]+=laz[pos];
	laz[pos<<1|1]+=laz[pos];
	num[pos<<1]+=laz[pos];
	num[pos<<1|1]+=laz[pos];
	laz[pos]=0;
	return mid;
}

void bld(int pos,int l,int r) {
	if(l==r) {
		num[pos]=-l;
		return;
	}
	int mid=(l+r)>>1;
	bld(pos<<1,l,mid);
	bld(pos<<1|1,mid+1,r);
	num[pos]=max(num[pos<<1],num[pos<<1|1]);
}

void chge(int pos,int l,int r) {
	if(l>=ql&&r<=qr) {
		num[pos]++;
		laz[pos]++;
		return;
	}
	int mid=pd(pos,l,r);
	if(ql<=mid) chge(pos<<1,l,mid);
	if(qr>mid) chge(pos<<1|1,mid+1,r);
	num[pos]=max(num[pos<<1],num[pos<<1|1]);
}

int main() {
	read(n); read(m);
	For(i,1,n) {
		read(node[i].l);
		read(node[i].r);
		if(node[i].l==0&&node[i].r>m) p++,i--,n--;
	}
	sort(node+1,node+n+1);
	bld(1,1,m+1);
	For(i,1,n) {
		ql=node[i].l+1; qr=m+1;
		chge(1,1,m+1);
		ans=max(ans,num[1]+1-(m-node[i].r+1));
	}
	printf("%d",max(ans,n-m)+p);
	return 0;
}
/*
7 6
0 7
1 5
3 6
2 7
1 6
2 6
3 7
*/

Measured memory_bytes: 7936
/**
*    author: lucasfcm9
*    created: 28.08.20 16:38:51
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int > m(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    sum += m[i];
  }
  int ans = 0;
  int c = *min_element(m.begin(), m.end());
  int tot = x;
  tot -= sum;
  debug(tot);
  while (tot > 0) {
    tot -= c;
    ans++;
  }
  debug(tot);
  if (tot < 0) {
    cout << n + ans - 1 << '\n';
  } else {
    cout << n  + ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>

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

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, string op, ll B) {
  cout << A + B * (op == "+" ? 1 : -1) << endl;
}

int main() {
  ll A;
  cin >> A;
  string op;
  cin >> op;
  ll B;
  cin >> B;
  solve(A, op, B);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	string S;
	cin >> S;

	ll M = S.size();

	vector<ll> yama;
	vector<ll> tani;

	tani.push_back(0);

	if (S[0] == '>') { yama.push_back(0); }

	repn(i, M - 1) {
		if (S[i - 1] == '>'&&S[i] == '<') { tani.push_back(i); }
		if (S[i - 1] == '<'&&S[i] == '>') { yama.push_back(i); }
	}

	if (S[M - 1] == '<') { yama.push_back(M); }
	tani.push_back(M);

	ll ans = 0;

	rep(i, yama.size()) {
		ll y = yama[i] - tani[i];
		ll t = tani[i + 1] - yama[i];
		ans += y * (y - 1) / 2 + t * (t - 1) / 2 + max(y, t);
	}

	cout << ans;
	
	system("PAUSE");

}





Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = (X - A) % B;

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
n, m = map(int, input().split())
ans = [0] * n
ans[0] = 1  # 先頭に1を指定しておく
data = [0] * m
for i in range(m):
    data[i] = list(map(int, input().split()))
data = list(map(list, set(map(tuple, data))))
# print(data)
arr = [0] * 3  # 変更回数の記録
for j in range(len(data)):
    s = data[j][0]-1
    c = data[j][1]
    before = ans[s]
    ans[s] = c
    after = ans[s]
    if before != after or after == 0:
        arr[s] += 1
if n == 1 and m == 0:
    print(0)
    exit()
for k in range(3):
    if arr[k] > 1:  # 変更回数が2回以上でだめ
        print(-1)
        exit()
if ans[0] == 0 and n != 1:  # 答えの先頭が0はだめ
    print(-1)
    exit()
print(*ans, sep='')

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

int main()
{
    int x, a, b, i=0;
    cin >> x;
    cin >> a;
    cin >> b;
    while(true){
        i++;
        if(x < a + b * i) {
            i--;
            break;
        }
    }
    cout << x - (a + b * i) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
		int a[3];
		bool b = true;
		for( int i=0;i<3;i++) cin >> a[i];
		while(b){
				b = false;
				for( int i=0;i<2;i++){
						if(a[i]>a[i+1]){
								int t = a[i];
								a[i] = a[i+1];
								a[i+1] = t;
								b = true;
						}
				}
		}
		cout << a[0] << " " <<  a[1] << " " <<  a[2] << endl;
		return 0;
}

Measured memory_bytes: 1164
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k;
int a[200000];
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = Inf;
	for (int i = k - 1; i < n; i++) {
		ans = min(ans, a[i] - a[i - k + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ0589().doIt();
	}
	
	class AOJ0589{
		void doIt(){
			int n = in.nextInt();
			HashMap<String,Data> map = new HashMap<String, Data>();
			for(int i=0;i<n;i++){
				String name = in.next();
				if(map.containsKey(name)){
					map.get(name).num+=in.nextInt();
					continue;
				}
				map.put(name,new Data(name, in.nextInt()));
			}
			ArrayList<Data> list = new ArrayList<Data>();
			for(String key:map.keySet()){
				list.add(map.get(key));
			}
			Collections.sort(list);
			for(int i=0;i<list.size();i++)System.out.println(list.get(i));
		}
		class Data implements Comparable<Data>{
			String name;
			int num;
			public Data(String name,int num) {
				this.name = name;
				this.num = num;
			}
			public int compareTo(Data o) {
				if(this.name.length()<o.name.length())return -1;
				else if(this.name.length()>o.name.length())return 1;
				else if(this.name.compareTo(o.name)<0)return -1;
				else if(this.name.compareTo(o.name)>0)return 1;
				return 0;
			}
			public String toString(){
				return name+" "+num;
			}
		}
	}
	
	
	class AOJ0571{
		void doIt(){
			char[] input = in.next().toCharArray();
			int result = 0;
			int n = input.length;
			
			System.out.println(result);
		}
	}
	
}

Measured memory_bytes: 38304
#include <stdio.h>

int main(){
  int a, b;
  scanf("%d%d", &a, &b);
  if( a < b ){
    printf("%s\n", "a < b");
  }else if( a > b){
    printf("%s\n", "a > b");
  }else if( a == b){
    printf("%s\n", "a == b");
  }
  return 0;
}



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

using namespace std;

set<int> merge(string & a, string & b) {
    set<int> offsets;
    for (int bonus = a.length(); bonus <= 4000; bonus++) {
        offsets.insert(bonus);
    }
    //offsets.insert(a.length());
    for (int sh = 0; sh < a.length(); sh++) {
        bool good = true;
        for (int j = 0; good && j < b.length(); j++) {
            int i = j + sh;
            if (i < a.length()) {
                char ca = a[i];
                char cb = b[j];
                if (ca == '?' || cb == '?') continue;
                if (ca != cb) {
                    good = false;
                    break;
                }
            } else {
                break;
            }
        }
        if (good) {
            offsets.insert(sh);
        }
    }
    return offsets;
}

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

    vector<string> v;
    vector<int> p;
    for (int i = 0; i < 3; i++) {
        string s;
        cin >> s;
        v.push_back(s);
        p.push_back(i);
    }

    int ans = 1e9;
    do {
        set<int> s01 = merge(v[p[0]], v[p[1]]);
        set<int> s02 = merge(v[p[0]], v[p[2]]);
        set<int> s12 = merge(v[p[1]], v[p[2]]);
        int cand0 = (int)v[p[0]].length();
        if (cand0 < ans)
        for (int sh1 = 0; sh1 <= 2000; sh1++) {
            if (s01.find(sh1) != s01.end()) {
                int cand1 = max(cand0, sh1 + (int)v[p[1]].length());
                if (cand1 < ans)
                for (int sh2 = 0; sh2 <= 2000; sh2++) {
                    if (s12.find(sh2) != s12.end()) {
                        int sh3 = sh1 + sh2;
                        int cand2 = max(cand1, sh3 + (int)v[p[2]].length());
                        if (cand2 < ans)
                        if (s02.find(sh3) != s02.end()) {
                            ans = min(ans, cand2);
                        }
                    }
                }
            }
        }
    } while (next_permutation(p.begin(), p.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
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();
        int t = sc.nextInt();

        int biscuitNum = biscuitNum(a, b, t);
        System.out.println(biscuitNum);
    }

    public static int biscuitNum(int a, int b, int t) {
        return (t / a) * b;
    }
}


Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
    int n; cin >> n;
    ll A[10010];
    for(int i=0;i<n;i++) cin >> A[i];

    vector<vector<pair<ll,ll>>> v(n);
    map<ll,ll> p;
    ll LCM = 1;
    for(int i=0;i<n;i++){
        v[i] = prime_factorize(A[i]);
        for(auto c:v[i]){
            p[c.first] = max(p[c.first], c.second);
        }
    }
    for(auto q:p){
        LCM = LCM * modpow(q.first, q.second, MOD) % MOD;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans = (ans + (LCM * modinv(A[i], MOD)) % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
//int l[n+1];
int main() {
  int x1,x2,x3,x4,x5;
  cin >> x1>>x2>>x3>>x4>>x5;
  
  if(x1 == 0){
    cout << 1;
  }else if(x2 == 0){
    cout << 2;
  }else if(x3 == 0){
    cout << 3;
  }else if(x4 ==0){
    cout << 4;
  }else if(x5 ==0){
    cout << 5;
  }



  
}


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

int main(){
  int buf1,buf2,buf3;
  cin >> buf1 >> buf2 >> buf3;
  int d12= buf1- buf2;
  int d13= buf1- buf3;

  bool correct= true;
  for(int i=1; i<3; i++){
    cin >> buf1 >> buf2 >> buf3;

    if(buf1- buf2!=d12 || buf1- buf3!=d13){
      correct= false;
      break;
    }
  }

  string ans= correct ? "Yes"
                      : "No";
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;

const ll INF = 1e18;

int main() {
#ifdef HOME
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
   	int	t, i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> t;
    while(t--) {
    	ll n;
    	int a, b, c, d;
    	cin >> n >> a >> b >> c >> d;

    	vector<pair<ll, ll>> arr = {{2, a}, {3, b}, {5, c}};

    	map<ll, ll> mp;
    	priority_queue<pair<ll, ll>> pq;

    	auto push = [&](ll b, ll a) {
    		if(mp.find(b) == mp.end() || mp[b] > -a) {
    			mp[b] = -a;
    			pq.push({a, b});
    		}
    	};

    	
    	pq.push({0, n});
    	ll ans = INF;

    	while(pq.size()) {
    		auto cur = pq.top();
    		pq.pop();

    		if(cur.second == 0) {
    			ans = min(ans, -cur.first);
    			break;
    		}

    		if(INF / d >= cur.second) {
    			ans = min(ans, -cur.first + 1LL * d * cur.second);
    		}

    		if(cur.second & 1) {
    			push((cur.second + 1) / 2, cur.first - d - a);
    			push((cur.second - 1) / 2, cur.first - d - (cur.second != 1) * a);
    		}
    		else {
    			push(cur.second / 2, cur.first - a);
    		}

    		int r = cur.second % 3;
    		if(r <= 1) {
    			push((cur.second - r) / 3, cur.first - r * d - (cur.second != r) * b);
    		}
    		else {
    			push((cur.second + 3 - r) / 3, cur.first - (3 - r) * d - b);
    		}

    		r = cur.second % 5;
    		if(r <= 2) {
    			push((cur.second - r) / 5, cur.first - r * d - (cur.second != r) * c);
    		}
    		else {
    			push((cur.second + 5 - r) / 5, cur.first - (5 - r) * d - c);
    		}
    	}

    	ans = min(ans, mp[0]);
    	cout << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 4420
/*
AtCoderBeginnerContest167
Problem D - Teleporter /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score:
400
points
*/

#include <iostream>
#include <vector>

int main()
{
    int N;
    long K;
    std::vector<int> A;
    A.push_back(0);
    std::cin >> N >> K;
    for (int i=0; i<N; i++)
    {
        int currA;
        std::cin >> currA;
        A.push_back(currA);
    }
    std::vector<int> vis(N+1, -1);
    std::vector<int> loc;
    int T = 0;
    int pos = 1;
    while (vis[pos]==-1)
    {
        vis[pos] = T;
        loc.push_back(pos);
        T++;
        pos = A[pos];
    }
    int prevT = vis[pos];
    if (K >= prevT)
    {
        long slack = K - prevT;
        int period = T - prevT;
        slack %= period;
        K = prevT + slack;
    }
    std::cout << loc[K] << "\n";
}


Measured memory_bytes: 6400
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if abs(dx) + abs(dy) <= dt and (abs(dx) + abs(dy)) % 2 == dt % 2:
        t, x, y = nt, nx, ny
    else:
        print("No")
        quit(0)
print("Yes")

Measured memory_bytes: 46952
#include <stdio.h>

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(){
    int N,K,Q;
    scanf("%d %d %d",&N,&K,&Q);
    int A[Q];
    for(int i=0;i<Q;i++){
        scanf("%d",&A[i]);
    }

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

    /*quick_sort(A,0,Q-1);
    int i=1,left=0,right=0;
    for(;left<Q-1;){
        if(A[right]==i){
           right++;
        }else if(A[right]>i){
            ans_count[i]=right-left;
            i++;
            left=right;
        }
    }*/
    for(int i=0;i<Q;i++){
        ans_count[A[i]]++;
    }
    for(int i=1;i<N+1;i++){
        if(K+ans_count[i]>Q){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  bool x = true;
  bool y = true;
  bool z = true;
  
  int n = s.size();
  int m = (n - 1) / 2;
  int l = (n + 1) / 2;
    
  for (int i = 0; i < n ; i++){
    if (s.at(i) == s.at(n - i - 1)){
      continue;
    }
    x = false;
  }
  
  for (int i = 0; i < m ; i++){
    if (s.at(i) == s.at(m - i - 1)){
      continue;
    }
    y = false;
  }
  
  for (int i = l; i < n ; i++){
    if (s.at(i) == s.at(n - i - 1)){
      continue;
    }
    z = false;
  }
    
  if (x && y && z){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }    
}

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

using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0;i < n - 1;i++){
        int m;
        cin >> m;
        a[m - 1]++;
    }
    
    for(int i = 0;i < n;i++){
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 3992
/*B - Easy Linear Programming*/
#include <bits/stdc++.h>
using namespace std;

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

	int aux = 0;
	int A, B, C;
	int cards;
	cin >> A >> B >> C >> cards;

	if(cards <= A)
		cout << cards;
	else if(cards <= A + B)
		cout << A;
	else{
		aux = A + B;
		aux = cards - aux;
		aux *= -1;
		cout << A + aux;
	}

	return 0;
}

Measured memory_bytes: 3648
//B - Bingo

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a[3][3];

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

    int n;

    cin >> n;

    int b;
    for (int i=0; i<n; i++){
        cin >> b;
        for (int x=0; x<3; x++){
            for (int y=0; y<3; y++){
                if (a[x][y] == b){
                    a[x][y] = -1;
                    break;
                }
            }
        }
    }

    bool flag = false;

    for (int x=0; x<3; x++){
        int ck1 = 0;
        int ck2 = 0;
        for (int y=0; y<3; y++){
            ck1 += a[x][y];
            ck2 += a[y][x];
        }
        if (ck1 == -3){
            flag = true;
            break;
        }
        if (ck2 == -3){
            flag = true;
            break;
        }
    }
    int ck3 = 0;
    int ck4 = 0;

    ck3 = a[0][0] + a[1][1] + a[2][2];
    ck4 = a[0][2] + a[1][1] + a[2][0];
    if (ck3 == -3){
        flag = true;
    }
    if (ck4 == -3){
        flag = true;
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
#define MAXN 1001
char A[MAXN][MAXN];
int w,h,n;
int s[2];

void input()
{
    cin>>h>>w>>n;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>A[i][j];
            if(A[i][j]=='S'){
                s[0]=i;
                s[1]=j;
            }
        }
    }
}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
typedef pair<pair<int,int>,int> P;

int known[MAXN][MAXN];

int bfs(int& x, int& y, char k)
{
    queue<P>que;
    que.push(P(make_pair(x, y), 0));
    while(!que.empty()){
        P cur = que.front();
        // cout<<"*"<<cur.first.first<<" "<<cur.first.second<<endl;
        que.pop();
        if(A[cur.first.first][cur.first.second]==k){
            x = cur.first.first;
            y = cur.first.second;
            return cur.second;
        }
        for(int i=0;i<4;i++){
            int nx = cur.first.first+dx[i];
            int ny = cur.first.second+dy[i];
            if(0<=nx&&nx<h && 0<=ny&&ny<w && A[nx][ny]!='X' && !known[nx][ny]){
                que.push(P(make_pair(nx, ny), cur.second+1));
                known[nx][ny]=1;
            }
        }
    }
    return 0x3fffffff;
}

int main()
{
    input();
    int res = 0;
    int x, y;
    x = s[0];
    y = s[1];

    for(int i=1;i<=n;i++){
        memset(known, 0, sizeof(int)*MAXN*MAXN);
        int tmp = bfs(x, y, '0'+i);
        res += tmp;
    }
    cout<<res<<endl;
    return 0;
}




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

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b ;
    cin >> u;
    if(s == u){
	a--;
    }
    else if(t == u){
        b--;
    }

    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys



def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, k = LI()
trees = sorted(IR(n))
ret = float('inf')
for i in range(n - k + 1):
    ret = min(ret, trees[i + k - 1] - trees[i])



print(ret)



Measured memory_bytes: 45532
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        cnt+=1
print(cnt)

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

int main(){
  int n;
  cin>>n;
  
  int ans=0;
  for(int i=1;i<=n;i++){
    if(1<=i && i<=9)  ans++;
    else if(100<=i && i<=999) ans++;
    else if(10000<=i && i<=99999) ans++;
  }

   cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3624
n = int(input())
# [[[ノード1, 距離3],[ノード3, 距離5]],[],...]
tree = [[] for _ in range(n+10)]
visited = [-1 for _ in range(n+10)]
# abc = [[0, 0, 0] for _ in range(n)]
for i in range(n-1):
    a, b, c = [int(j) for j in input().split()]
    tree[a - 1].append([b - 1, c])
    tree[b - 1].append([a - 1, c])
q, k = [int(i) for i in input().split()]

stack = [[k-1, 0]]
while True:
    size = len(stack)
    if size == 0:
        break
    now, cost = stack.pop()
    visited[now] = cost
    for i in range(len(tree[now])):
        if visited[tree[now][i][0]] == -1:
            stack.append([tree[now][i][0],
                          cost+tree[now][i][1]])

for _ in range(q):
    x, y = [int(i) - 1 for i in input().split()]
    print(visited[x] + visited[y])

Measured memory_bytes: 55120
<?php
fscanf(STDIN,'%d%d',$N,$M);
$count=[];
$count2=0;
$x=0;
for ($i=0; $i <=$M ; $i++) {
  // code...
  $count[$i]=0;
}
for ($i=1; $i <=$N ; $i++) {
  // code...
  $K=explode(" ",trim(fgets(STDIN)));
  for ($j=1; $j <count($K) ; $j++) {
    // code...
    $x=$K[$j];

   $count[$x]++;
  }
}
for ($i=1; $i <=$M ; $i++) {
  // code...
  if ($count[$i]==$N) {
    // code...
    $count2++;
  }
}
echo $count2;
 ?>


Measured memory_bytes: 3828
def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def examA():
    N, K = LI()
    A = LI()
    ans = "POSSIBLE"
    if max(A)<K:
        ans = "IMPOSSIBLE"
    cur = A[0]
    for i in range(1,N):
        cur = gcd(cur,A[i])
    if K%cur!=0:
        ans = "IMPOSSIBLE"
    print(ans)
    return

def examB():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examA()


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

int main() {
	int n;
	while (cin >> n, n) {
		int sum = 3, ans = 0;
		for (int l = 1, r = 2;;) {
			while (r < n/2+1 && sum < n) {
				sum += ++r;
			}
			if (sum < n)break;
			else if (l != r && sum == n)ans++;
			sum -= l++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3128