akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int ans1 = 0;
    int ans2 = 0;

    char b;

    b = '0';
    for (int i = 0; i < s.length(); i++) {
        if (b == s[i]) {
            ans1++;
            b = (b == '0' ? '1' : '0');
        } else {
            b = s[i];
        }
    }

    b = '1';
    for (int i = 0; i < s.length(); i++) {
        if (b == s[i]) {
            ans2++;
            b = (b == '0' ? '1' : '0');
        } else {
            b = s[i];
        }
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

int main()
{
	int mod = 0;
	std::string text;
	std::cin >> text;

	for (char ch : text) {
		char num[2] = { ch, '\0', };
		int input = std::stoi(num);
		mod += input;
		mod %= 9;
	}

	bool isMultiple = (mod == 0);
	std::string output = (isMultiple) ? "Yes" : "No";
	std::cout << output << std::endl;
	return 0;
}

Measured memory_bytes: 3732
N = int(input())
A = []
r = 0
for i in range(N):
    A.append((int(input()), i))

A_sorted = sorted(A, reverse=True, key=lambda x: x[0])
A_sorted = list(enumerate(A_sorted))
A = sorted(A_sorted, key=lambda x: x[1][1])

for r, t in A:
    a, _ = t
    if r == 0:
        print(A_sorted[1][1][0])
    else:
        print(A_sorted[0][1][0])

Measured memory_bytes: 55784
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>

static void B_CanYouSolveThis();

int main()
{
	B_CanYouSolveThis();

	fflush(stdout);
	return 0;
}

static void B_CanYouSolveThis()
{
	int N = 0, M = 0;
	int A[20][20] = { 0 };
	int B[20] = { 0 };
	int C = 0;

	scanf(" %d %d %d", &N, &M, &C);

	for (int i = 0; i < M; i++) {
		scanf(" %d", &B[i]);
	}

	int sum = 0;
	int solveCnt = 0;
	for (int i = 0; i < N; i++) {
		sum = 0;
		for (int j = 0; j < M; j++) {
			scanf(" %d", &A[i][j]);

			sum += A[i][j] * B[j];
		}
		if ((sum + C) > 0) {
			solveCnt++;
		}
	}

	printf("%d\n", solveCnt);
}



Measured memory_bytes: 256
#!/usr/bin/env python3

class UnionFind():
        def __init__(self, n):
            self.parents = list(range(n))
            self.size = [1] * n
    
        def find(self, x):
            if self.parents[x] == x:
                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:
                if self.parents[x] > self.parents[y]:
                    x, y = y,x
                self.parents[y] = x
                self.size[x] += self.size[y]

def main():
    N, M, K = map(int, input().split())
    friend_adj = [[] for _ in range(N)]
    block_adj = [[] for _ in range(N)]
    uf = UnionFind(N)

    for _ in range(M):
        a, b = map(lambda x: int(x)-1, input().split())
        friend_adj[a].append(b)
        friend_adj[b].append(a)
        uf.union(a,b)
    for _ in range(K):
        c, d = map(lambda x: int(x)-1, input().split())
        if uf.find(c) == uf.find(d):
            friend_adj[c].append(d)
            friend_adj[d].append(c)

    ans = [uf.size[uf.find(i)]-1 for i in range(N)]

    for i in range(N):
        ans[i] -= len(friend_adj[i])        
        # for b in block_adj[i]:
        #     if uf.find(b) == uf.find(i):
        #         ans[i] -= 1
    print(*ans)
    
    
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 44624
using System;
using System.Linq;

namespace _0518
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[] x = new int[n]; int[] y = new int[n]; bool[,] isthere = new bool[5010,5010];
                for (int i = 0; i < n; i++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    x[i] = a[0]; y[i] = a[1]; isthere[x[i],y[i]] = true;
                }
                long max = 0;
                for (int i = 0; i < n; i++)
                {
                    for (int j = i + 1; j < n; j++)
                    {
                        long xsa = x[i] - x[j]; long ysa = y[i] - y[j];
                        if (5010 > x[i] - ysa && x[i] - ysa >= 0 &&
                            5010 > y[i] + xsa && y[i] + xsa >= 0 &&
                            5010 > x[j] - ysa && x[j] - ysa >= 0 &&
                            5010 > y[j] + xsa && y[j] + xsa >= 0)
                        {
                            if (isthere[x[i] - ysa,y[i] + xsa] && isthere[x[j] - ysa,y[j] + xsa])
                                max = Math.Max(max,xsa * xsa + ysa * ysa);
                        }
                        if (5010 > x[i] + ysa && x[i] + ysa >= 0 &&
                            5010 > y[i] - xsa && y[i] - xsa >= 0 &&
                            5010 > x[j] + ysa && x[j] + ysa >= 0 &&
                            5010 > y[j] - xsa && y[j] - xsa >= 0)
                        {
                            if (isthere[x[i] + ysa,y[i] - xsa] && isthere[x[j] + ysa,y[j] - xsa])
                                max = Math.Max(max,xsa * xsa + ysa * ysa);
                        }
                    }
                }
                Console.WriteLine(max);
            }
        }
    }
}


Measured memory_bytes: 83664
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=1,ans2=2,d;
    cin>>n;
    if(n==1){
        cout<<1<<endl;
    }
    else{
        f(i,0,n-1){
            d=ans;
            ans+=ans2;
            ans2=d;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int x; cin >> x;
    x ^= 1;
    cout << x << '\n';
    
}


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

int main() {
    int N;
    string S;
    string ans = "Yes";
    cin >> N >> S;
    while (true) {
        if (N % 2 == 1) {
            ans = "No";
            break;
        }
        for (int i = 0; i < N / 2; i++) {
            int j = N / 2 + i;
            if (S[i] != S[j]) {
                ans = "No";
                break;
            }
        }
        break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  char C = (S[0]=='A'?'A':'B');
  bool ans = false;
  for(char c:S) { if(c != C) ans = true; }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[100005];
int ss[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&s[i]);
    int l=0;
    for(int i=1;i<=n;i++){
        ss[i]=abs(s[i]-l)+ss[i-1];
        l=s[i];
    }
    for(int i=1;i<=n;i++){
        if(i!=n)
        printf("%d\n",ss[i-1]+abs(s[i+1]-s[i-1])+ss[n]-ss[i+1]+abs(s[n]));
        else printf("%d\n",ss[n-1]+abs(s[n-1]));
    }
    return 0;
}


Measured memory_bytes: 2048
n = int(input())
dp = [[[[0 for _ in range(4)]for _ in range(4)]for _ in range(4)]for _ in range(n+1)]
dp[0][3][3][3]=1
for i in range(n):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    if k==0 and l==2 and m==1: continue
                    elif k==2 and l==0 and m==1: continue
                    elif k==0 and l==1 and m==2: continue
                    elif j==0 and l==2 and m==1: continue
                    elif j==0 and k==2 and m==1: continue
                    else: dp[i+1][k][l][m]+=dp[i][j][k][l]
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[n][i][j][k]
print(ans%(10**9+7))

Measured memory_bytes: 3444
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
s = list(map(int,input()))

ue = 10*s[0] + s[1]
shita = 10*s[2] + s[3]

if 0 < ue < 13:
  if 0 < shita < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < shita < 13:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n,m;
  cin>>n>>m;
  int w[30];
  rep(i,n)w[i] = i + 1;
  while(m--){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(w[--a],w[--b]);
  }
  rep(i,n)cout<<w[i]<<endl;
}

Measured memory_bytes: 1240
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 200000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
int ans = INF;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int H, W, K;
string S[810];
int d[810][810];
void bfs(int a, int b) {
    rep(i, H) rep(j, W) d[i][j] = INF;
    d[a][b] = 0;
    queue<P> que;
    que.push({a, b});
    int Ld = a;
    int Rd = H - a - 1;
    int Ud = b;
    int Dd = W - b - 1;
    int tmp = (min({Ld, Rd, Ud, Dd}) + K - 1) / K;
    ans = min(ans, tmp + 1);
    while(que.size()) {
        P p = que.front(); que.pop();
        
        int x = p.first;
        int y = p.second;
        rep(k, 4) {
            int xx = x + dx[k];
            int yy = y + dy[k];
            
            if(xx < 0 || xx >= H || yy < 0 || yy >= W) continue;
            if(S[xx][yy] == '#') continue;
            if(d[xx][yy] != INF) continue;
            if(xx == 0 || xx == H - 1 || yy == 0 || yy == W - 1) 
                ans = 1;
            d[xx][yy] = d[x][y] + 1;
            int Ld = xx;
            int Rd = H - xx - 1;
            int Ud = yy;
            int Dd = W - yy - 1;
            int tmp = (min({Ld, Rd, Ud, Dd}) + K - 1) / K;
            ans = min(ans, tmp + 1);
            if(d[xx][yy] < K) {
                que.push({xx, yy});
            }
        }
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> W >> K;
    
    rep(i, H) cin >> S[i];
    rep(i, H) {
        rep(j, W) {
            if(S[i][j] == 'S') bfs(i, j);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6808
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	string S;
	cin >> S;

	string ans = "Yes";

	rep(i, S.length()) {
		if (i%2 == 0) {
			if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {

			} else {
				ans = "No";
				break;
			}
		} else {
			if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {

			} else {
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
require 'prime'

MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  res = 1
  i = k
  j = 1
  while i > 0
    res = res * (n - i + 1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def repeated_nCk(n, k)
  # 仕切りのイメージで
  nCk(n + k - 1, n - 1) % MOD
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

n, m = gets.split.map(&:to_i)
factor_counts = m.prime_division.map { |factor, count| count }
puts factor_counts.inject(1) { |res, count| res * repeated_nCk(n, count) } % MOD


Measured memory_bytes: 2044
import sys

N = int(input())
S = input()

if "#" not in S or "." not in S:
    print(0)
    sys.exit(0)

# all_dot = len([s for s in S if s == "#"])

ans = 1e20
num = 0
all_dot = int(S[0]=="#")
for i in range(1, len(S)):
    if S[i-1] == "." and S[i] == "#":
        num = min(num, all_dot)

    if S[i] == '#':
        all_dot += 1
    else:
        num += 1

ans = min(all_dot, num)
print(ans)


Measured memory_bytes: 3628
#include <cstdio>

using namespace std;

int c[3][3];

bool check() {
  if (c[0][0] - c[0][1] != c[1][0] - c[1][1]) {
    return false;
  }
  if (c[1][0] - c[1][1] != c[2][0] - c[2][1]) {
    return false;
  }
  if (c[0][1] - c[0][2] != c[1][1] - c[1][2]) {
    return false;
  }
  if (c[1][1] - c[1][2] != c[2][1] - c[2][2]) {
    return false;
  }
  if (c[0][0] - c[1][0] != c[0][1] - c[1][1]) {
    return false;
  }
  if (c[0][1] - c[1][1] != c[0][2] - c[1][2]) {
    return false;
  }
  if (c[1][0] - c[2][0] != c[1][1] - c[2][1]) {
    return false;
  }
  if (c[1][1] - c[2][1] != c[1][2] - c[2][2]) {
    return false;
  }
  return true;
}

int main() {
  for (int i = 0; i < 3; i++) {
    scanf("%d %d %d", &c[i][0], &c[i][1], &c[i][2]);
  }
  bool ans = check();
  if (ans) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
lis = list(map(int, input().split()))

if lis.count(0) == n:
    print('Yes')
elif n % 3 != 0:
    print('No')
elif len(set(lis)) == 2:
    if 0 in set(lis):
        if lis.count(0) == n/3:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(set(lis)) == 3:
    xor = 0
    for  a in set(lis):
        if lis.count(a) == n/3:
            xor ^= a
        else:
            print('No')
            exit()
    if xor == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 20452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{

	public static void main(String[] args) throws IOException
	{
		int m;
		String strSub;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

        while(true)
        {
    		String str = br.readLine();
    		
    		if(str.equals("-") ) break;
    		
    		String strM = br.readLine();
    
    		m = Integer.parseInt(strM);
    		int[] h = new int[m];
    		
    		for(int i=0; i<m; i++)
            {
                String strH = br.readLine();
                h[i] = Integer.parseInt(strH);
                
        		strSub = str.substring(0, h[i]);
        
        		str += strSub;
        		
        		str = str.substring(h[i]);
            }
            
            System.out.println(str);
            
        }
	}
}

Measured memory_bytes: 24408
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//計算量はO(log max(a,b))
ll lcm(ll x,ll y){
  ll mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    ll temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return x*(y/mindata);
}


signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    ll M;
    ll a[110000];
    cin>>N>>M;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    ll x=1;
    for(int i=0;i<N;i++){
        x=lcm(x,a[i]/2);
    }
    bool flag=true;
    for(int i=0;i<N;i++){
        if((x-a[i]/2)%a[i]!=0) flag=false; 
    }
    if(!flag){
        cout<<0<<endl;
        return 0;
    }
    /*if(!flag) x*=2;
    flag=true;
    for(int i=0;i<N;i++){
        if((x-a[i]/2)%a[i]!=0) flag=false; 
    }
    if(!flag) x=x/2*3;*/

    ll y=1;
    for(int i=0;i<N;i++){
        y=lcm(y,a[i]);
    }
    ll ans=0;
    //cout<<x<<endl;
    //cout<<y<<endl;    

    if(x<=M){
        ans++;
        ans+=(M-x)/y;
    }
    cout<<ans<<endl;
}


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

int main(){
  string nw;
  while(1){
    int an=0,n=1;
    cin>>nw;
    if(nw[0]=='#')break;
    if(nw[nw.size()-4]=='w')an=90;
    for(int i=nw.size()-7;i>=0;i--){
      if(nw[i]=='w')n*=2,an*=2,an+=90;
      if(nw[i]=='n')n*=2,an*=2,an-=90;
    }
    while(an%2==0&&n>1)an/=2,n/=2;
    cout<<an;
    if(n!=1&&an!=0)cout<<'/'<<n;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int main()
{
  int I, J, K, L, M, N, S;
  double i, j, k;
  char ch[3];
  bool check;
  cin >> ch;
  if(ch[0]==ch[1] && ch[1]==ch[2]){
    check = false;
  }else{
    check = true;
  }

  if (check)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
}

Measured memory_bytes: 256
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<30;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=1010;
char a[N], b[N];

int main(){
    scanf("%s",&a);
    scanf("%s",&b);

    int n=strlen(a);
    int m=strlen(b);

    int ans=inf;
    for(int i=0 ; i<n ; i++){
        if(i+m > n) break;
        int cnt=0;
        for(int j=0 ; j<m ; j++){
            if(a[i+j] != b[j])
                cnt++;
        }

        ans=min(ans, cnt);
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 3824
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N, K, Q = [int(n) for n in input().split()]
    A = [0 for _ in range(N)]
    for _ in range(Q):
        A[int(input())-1] += 1
    for i in range(N):
        if Q - A[i] < K:
            print("Yes")
        else:
            print("No")



if __name__ == "__main__":
    main()


Measured memory_bytes: 4672
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;


int main(void){
    string S;cin>>S;
    REP(i,S.size()){
        if((i+1)%2!=0&&S[i]=='R'||S[i]=='U'||S[i]=='D'){
            continue;
        }else if((i+1)%2==0&&S[i]=='L'||S[i]=='U'||S[i]=='D'){
            continue;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}




Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([]int, n)

	for i := range s {
		s[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(s))
	ans := float64(s[0])
	for i := 1; i < n; i++ {
		ans = (ans + float64(s[i])) / 2
	}
	_, _ = fmt.Fprintf(writer, "%.10f", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);       
       int K = scan.nextInt();
       int X = scan.nextInt();
       if(K*500>=X){
           System.out.println("Yes");
       }else{
           System.out.println("No");
       }       
    }  
}


Measured memory_bytes: 20820
#include<stdio.h>

int n,A[50];

//入力値のMから選んだ要素を引いていく再帰関数
int solve(int i,int m){
    if(m==0) return 1; //成功
    if(i>=n) return 0; //失敗
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(void){
    int q,M,i;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&M);
        if(solve(0,M)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2100
while True:
	m, f, r = map(int, raw_input().split())
	if m + f + r == -3: break

	if m == -1 or f == -1:
		grade = 'F' 
	elif m + f >= 80:
		grade = 'A'
	elif m + f >= 65:
		grade = 'B'
	elif m + f >= 50:
		grade = 'C'
	elif m + f >= 30:
		grade = 'C' if r >= 50 else 'D' 
	elif m + f < 30:
		grade = 'F'
	print grade

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a > 0 || c > 0){
    if(c - b <= 0){
      cout << "Yes" << endl;
      break;
    }
    else if(a - d <= 0){
      cout << "No" << endl;
      break;
    }
    c -= b;
    a -= d;
  }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d; cin >> n >> d;
    if(n%(2*d+1) == 0){
        cout << n/(2*d+1) << endl;
    }else{
        cout << n/(2*d+1)+1 << endl;
    }
}

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


char name[120];
pair<pair<string,int>,int> p[110];
int main(){
    int N;
    cin>>N;
    for(int i = 0; i<N;i++){
        int num;
        cin>>name>>num;
        string tmp = name;
        p[i]=make_pair(make_pair(tmp,-num),i);

    }
    sort(p,p+N);
    for(int i = 0 ; i<N;i++){
        cout<<p[i].second+1<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
const int inf = 1000000000; // 10^9

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    int ans = inf;
    for (int i = 1; i <= 100; i++)
    { 
        int cost = 0;
        rep(j, N) cost += (X[j] - i) * (X[j] - i);
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <vector>
#include <algorithm>



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


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;

int n,m,u,v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];


int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to: eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};
using namespace std;
int main(){
    int n;
    cin >> n;

    string s = "ACL";

    REP(i,n){
        cout << s;
    }
    cout <<endl;
}





Measured memory_bytes: 6208
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<vector<ll>> v(n, vector<ll>(3, 0));
    REP(i,n) REP(j,3) cin >> v[i][j];
    ll ans = -LINF*8;
    for (int bit = 0; bit < (1 << 3); ++bit) {
        vector<ll> a(n, 0);
        REP(i,n) {
            REP(j,3) {
                ll tmp = v[i][j];
                if (bit & (1 << j)) tmp *= -1ll;
                a[i] += tmp;
            }
        }
        sort(a.begin(), a.end(), greater<ll>());
        ll cans = 0;
        REP(i,m) cans += a[i];
        ans = max(ans, cans);
    }
    cout << ans << std::endl;
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> X(N);
  for (ll i = 0; i < N; i++) cin >> X.at(i);
  ll vmin = LLONG_MAX;
  for (ll p = 1; p <= 100; p++) {
    ll tot = 0;
    for (ll i = 0; i < N; i++) {
      ll dist = X.at(i) - p;
      tot += dist * dist;
    }
    if (tot < vmin) vmin = tot;
  }
  cout << vmin << endl;

  return 0;
}



Measured memory_bytes: 256
N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
mini = 1000000000
for i in range(N - K + 1):
    if min(abs(x[i]), abs(x[i + K - 1])) + abs(x[i + K - 1 ] - x[i]) < mini:
        mini = min(abs(x[i]), abs(x[i + K - 1])) + abs(x[i + K - 1 ] - x[i])

print(mini)

Measured memory_bytes: 14384
#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>
#include <cmath>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvl vector<vector<ll>> 


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
using namespace std;

double PI = (acos(-1));

ll md = 1000000007;
ll ma = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
}
//vst vect={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};




// AB DEKHO JAADU...

void solve(){
    ll x,y;
    cin>>x>>y;
    ll p=(y-(4*x))/2;
    if(y>4*x||y<2*x)cout<<"No";
    else{if((y-(4*x))%2==0)cout<<"Yes";
    else cout<<"No";
    }
}

    
    


int main(){
    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }

    return 0;
    }

// KHATAM HO GAYA:)...





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

const int MAXN = 1e5+100;
char str[MAXN];

int main()
{
	scanf("%s",str);
	int Len=strlen(str);
	int l=0,r=Len-1;
	int pos=-1,L=-1,R=-1;
	bool suc=true;
	int ans=0;
	while(l<=r)
	{
		L=l,R=r;
		while(l<Len&&str[l]=='x')	++l;
		while(r>=0&&str[r]=='x')	--r;
		if(r<l)	break;
		ans+=(max(l-L,R-r)-min(l-L,R-r));
		if(str[l]!=str[r])
		{
			suc=false;
			break;
		}
		++l,--r;
	}
	if(suc)
	{
		cout<<ans<<endl;
	}else cout<<"-1"<<endl;
	return 0;
}


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

int gcd(int m, int n){
    if(m < n){
        int t = m;
        m = n;
        n = t;
    }
    if(n > 0){
        return gcd(n, m%n);
    }else{
        return m;
    }

}

int main(){
    int N, X;
    int city[100010];
    int dist[100010];

    cin >> N >> X;
    for (int i = 0; i < N; ++i){
        cin >> city[i];
        dist[i] = abs(city[i] - X);
    }

    int D = gcd(dist[0],dist[1]);
    for(int i = 0; i < N; ++i){
        D = gcd(dist[i],D);
    }

    cout << D << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 1<<21;
int N, n, k;
int A[MAX_N];
int dat[2*MAX_N-1];

void init(int n_)
{
	n = 1<<20;
}

void update(int k, int a)
{
	k+=n-1;
	dat[k]=max(dat[k],a);
	while(k>0){
		k=(k-1)/2;
		dat[k]=max(dat[k*2+1],dat[k*2+2]);
	}
}

int query(int a, int b, int k, int l, int r)
{
	if(r<=a||b<=l) return 0;
	if(a<=l&&r<=b) return dat[k];
	else return max(query(a,b,k*2+1,l,(l+r)/2), query(a,b,k*2+2,(l+r)/2,r));
}

void solve()
{
	init(N);
	int res = 1;
	for(int i=0;i<N;++i){
		const int mi = max(0, A[i]-k);
		const int mx = min(MAX_N, A[i]+k);
		int best = query(mi,mx+1,0,0,n)+1;
		res = max(res, best);
		update(A[i], best);
	}
	cout<<res<<'\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N >> k;
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 7196
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

long long maxVal(long long a, long long b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}

int main(int argc, const char * argv[]) {

    string S;
    cin >> S;
    long long N = S.size()+1;
    char s[N-1];
    S.copy(s,N-1);
    //s[N] = '\0';

    long long a[N];
    long long i=0;

    long long plus[N];
    long long minus[N];
    for(i=0;i<=N-1;i++){
        plus[i]=0;
        minus[i]=0;
    }

    for(i=0;i<N-1;i++){
        if(s[i]=='<'){
            plus[i+1] = plus[i] + 1;
        }
    }

    for(i=N-2;i>=0;i--){
        if(s[i]=='>'){
            minus[i] = minus[i+1] + 1;
        }    
    }

    for(i=0;i<N;i++){
        a[i] = maxVal(plus[i],minus[i]);
    }


    long long sum = 0;
    for(i=0;i<N;i++){
        sum += a[i];
    }
    cout << sum <<endl;
    // source code
    
    return 0;
}

Measured memory_bytes: 13060
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;



int main() {
	int n, k;
	cin >> n >> k;
	VI l(n);
	rep(i, 0, n) scanf("%d", &l[i]);
	sort(ALL(l), greater<int>());

	cout << accumulate(&l[0], &l[k], 0) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = n; i < 10000000; i++){
        for(int j = 2; j <= i; j++){
            if(i % j == 0)
                break;
            if(j == i/2)
                ans = i;
        }
        if(ans != 0)
            break;
    }
    if(n == 2 || n == 3)
        ans = n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

isnewLine = False

pattern = {"0": "* = ****",
           "1": "* =* ***",
           "2": "* =** **",
           "3": "* =*** *",
           "4": "* =**** ",
           "5": " *= ****",
           "6": " *=* ***",
           "7": " *=** **",
           "8": " *=*** *",
           "9": " *=**** ",
           }

for line in sys.stdin:

    if isnewLine:
        print()
    else:
        isnewLine = True

    line = line[:-1]

    line = "0" * (5 - len(line)) + line

    bar = [pattern[item] for item in line]

    for i1, i2, i3, i4, i5 in zip(bar[0], bar[1], bar[2], bar[3], bar[4]):
        print(i1 + i2 + i3 + i4 + i5)



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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

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

#define N 200010
#define MOD 1000000007


int f[1000010];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    int ar1[a + 1], ar2[b + 1], ar3[c + 1];

    for (int i = 0; i < a; ++i)
    {
        cin >> ar1[i];
    }
    for (int i = 0; i < b; ++i)
    {
        cin >> ar2[i];
    }
    for (int i = 0; i < c; ++i)
    {
        cin >> ar3[i];
    }

    ar1[a] = ar2[b] = ar3[c] = -1;

    sort(ar1, ar1 + a, greater<int>());
    sort(ar2, ar2 + b, greater<int>());
    sort(ar3, ar3 + c, greater<int>());

    int i = 0, j = 0, k = 0;
    int cnt1 = 0, cnt2 = 0, ans = 0, no = 0;
    while (cnt1 + cnt2 + no < x + y)
    {
        int ma = 0, f = 0;
        if (cnt1 < x && cnt2 < y)
        {
            if (ar1[i] > ar2[j])
                ma = ar1[i];
            else
                ma = ar2[j], f = 1;
        }
        else if (cnt1 == x)
        {
            ma = ar2[j], f = 1;
        }
        else
        {
            ma = ar1[i];
        } 

        if (k < c)
        {
            if (ar3[k] > ma)
            {
                ma = ar3[k], k++;
                no++;
            }
            else if (f) j++, cnt2++;
            else i++, cnt1++;
        }
        else if (f) j++, cnt2++;
        else i++, cnt1++;

        // cout << ma << "\n";
        ans += ma;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long  n,res,count=1;
  cin>>n;
  if(n%2==0||n%5==0)
     count=-1;
  else{
     long long  m=7%n;
    while(m!=0){
    m=(m*10+7)%n;
      count++;
    }
  }
    cout<<count<<"\n";
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
char g[2222][2222];
int val[2222][2222];
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>g[i][j];
	for(int i=0;i<n;i++)
	{
		int now=0;
		for(int j=0;j<m;j++)
		{
			val[i][j]+=now;
			if(g[i][j]=='.')
				now++;
			else
				now=0;
		}
		now=0;
		for(int j=m-1;j>=0;j--)
		{
			val[i][j]+=now;
			if(g[i][j]=='.')
				now++;
			else
				now=0;
		}
	}
	for(int j=0;j<m;j++)
	{
		int now=0;
		for(int i=0;i<n;i++)
		{
			val[i][j]+=now;
			if(g[i][j]=='.')
				now++;
			else
				now=0;
		}
		now=0;
		for(int i=n-1;i>=0;i--)
		{
			val[i][j]+=now;
			if(g[i][j]=='.')
				now++;
			else
				now=0;
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(g[i][j]!='#')
				ans=max(ans,val[i][j]);
		}
	}
	cout<<ans+1<<"\n";
	return 0;
}


Measured memory_bytes: 23808
#include <stdio.h>
#include <algorithm>
int n, k, s, m, t, ans, x;
int a[500], b[500];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		s += a[i];
	}
	for (int i = 1; i < 23000; i++) {
		if (s % i == 0) {
			m = s / i;
			t = 0;
			for (int j = 0; j < n; j++) {
				b[j] = a[j] % m;
				t += b[j];
			}
			std::sort(b, b + n);
			t /= m;
			t = n - t;
			x = 0;
			for (int j = 0; j < t; j++) {
				x += b[j];
			}
			if (x <= k)ans = m;
		}
		if (ans) {
			printf("%d\n", ans);
			return 0;
		}
	}
	for (int i = 23000; i > 0; i--) {
		if (s % i == 0) {
			m = i;
			t = 0;
			for (int j = 0; j < n; j++) {
				b[j] = a[j] % m;
				t += b[j];
			}
			std::sort(b, b + n);
			t /= m;
			t = n - t;
			x = 0;
			for (int j = 0; j < t; j++) {
				x += b[j];
			}
			if (x <= k)ans = m;
		}
		if (ans) {
			printf("%d\n", ans);
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define in read()
#define re register
#define fur(i,a,b) for(re int i=a;i<=b;++i)
#define fdr(i,a,b) for(re int i=a;i>=b;--i)
#define cl(a,b) memset(a,b,sizeof(a))
#define jinitaimei signed
#define int long long
inline int read()
{
	int x=0;
	char ch=getchar();
	for(;!isalnum(ch);ch=getchar());
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}
const int xx=1e5+1612;
int to[xx][18];
int x[xx],n,L;
inline void init()
{
	n=in;
	fur(i,1,n) x[i]=in;
	L=in;
	int j=n;
	to[n][0]=j;
	fdr(i,n-1,1)
	{
		while(x[j]-x[i]>L) --j;
		to[i][0]=j;
	}
	fur(k,1,17) fur(i,1,n) to[i][k]=to[to[i][k-1]][k-1];
}
inline int power(int b,int k)
{
	int res=1;
	for(;k;k>>=1,b=b*b) if(k&1) res=res*b;
	return res;
}
inline void sol(int a,int b)
{
	if(a>b) swap(a,b);
	int j=a,g=17;
	int ans=0;
	while(j<b)
	{
		while(to[j][g]>b&&g) --g;
		if(b==n) while(to[j][g]==b&&g) --g;
		j=to[j][g];
		ans+=power(2,g);
	}
	printf("%lld\n",ans);
}
jinitaimei main()
{
	init();
	int T=in;
	while(T--) sol(in,in);
	return 0;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    s = '#' + s + '#';
    if (c < d) {
        for (int i = a; i < d; i++) if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No";
            return 0;
        }
        cout << "Yes";
    } else {
        bool y = 0;
        for (int i = b; i <= d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') y = 1;
        for (int i = a; i < c; i++) if (s[i] == '#' && s[i + 1] == '#') y = 0;
        if (y) cout << "Yes";
        else cout << "No";
    }
}


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

int N,A[100],swapcount;

inline void Initial() {
  std::ios::sync_with_stdio(false);
  cout.tie(0); cin.tie(0);
}
inline void Input() {
  cin>>N;
  for (int i=0; i<N; i++) {
    cin>>A[i];
  }
}
inline void SelectionSort() {
  for (int i=0; i<N; i++) {
    int minj=i;
    for (int j=i; j<N; j++) {
      if (A[j]<A[minj]) {
        minj=j;
      }
    }
    swap(A[i],A[minj]);
    if (i!=minj) {
      swapcount++;
    }
  }
}
inline void Output() {
  for (int i=0; i<N; i++) {
    if (i) {
      cout<<" "<<flush;
    }
    cout<<A[i]<<flush;
  }
  cout<<endl;
  cout<<swapcount<<endl;
}
int main() {
  Initial(),Input(),SelectionSort(),Output();
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,d,x;cin >> n >> d >> x;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans=x;
	rep(i,n){
		ans+=(d-1)/a.at(i)+1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   int n;
   cin >> s;
   n = s.length();
   int c1 = 0,c2 = 0;
   f(i,0,n){
      if(i&1){
         if(s[i]=='0'){
            c1++;
         }
         if(s[i]=='1'){
            c2++;
         }
      }else{
         if(s[i]=='0'){
            c2++;
         }
         if(s[i]=='1'){
            c1++;
         }
      }
   }
   cout << min(c1,c2) << '\n';
   return 0;
} 

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define Rrep(i, m, n) for(int i=(m);i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int space[100][100];
bool flag[100][100];
int w, h;
int sx, sy;
int gx, gy;
int n;

bool bfs() {
  queue<Pii> q;
  int start_color = space[sy][sx];
  q.push( Pii(sy, sx) );

  while( !q.empty() ) {
    Pii p = q.front(); q.pop();
    int x = p.sc, y = p.fr;
    flag[y][x] = true;
    if( x == gx && y == gy ) return true;
    Rep(i, 4) {
      int nx = x+dx[i], ny = y+dy[i];
      if( nx >= 0 && ny >= 0 && nx < w && ny < h && !flag[ny][nx] && space[ny][nx] == start_color ) {
	q.push( Pii(ny, nx) );
      }
    }
  }

  return false; 
}

int main()
{
  while( cin >> w >> h, w+h ) {
    fill_n(*space, 100*100, 0);
    fill_n(*flag, 100*100, false);
    cin >> sx >> sy; sx--; sy--;
    cin >> gx >> gy; gx--; gy--;
    cin >> n;

    Rep(i, n) {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      x--; y--;
      if( d == 0 ) {
	Rep(j, 2) {
	  Rep(k, 4) {
	    space[y+j][x+k] = c;
	  }
	}
      } else {
	Rep(j, 4) {
	  Rep(k, 2) {
	    space[y+j][x+k] = c;
	  }
	}
      }
    }

    if( bfs() ) cout << "OK" << endl;
    else cout << "NG" << endl;
  }

}

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

using namespace std;

#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(x)  (x).begin(), (x).end()
#define ll long long

int main()
{
	int X;

	cin >> X;

	if (X == 3 || X == 5 || X == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int

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

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

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

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



int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n,k;
cin>>n>>k;
int a[n];
ll s=0;
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
if(k>=n)
{
    cout<<"0";
    return 0;
}
sort(a,a+n);
for(int i=0;i<(n-k);i++)
{
    s+=a[i];
}
cout<<s;


    return 0;
}

Measured memory_bytes: 1024