akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 505;

int X1[MAX_N],X2[MAX_N],Y1[MAX_N],Y2[MAX_N];
int w,h,n;
bool fld[MAX_N*6][MAX_N*6];

int compress(int *x1,int *x2,int W)
{
	vector<int> xs;
	rep(i,n){
		for(int d=-1;d<=1;d++){
			int tx1 = x1[i] + d;
			int tx2 = x2[i] + d;
			if(1 <= tx1 && tx1 <= W){
				xs.push_back(tx1);
			}
			if(1 <= tx2 && tx2 <= W){
				xs.push_back(tx2);
			}
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	rep(i,n){
		x1[i] = lower_bound(xs.begin(),xs.end(),x1[i]) - xs.begin();
		x2[i] = lower_bound(xs.begin(),xs.end(),x2[i]) - xs.begin();
	}
	return xs.size();
}

int main()
{
	int dx[4] = {-1,0,0,1};
	int dy[4] = {0,-1,1,0};
	while(1){
	cin >> w >> h;
	if(w==0&&h==0){
		break;
	}else{
	cin >> n;
	rep(i,n){
		int p,q,r,s;
		scanf("%d%d%d%d",&p,&q,&r,&s);
		X1[i] = p+1;
		X2[i] = r;
		Y1[i] = q+1;
		Y2[i] = s;
	}
	w = compress(X1,X2,w);
	h = compress(Y1,Y2,h);
	memset(fld,0,sizeof(fld));
	rep(i,n){
		for(int y=Y1[i];y<=Y2[i];y++){
			for(int x=X1[i];x<=X2[i];x++){
				fld[y][x] = true;
			}
		}
	}
	int ans = 0;
	rep(y,h){
		rep(x,w){
			if(fld[y][x]){
				continue;
			}
			ans++;
			queue<P> que;
			que.push(P(x,y));
			while(!que.empty()){
				int sx = que.front().first;
				int sy = que.front().second;
				que.pop();
				rep(i,4){
					int tx = sx + dx[i];
					int ty = sy + dy[i];
					if(tx<0||w<=tx||ty<0||h<=ty){
						continue;
					}
					if(fld[ty][tx]){
						continue;
					}
					que.push(P(tx,ty));
					fld[ty][tx] = true;
				}
			}
		}
	}
	printf("%d\n",ans);
	}
	}
	return 0;
}

Measured memory_bytes: 12064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

"""
・「必要」とは～～が存在
・x を含まない、[K-x,K) 内の総和が存在
・集合を指定すると、ある値段より上側
・全体としても単調性がある
"""

N,K,*A = map(int,read().split())

A = [x if x <= K else K + 1 for x in A]
A.sort()

mask = (1 << K) - 1

def test(x):
    # x番目は必要
    if A[x] > K:
        return True
    dp = 1
    for a in itertools.chain(A[:x], A[x+1:]):
        dp |= (dp << a)
        dp &= mask
    dp >>= (K - A[x])
    return (dp > 0)

left = -1 # 必要
right = N # 不要
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = left + 1
print(answer)


Measured memory_bytes: 41580
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
#define N 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,c = 0;
    cin>>n;
    if(n%2 == 1)
        cout<<0;
    else
    {
        n = n/2;
        while(n)
        {
            c += n/5;
            n = n/5;
        }
        cout<<c;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    uint64_t K; cin>>K;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    vector<int> V(N,-1);
    V.at(0)=0;
    int n=0,t=1,loopS,loopN;
    rep(i,0,N+1){
        n++;
        t=A.at(t-1);
        if(V.at(t-1)!=-1){
            loopS=t-1;
            loopN=n-V.at(t-1);
            break;
        }
        else{
            V.at(t-1)=n;
        }
    }

    int ans=1;
    if(K>V.at(loopS)){
        ans=loopS+1;
        rep(i,0,(K-V.at(loopS))%loopN){
            ans=A.at(ans-1);
        }
    }else{
        rep(i,0,K){
            ans=A.at(ans-1);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		  int ans = sc.nextInt();
		  if(ans>=30){
		    System.out.println("Yes");
		  }
		  else{
		    System.out.println("No");
		  }
	}

}


Measured memory_bytes: 35716
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct Point{double x,y;}p1,p2,p;
Point operator +(Point a,Point b){return (Point){a.x+b.x,a.y+b.y};}
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
Point operator *(Point a,double b){return (Point){a.x*b,a.y*b};}
double dot(Point a,Point b){return a.x*b.x+a.y*b.y;}
double norm(Point a){return a.x*a.x+a.y*a.y;}
void read(Point &x){x.x=read();x.y=read();}
void print(Point x){printf("%.10lf %.10lf\n",x.x,x.y);}
Point Project(Point p1,Point p2,Point p)
{
	Point base=p2-p1,hypo=p-p1;
	double r=dot(hypo,base)/norm(base);
	return p1+base*r;
}
int main()
{
	read(p1);read(p2);
	int q=read();while(q--)
		read(p),print(Project(p1,p2,p));
	return 0;
}



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

void fail() {
    cout << "No\n";
    exit(0);
}

int main() {
    string s;
    cin >> s;
    if (s.size() & 1) fail();
    for (int i = 0; i < s.size(); i++) {
        if (i & 1) {
            if (s[i] != 'i') fail();
        } else {
            if (s[i] != 'h') fail();
        }
    }
    cout << "Yes\n";
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    ll x; cin>>x;

    for(ll i=0;;i++){
        for(ll j=-10000;j<=i;j++){
            if(abs(i*i*i*i*i-j*j*j*j*j)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
        
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1001][10001];
ll a[1001],b[1001];
int n;
int solve(int index, int hp)
{
    if(hp<=0) return 0;
    if(index==n)
    {
        if(hp<=0) return 0;
        return INT_MAX;
    }
    ll &ret = dp[index][hp];
    if(~ret) return ret;
    ret = solve(index+1,hp);
    ret = min(ret, b[index] + solve(index+1, hp - a[index]));
    ret = min(ret,b[index] + solve(index,hp-a[index]));
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll h;
    cin>>h>>n;
    for(int i=0;i<n;++i)
    {
        cin>>a[i]>>b[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,h);
}


Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        int coinNum;
        int inputCash;

        Scanner scanner = new Scanner(System.in);
        String inputData = scanner.nextLine();
        scanner.close();

        String[] editedInputData = inputData.split(" ");

        coinNum = Integer.parseInt(editedInputData[0]);
        inputCash = Integer.parseInt(editedInputData[1]);

        int sumCoinCash = coinNum * 500;

        if (sumCoinCash >= inputCash) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a<=c and c <= b){
    cout << min(b,d)-c << endl;
  }else if(c<=a and a<=d) {
    cout << min(b,d)-a << endl;
  } else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

    string s,t;
    cin >> s >> t;
    int ans = 0;
    REP(i,3) ans += (s[i] == t[i]);
    cout << ans << endl;

    return 0;
}

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

ll n, k, a[M], dp[M];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i], dp[i] = 1e9;
    dp[1] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= k; j++){
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i + j] - a[i]));
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  typedef long long int ll;
int A, B, C,D;
cin >> A >> B >> C >> D;
bool ans = false;
if(A * B > C * D)ans = true;
if(ans)cout << A * B << endl;
else cout << C * D << endl;
        return 0;
}

Measured memory_bytes: 256
n = int(input())
al = []
for _ in range(n):
    a = int(input())
    al.append(-a)


def LIS(L):
    from bisect import bisect
    seq = []
    for i in L:
        pos = bisect(seq, i)
        if len(seq) <= pos:
            seq.append(i)
        else:
            seq[pos] = i
    return len(seq)


print(LIS(al))


Measured memory_bytes: 54360
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int X;
	int result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		X = Integer.parseInt(in.readLine());
	}

	void calc() {
		int mul = X / 100;
		int mod = X % 100;
		if (mod > mul * 5) {
			result = 0;
		} else {
			result = 1;
		}
	}

	void showResult() {
		System.out.println(result);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main() {
    int n,t;
    cin>>n>>t;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    vector<int> b(n);
    b[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--) b[i]=max(a[i],b[i+1]);

    int maxv=0;
    rep(i,n) maxv=max(maxv,b[i]-a[i]);

    int ans=0;
    rep(i,n){
        if(b[i]-a[i]==maxv) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	char nums[1001];
	int sum;				//Answers.
	int i;

	while(1)
	{
		i = 0;
		sum = 0;
		while( (nums[i] = getchar()) != '\n') 
		{
			if(i == 0 && nums[i] == '0')
				return (0);
			sum = sum + (nums[i] - '0');
			i++;
		}
		printf("%d\n", sum);
	}

	return (0);
}



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

int main(){
  long K;
  cin >> K;
  
  long answer = 1;
  
  if(K % 2 == 0){
    answer = -1;
  }
  
  if(answer == -1){
  } else {
    int amari = 7 % K;
    for(long i = 2; amari != 0 && i < 1000000; i++){
      amari = (amari * 10 + 7) % K;
      answer = i;
      if(i == 999999){
      	answer = -1;
      }
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 3584
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: usize,
        X: usize,
        T: f64,
    }


    let ans = ((N as f64 / X as f64).ceil() * T) as i64;
    println!("{}", ans);
}


Measured memory_bytes: 2660
# -*- coding: utf-8 -*-

import os
import sys

def main():
    result = 0
    list_length = int(input())
    data = list(input())
    for i in range(list_length):
        c = and_count(data[:i], data[i:])
        if result < c:
            result = c
    print(result)

def and_count(l1, l2):
    s1 = set(l1)
    s2 = set(l2)
    return len(list(s1 & s2))

if __name__ == '__main__':
    main()

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

int main(){
   int A,B,C,D;
   cin>>A>>B>>C>>D;
    if(A+B-(C+D)==0){
       cout<<"Balanced"<<endl;
    }else if(A+B-(C+D)>0){
       cout<<"Left"<<endl;
    }else {
      cout<<"Right"<<endl;
    }
     }


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
const ll INF = 1e18;
const int MX = 2020;
ll dp[MX][MX];

inline void chmax(ll &a, ll b)
{
    a = max(a, b);
}

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

    vector<ll> a(n);
    vector<pl> p;

    rep(i, n)
    {
        cin >> a.at(i);
    }

    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
            dp[i][j] = -INF;
        }
    }

    dp[0][0] = 0;

    rep(i, n)
    {
        p.emplace_back(a.at(i), i);
    }
    sort(p.rbegin(), p.rend());

    rep(i, n)
    {
        int pi = p.at(i).second;
        rep(l, i + 1)
        {
            int r = i - l;
            chmax(dp[i + 1][l + 1], dp[i][l] + ll(pi - l) * a.at(pi));
            chmax(dp[i + 1][l], dp[i][l] + ll((n - r - 1) - pi) * a.at(pi));
        }
    }
    ll ans = 0;
    rep(i, n + 1)
    {
        chmax(ans, dp[n][i]);
    }

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


Measured memory_bytes: 35256
x = int(input())
B = True
a = 0
while B == True:
    btarget = a ** 5 - x
    b = 0
    if btarget >= 0:
        while b ** 5 <= btarget:
            if b ** 5 == btarget:
                print(a, b)
                exit()
            b += 1
    else:
        while b ** 5 >= btarget:
            if b ** 5 == btarget:
                print(a, b)
                exit()
            b -= 1
    a += 1

Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

/*
g++ -std=c++14 abc134/f.cpp
 */

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>


#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000

using namespace std;

int main() {
	int n,nn;
	cin >> n;
	nn = n;
	int ans = 0;
	while (nn > 0) {
		ans += nn % 10;
		nn /= 10;
	}
	if (n%ans == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
N=int(input())
for h in range(2,3501,2):
  for n in range(2,3501,2):
    if (4*h*n-N*n-N*h) != 0 and (N*h*n)%(4*h*n-N*n-N*h) == 0:
      if 0 < (N*h*n)//(4*h*n-N*n-N*h):
        print(h,n,(N*h*n)//(4*h*n-N*n-N*h))
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main()
{
    int n;
    bool has_zero = false;
    ll ans = 1LL;
    const ll MAX = 1e18;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            has_zero = true;
        }
    }
    if (has_zero)
    {
        cout << "0\n";
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] > MAX / ans)
        {
            cout << "-1\n";
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4056
#include <cstdio>

typedef long long ll;

int main(void){
	while(1){
		ll z;
		scanf("%lld",&z);
		if(z==0)break;
		ll big=0;
		for(ll i=1;i<z;i++){
			for(ll j=1;j<z;j++){
				if(j*j*j+i*i*i<z*z*z && j*j*j+i*i*i>big)big=j*j*j+i*i*i;
			}
		}
		printf("%lld\n",z*z*z-big);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    String s = Integer.toString(n);

    for (int i = 0; i < 3; i++) {
      if (s.charAt(i) == '7') {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");

  }

}

Measured memory_bytes: 35740
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <sstream>

using namespace std;

int main()
{
    int w,n;
    int A[100];
    while(cin >> w >> n)
    {
        for(int i=0; i<w; i++)
            A[i] = i + 1;
        string str;
        for(int i=0; i<n; i++)
        {
            cin >> str;
            int len = str.length();
            int d = str.find(',',0);
            string str1 = str.substr(0,d);
            string str2 = str.substr(d+1,len-1);
            str1 = str1 + " " + str2;
            int a;
            istringstream issInt(str1);
            issInt >> a;
            int b;
            issInt >> b;
            int t = A[a-1];
            A[a-1] = A[b-1];
            A[b-1] = t;
        }
        for(int i=0; i<w; i++)
            cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

const int M = 1000006;

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  vector<int> cnt(M);
  for (auto x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for (auto x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8008
#include <stdio.h>

int main(void) {
	int n = 0;
	int m = 0;

	scanf("%d", &n);

	m = n % 10;

	if(m == 2 || m == 4 || m == 5 || m == 7 || m == 9) {
		puts("hon");
	} else if(m == 0 || m == 1 || m == 6 || m == 8) {
		puts("pon");
	} else {
		puts("bon");
	}

	return 0;
}

Measured memory_bytes: 1648
/*
 *  author: chw0501
 *  created: 15.04.2020 07:37:31(UTC)
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
vector<int> v;
//dp[i]: i개의 돌이 남았을 때 플레이 할 때 이번 플레이어가 이기면 1, 지면 0을 저장
int dp[100001];

int solve(int i){
	int &ret = dp[i];
	if(ret!=-1) return ret;
	if(i<v[0]) return ret=0;
	ret=0;
	for(int j=0;j<n;j++){
		if(v[j]>i) break;
		if(solve(i-v[j])==0) ret=1;
	}
	return ret;
}

int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		v.push_back(x);
	}
	memset(dp,-1,sizeof(dp));
	if(solve(k)==1) cout<<"First";
	else cout<<"Second";
	return 0;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int fact[1000001];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int N, M;
  cin >> N >> M;
  if (abs(N-M) > 1) {
    cout << 0 << "\n";
    return 0;
  }
  fact[0] = 1;
  for (int i=1; i<=1000000; i++) {
    fact[i] = (1LL*i*fact[i-1]) % MOD;
  }
  long long t = 1;
  if (N==M) t = 2;
  cout << (1LL*t*fact[N]*fact[M])%MOD << "\n";
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define aint(v) v.begin(),v.end()
#define endl "\n"
#define all(v) v.begin(),v.end()
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<15> MASK;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main() {
    fast();
    int n,m;cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1)/2);
}


Measured memory_bytes: 3604
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

double sunuke(ll x){
  ll sx = 0;
  ll x_ = x;
  while(x_ > 0){
    sx += x_ % 10;
    x_ /= 10;
  }
  return 1. * x / sx;
}

ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

int main(){
  ll K;
  cin >> K;
  vector<ll> xs;//候補
  for(int i = 1; i < 1000; i++){
    for(int j = 0; j < 14; j++){
      xs.push_back(i * Mypow(10, j) + Mypow(10, j) - 1);
    }
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  int N = xs.size();
  vector<pair<ll, double>> A(N);//検証
  for(int i = 0; i < N; i++){
    A[i].first = xs[i];
    A[i].second = sunuke(xs[i]);
  }
  vector<ll> sunukeList;
  for(int i = 0; i < N; i++){
    bool l = 1;
    for(int j = 0; j < N; j++){
      if(A[i].first < A[j].first && A[i].second > A[j].second) l = 0;
    }
    if(l) sunukeList.push_back(A[i].first);
  }
  sort(sunukeList.begin(), sunukeList.end());
  for(int i = 0; i < K; i++){
    cout << sunukeList[i] << endl;
  }

}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX_MN 1000
string S[MAX_MN],T[MAX_MN];
int maxx=-0x3f3f3f3f;
int main(){
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		cin>>S[i];
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
		cin>>T[i];
	for(int i=1;i<=n;i++){
		int ans=1;
		for(int j=i+1;j<=n;j++)
			if(S[j]==S[i])
				ans++;
		if(ans<maxx)continue;
		for(int j=1;j<=m;j++)
			if(T[j]==S[i])
				ans--;
		if(ans>maxx)
			maxx=ans;
	}
	if(maxx<0)printf("0\n");
	else printf("%d\n",maxx);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Double A = sc.nextDouble();
		Double B = sc.nextDouble();
		Double H = sc.nextDouble();
		Double M = sc.nextDouble();
		Double kaku = 0.0;
		kaku=Math.min(Math.abs((30*H+0.5*M)-6*M), (6*M-(30*H+0.5*M)));
		double kekka=0;
		
		kekka=(Math.pow(A, 2)+Math.pow(B, 2)-(2*A*B)*Math.cos(Math.toRadians(kaku)));
		kekka=Math.sqrt(kekka);
		
		System.out.print(kekka);
		sc.close();
	}
}


Measured memory_bytes: 37536
start =  list(map(int, [n for a in [input().split() for i in range(3)] for n in a]))
goal = [1, 2, 3, 4, 5 ,6, 7, 8, 0]

adjacent = (
    (1, 3),
    (0, 2, 4),
    (1, 5),
    (0, 4, 6),
    (1, 3, 5, 7),
    (2, 4, 8),
    (3, 7),
    (4, 6, 8),
    (5, 7)
)

class State():
    def __init__(self, board, space, path):
        self.board = board
        self.space = space
        self.path = path

def main():
    if start == goal:
        return 0

    queue = [State(start[:], start.index(0), 0)]
    stateList = {"".join(map(str, start)) : True}

    while len(queue) != 0:
        state = queue.pop(0)
        for i in adjacent[state.space]:
            next_state = State(state.board[:], i, state.path + 1)
            next_state.board[i], next_state.board[state.space] = next_state.board[state.space], next_state.board[i]
            state_str = "".join(map(str, next_state.board))
            if stateList.get(state_str) :
                continue
            stateList[state_str] = True
            if next_state.board == goal:
                return next_state.path
            queue.append(next_state)

if __name__ == '__main__':
    result = main()
    print(result)


Measured memory_bytes: 38100
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;




int main(){
    ll n,l;
    cin >> n >> l;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll flag = -1;
    rep(i,n-1){
        if(flag!=-1)break;
        if(a[i]+a[i+1]>=l){
            flag = i+1;
        }
    }
    if(flag==-1)cout << "Impossible" << endl;
    else{
        cout << "Possible" << endl;
        for(int i=1;i<flag;i++){
            cout << i << endl;
        }
        for(int i=n-1;i>flag;i--){
            cout << i << endl;
        }
        cout << flag << endl;
        
    }
    return 0;
}


Measured memory_bytes: 1664
# A問題
N, A, B, C, D = map(int, input().split())
S = input()
flag = False


if C < D:   # AがBを飛び越えない時
    if S.count("##") > 0:
        if S[A-1:C-1].count("##") > 0 or S[B-1:D-1].count("##") > 0:
            flag = False
        else:
            flag = True
    else:
        flag = True
else:   # AがBを飛び越えるとき
    if S.count("##") > 0:
        flag = False
    else:
        if S[B-2:D+1].count("..."):
            flag = True
        else:
            flag = False
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3572
#include<stdio.h> 
long long fiboDP(int n) { 
    long long fibo_dp[200] = {0}; 
              fibo_dp[0] = 1;
              fibo_dp[1] = 1; 
              for(int i=2; i<=n; i++) {
                  fibo_dp[i] = fibo_dp[i-1] + fibo_dp[i-2];
                  } return fibo_dp[n]; 
     
}
int main(void){ 
    int n; scanf("%d\n", &n); 
    printf("%lld\n", fiboDP(n)); 
    return 0; } 


Measured memory_bytes: 2044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final String s = fs.next();
        System.out.println(dfs(s.toCharArray(), 0, 0, new Long[s.length()][4]));
    }

    private static long dfs(char[] s, int i, int j, Long[][] dp) {
        if (i == s.length) {
            return j == 3 ? 1 : 0;
        }
        if (dp[i][j] != null) {
            return dp[i][j];
        }
        long res = dfs(s, i + 1, j, dp);
        if (s[i] == '?') {
            res = 3 * dfs(s, i + 1, j, dp) % MOD;
        }
        if (j < 3 && (s[i] == '?' || s[i] == "ABC".charAt(j))) {
            res = (res + dfs(s, i + 1, j + 1, dp)) % MOD;
        }
        return dp[i][j] = res;
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

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


Measured memory_bytes: 115744
function main(arg) {
    //const input = arg.split("\n")
    let N = Number(arg)
    
    while (N >= 1000) {
        N %= 1000
    }
    //console.log(N)
    console.log(N === 0 ? 0 : 1000-N)


}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void) {
  string S;
  cin >> S;
  bool bad = false;
  for (int i = 0; i < 3; ++i) {
    if (S[i] == S[i + 1]) {
      bad = true;
      break;
    }
  }
  cout << (bad ? "Bad" : "Good") << "\n";
  return 0;
}


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

int main() {
    int i, ans = 0;
    string s;
    cin >> s;
    map<int, int> lst;
    int dp[s.size()], ten[s.size()];
    dp[0] = s[s.size()-1]-'0';
    ten[0] = 1;
    for(i = 1; i < s.size(); i++){
        ten[i] = (ten[i-1]*10)%2019;
    }
    for(i = 1; i < s.size(); i++){
        dp[i] = (dp[i-1] + ten[i] * (s[s.size()-i-1]-'0'))%2019;
    }
    for(i = 0; i < s.size(); i++){
        if(dp[i] == 0)ans++;
        if(lst.count(dp[i])) lst[dp[i]]++;
        else lst[dp[i]] = 1;
    }
    for(auto l : lst){
        auto value = l.second;
        ans += value*(value-1)/2;
    }
    cout << ans << endl;
}

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

string s;
int main() {
  cin >> s;
  
  int mn = 1e9;
  for (int x : { 0, 1 }) {
    int y = x;
    int sum = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] - '0' != y) ++sum;
      y = !y;
    }
    mn = min(mn, sum);
  }
  cout << mn << endl;
}

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

int main()
{
    int a,b,n,ans;
    while(cin >> a >> b >> n){
       ans = 0;
       a %= b;
       for(int i = 0; i < n; ++i){
           a *= 10;
           ans += a / b;
           a %= b;
       }
       cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    ll n,k;
    cin>>n>>k;
    map<ll,ll> abmap;
    
    for(ll i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        abmap[a]+=b;
    }
    ll sum=0;
    for(const auto& item:abmap){
        sum+=item.second;
        if(sum>=k){
            cout<<item.first<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int tc=1;
void solve()
    { 
        int n;
        cin>>n;
        string s;
        cin>>s;
        if(n&1==1)
        {
            cout<<"No";
            return;
        }
        if(s.substr(0,n/2)==s.substr(n/2,n/2))
        {
            cout<<"Yes";
            return;
        }
        else
        {
            cout<<"No";
            return;
        }
        

    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    //wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}







Measured memory_bytes: 10636
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,k;
    cin>>k>>n;
    ll sum=0;
    fori(n){ll a;cin>>a;sum+=a;}
    if(k<=sum){cout<<"Yes";}
    else{cout<<"No";}
    
//code ends
    return 0;
}


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

using namespace std;

int a[200005], res[200005];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	int xsum = 0;
	for (int i = 1; i < n; i += 2) xsum ^= (a[i] ^ a[i - 1]);
	
	for (int i = 0; i < n; i++) {
		res[i] = xsum ^ a[i];
		if (i == 0) printf("%d", res[i]);
		else printf(" %d", res[i]);
	}

	printf("\n");
}


Measured memory_bytes: 5284
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,i;
char s[100];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n&1)
	{
		printf("No");
		return 0;
	}
	for(i=1;i<=n;++i)
		if(i&1)
		{
			if(s[i]!='h')
				break;
		}
		else
		{
			if(s[i]!='i')
				break;
		}
	if(i<=n)
		printf("No");
	else
	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

#　素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# ここから書き始める
x = int(input())
total = 0
ans = 0
while True:
    if total >= x:
        print(ans)
        break
    ans += 1
    total += ans

Measured memory_bytes: 64492
n = int(input())
a = list(map(int, input().split()))
l = []
rate = ['gray', 'brown', 'green', 'water', 'blue', 'yellow', 'orange', 'red']
count = 0

for i in range(n):
    q, r = divmod(a[i], 400)
    if q >= 8:
        count += 1
    else: l.append(rate[q])

print(max(len(set(l)), 1), len(set(l))+count)

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.tie(0)
#define MAXX 100005

int n , m , x;

int main()
{
    _FastIO;
    cin >> n;
    string ans = "Yes";
    for(int i = 0; i < n; i++){
        cin >> x;
        if(m > x)
            ans = "No";
        m = max(m , x - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n,m = map(int,input().split())
    p = []
    s = []
    for i in range(m):
        a,b = input().split()
        p.append(int(a) - 1)
        s.append(b)
    ac = [[0,False] for i in range(n)]
    for i in range(m):
        if ac[p[i]][1]:
            continue
        else:
            if s[i] == 'WA':
                ac[p[i]][0] += 1
            else:
                ac[p[i]][1] = True
    ans = 0
    pena = 0
    for i in range(n):
        if ac[i][1]:
            ans += 1
            pena += ac[i][0]
    print(ans,pena)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 75860