akhauriyash/Code-Regression huggingface dataset:
#70c
from functools import reduce
import math
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())

T_set = set()

for _ in range(N):
    t = int(input())
    T_set.add(t)
    
T_list = list(T_set)
print(lcm_list(T_list))

Measured memory_bytes: 5512
x,n = (int(x) for x in input().split())
la = list(map(int, input().split()))
lb = list(range(0,102))
li = list(filter(lambda y: y not in la, lb))
ld = [abs(x-a) for a in li]
s = ld.index(min(ld))
print(li[s])

Measured memory_bytes: 9188
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vi adj[222222];
int h[222222];
set<int> S[3];
int a[222222];
void dfs(int u, int p=-1)
{
	for(int v:adj[u])
	{
		if(v==p) continue;
		h[v]=h[u]+1;
		dfs(v,u);
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v;u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	for(int i=1;i<=n;i++)
	{
		S[i%3].insert(i);
	}
	dfs(0,-1);
	vi V[2];
	for(int i=0;i<n;i++)
	{
		V[h[i]&1].pb(i);
	}
	if(V[0].size()>V[1].size()) swap(V[0],V[1]);
	if(V[0].size()<=S[0].size())
	{
		for(int x:V[0])
		{
			a[x]=(*S[0].begin());
			S[0].erase(S[0].begin());
		}
		for(int x:V[1])
		{
			for(int j=0;j<3;j++)
			{
				if(!S[j].empty())
				{
					a[x]=(*S[j].begin());
					S[j].erase(S[j].begin());
					break;
				}
			}
		}
	}
	else
	{
		for(int x:V[0])
		{
			if(!S[2].empty())
			{
				a[x]=(*S[2].begin());
				S[2].erase(S[2].begin());
			}
			else
			{
				a[x]=(*S[0].begin());
				S[0].erase(S[0].begin());
			}
		}
		for(int x:V[1])
		{
			if(!S[1].empty())
			{
				a[x]=(*S[1].begin());
				S[1].erase(S[1].begin());
			}
			else
			{
				a[x]=(*S[0].begin());
				S[0].erase(S[0].begin());
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
		if(i+1<n) cout<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 29032
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int sum=0;
    for(int i=1;i<S.length();i++){
        if(S[i-1]==S[i]){
            sum++;
        }
    }
    cout << min(sum+2*K,N-1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int A, B, K;
    cin >> K >> A >> B;
    for (int x = A; x <= B; x++){
        if ((x % K) == 0){
            cout << "OK" << endl;
            return 0;
        }
        //cout << x << endl;
    }
    cout << "NG" << endl;
}

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

int main() {
    int n, q;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    set<int> st;
    for (int bit = 0; bit < 1 << n; ++bit) {
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            if (bit >> i & 1) sum += A[i];
        }
        st.insert(sum);
    }
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int m;
        cin >> m;
        if (st.count(m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3112
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  vector<string> w(n);
  REP(i,n)cin>>w[i];
  REP(i,n-1){
    if(w[i].substr(w[i].size()-1,1)!=w[i+1].substr(0,1)){
      cout<<"No"<<endl;
      cerr<<"type:1"<<endl;
      cerr<<i<<endl;
      return 0;
    }
  }

  for(int q=0;q<w.size()-1;q++){
    for(int i=q+1;i<w.size();i++){
      if(w[q]==w[i]){
        cout<<"No"<<endl;
        cerr<<"type:2"<<endl;
        cerr<<"q:"<<q<<" i:"<<i<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  rep(i, 0, M) {
    int k; cin >> k;
    rep(j, 0, k) {
      int a; cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  rep(i, 0, M) cin >> p[i];
  int ans = 0;
  rep(i, 0, 1<<N) {
    int cnt2 = 0;
    rep(j, 0, M) {
      int cnt = 0;
      rep(m, 0, s[j].size()) {
        if((i+1) & 1<<s[j][m]) cnt++;
      }
      if(cnt%2 == p[j]) cnt2++;
    }
    if(cnt2 == M) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::cmp::max;


fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let tak: i64 = ws.next().unwrap().parse().unwrap();
    let aok: i64 = ws.next().unwrap().parse().unwrap();
    let eat: i64 = ws.next().unwrap().parse().unwrap();

    let tak_rem = max(tak-eat, 0);
    let eat = eat - (tak - tak_rem);
    let aok_rem = max(aok-eat, 0);
    println!("{} {}", tak_rem, aok_rem);
}

Measured memory_bytes: 4352
//#include<cstdio>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define high 100010
#define bfast cin.tie(0)

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, bool>mpbc;
typedef map<char, LL>mpcll;


int main()
{
    fast;
    string s;
    LL len=0 , i=0;
    while(cin >> s)
    {
        len = s.length();

        if(len == 2)
        {
            if(s[0] == s[i+1]) cout << i+1 << " " << i+2 << "\n";

            else
            {
                cout << "-1 -1\n";
            }

            continue;
        }

        bool f=false;

        for(i=0; i<len-2; i++)
        {
            if(s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2])
            {
                cout << i+1 << " " << i+3 << "\n";
                f=true;
                break;
            }
        }

        if(!f) cout << "-1 -1\n";
    }

    return 0;
}


Measured memory_bytes: 512
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;
using Graph = vector<vector<int>>;

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

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

  int k=(a[n-1]*2-b[n-1])/2;
  for(int i=0;i<n;i++){
    if(i%2==0) cout<<b[i]+k<<endl;
    else cout<<b[i]-k<<endl;
  }

}

Measured memory_bytes: 2432
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(void)
{
    string t, s;
    int n;
    int tl, sl, i, j, count, ma;
    ma = 0;
    cin >> s;
    cin >> t;
    sl = s.length();
    tl = t.length();
    for (i = 0; i < sl - tl + 1; i++)
    {
        count = 0;
        for (j = 0; j < tl; j++)
        {
            if (t[j] == s[i + j])
            {
                count++;
            }
        }
        ma = max(ma, count);
    }
    cout << tl - ma << endl;

    return 0;
}

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

int main(){
   string a,b="CODEFESTIVAL2016";
   cin>>a;
   int c=0;
   for(int i=0;i<a.size();i++) if(a[i]!=b[i])c++;
   cout<<c<<endl;
   return 0;
} 

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

int main() {
	
	int n;
	int **mat;
	
	cin>>n;
	mat = new int*[n];
	for(int i=0;i<n;++i){
		mat[i] = new int[n];
	}
	
	for(int i=0;i<n;++i){
		int id,k,v;
		cin>>id;
		cin>>k;
		
		for(int j=0;j<k;++j){
			cin>>v;
			
			mat[id-1][v-1] = 1;
		}
	}
	
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cout<<(j?" ":"")<<mat[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int N, K, P;
int main()
{
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> K >> P;
		if(K % P)
			cout << K % P << endl;
		else
			cout << P << endl;
	}
}

Measured memory_bytes: 3088
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    S = [("").join(sorted(input().rstrip())) for i in range(N)]
    DICT = {}
    ans = 0
    for i in range(N):
        if S[i] in DICT:
            DICT[S[i]] += 1
            ans += DICT[S[i]]
        else:
            DICT.setdefault(S[i], 0)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 19400
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String str = br.readLine();
        String[] strs = str.split(" ");
        //--- list?????¨??? ---
        for(int i = strs.length-1; i >= 0; i--){
            if(i != 0){
                System.out.print(strs[i] + " ");
            }else{
                System.out.print(strs[i]);
            }//if
        }//for
        System.out.println();
    }
}

Measured memory_bytes: 24252
#include<iostream>
#include<algorithm>

using namespace std;

bool is_equal(int* a, int *b, int n)
{
	for(int i = 0 ; i < n ; i++)
		if(a[i] != b[i])
			return false;
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, ord1, ord2;
	cin >> n;
	int org[n], p[n], q[n];
	for(int i = 0 ; i < n ; i++){
		cin >> p[i];
		--p[i];
		org[i] = i;
	}
	for(int i = 0 ; i < n ; i++){
		cin >> q[i];
		--q[i];
	}
	int i = 0;
	do{
		if(is_equal(org, p, n)) ord1 = i;
		if(is_equal(org, q, n)) ord2 = i;
		++i;
	}while(next_permutation(org, org + n));
	cout << abs(ord1 - ord2) << '\n';	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt();
		int[]in=new int[n];
		for(int i=0;i<n;i++)in[i]=sc.nextInt();
		Arrays.sort(in);
		double prev=in[0];
		
		for(int i=1;i<n;i++) {
			prev=(prev+in[i])/2;
		}
		pw.println(prev);
		pw.flush();
 
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 23124
X, N = map(int,input().split())
A = set(i for i in range(102))
P = set(map(int,input().split()))
B=A-P

min_ = float('inf')
ans = X
for b in B:
    if abs(X-b) < min_:
        min_ = abs(X-b)
        ans = b

print(ans)

Measured memory_bytes: 9136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
string s;
string a[1010];
int b[1010],n,m,tail,ans,flag;
int main()
{
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>s;
		getchar();
		flag=0;
		for(j=1;j<=tail;j++)
		{
			if(s==a[j])
			{
				b[j]++;
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			a[++tail]=s;
			b[tail]=1;
		}
	}
	cin>>m;
	for(i=1;i<=m;i++)
	{
		cin>>s;
		getchar();
		flag=0;
		for(j=1;j<=tail;j++)
		{
			if(s==a[j])
			{
				b[j]--;
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			a[++tail]=s;
			b[tail]=-1;
		}
	}
	for(i=1;i<=tail;i++)
	ans=max(ans,b[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <cstdint>
#include <string>


using namespace std;
class city{
public:
	city(int y,int n):year(y),number(n){}
	int year;
	int number;
};

bool operator<(const city& left, const city& right) {
        return left.year < right .year;
}
bool operator>(const city& left, const city& right) {
        return left.year > right .year;
}


int main() {
	int n,m;
	cin>>n>>m;
	int *city_prefecture=new int[m];
	int *city_number = new int[m];
	vector<city> *pref = new vector<city>[n+1];
	for(int i=0;i<m;i++){
		int p,y;
		cin>>p>>y;
		pref[p].push_back(city(y,i));
		city_prefecture[i]=p;
	}
	for(int i=0;i<=n;i++){
		sort(pref[i].begin(),pref[i].end());
		for(int k=0;k<pref[i].size();k++){
			city_number[pref[i].at(k).number]=k+1;
		}
	}
	for(int i=0;i<m;i++){
		cout<< setfill('0') << setw(6)<<city_prefecture[i];
		cout<< setfill('0') << setw(6)<<city_number[i]<<endl;
	}






	return 0;

}


Measured memory_bytes: 7808
#include<stdio.h>

typedef struct{
  int x, y;
}Place;

int max(int *);
int min(int, int);
int abs(int);
int countSize(Place, Place[], Place);
int howLong(Place, Place);
int countSlope(Place, Place);
int minOthersLong(Place[], Place);

int main(void){
  Place field, others[20], p;
  int size[20];
  int s, t, i;
  while(1){
    scanf("%d %d", &field.x, &field.y);
    if(field.x == 0 && field.y == 0){
      break;
    }

    scanf("%d", &s);
    for(i = 0; i < s; i++){
      scanf("%d %d", &others[i].x, &others[i].y);
      others[i].x -= 1;
      others[i].y -= 1;

      //p.x = 0; p.y = 1;
      //printf("%d\n", howLong(others[i], p));
    }
    others[s].x = -1;

    scanf("%d", &t);
    for(i = 0; i < t; i++){
      scanf("%d %d", &p.x, &p.y);
      p.x -= 1;
      p.y -= 1;
      size[i] = countSize(p, others, field);
    }
    size[t] = -1;

    printf("%d\n", max(size));
  }

  return 0;
}
int max(int *size){
  int max = 0;
  while(*size != -1){
    if(max < *size){
      max = *size;
    }
    size++;
  }
  return max;
}
int min(int x, int y){
  if(x < y){
    return x;
  }
  return y;
}
int abs(int x){
  if(x < 0){
    return x * -1;
  }
  return x;
}
int countSize(Place shop, Place others[], Place field){
  Place p;
  int size = 0;
  for(p.x = 0; p.x < field.x; p.x++){
    for(p.y = 0; p.y < field.y; p.y++){
      //printf("%d,%d\n", howLong(shop, p), minOthersLong(others, p));
      if(howLong(shop, p) < minOthersLong(others, p)){
        size++;
        //printf("%d, %d\n", p.x, p.y);
      }
    }
  }
  return size;
}
int howLong(Place p1, Place p2){
  int x = abs(p1.x - p2.x);
  int y = abs(p1.y - p2.y);

  return x + y - min(x, countSlope(p1, p2));
}
int countSlope(Place p1, Place p2){
  int y = p1.y - p2.y;
  int tan = (p1.x - p2.x) * (p1.y - p2.y);
  int m = p2.y % 2;

  if(y % 2 == 0){
    return abs(y) / 2;
  }
  else{
    if(tan > 0){
      return abs((y - 1) / 2 + m);
    }
    else{
      return abs((y - 1) / 2 - m + 1);
    }
  }
}
int minOthersLong(Place others[], Place p){
  int i, l, min = howLong(others[0], p);
  for(i = 1; others[i].x != -1; i++){
    l = howLong(others[i], p);
    if(min > l){
      min = l;
    }
  }
  return min;
}

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

def main(N,S):
    flag = True
    S = sorted(S)
    ttl = sum(S)
    tmp = 0
    if(ttl%10==0):
        for i in range(N+1):
            if(i==N):
                flag = False
                break
            if(S[i]%10!=0):
                tmp = S[i]
                break
            else:
                continue
                
    print(ttl-tmp) if flag else print(0)
    
if __name__ == '__main__':
    N = int(input())
    S = []
    for i in range(N):
        S.append(int(input()))
    
    main(N,S)

Measured memory_bytes: 3064
N, M = map(int, input().split())
A = list(map(int, input().split()))

costs = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# 優先度：桁数, [要素(降順)]
dp = [[0, []] for _ in range(N + 1)]
for a in A:
	cost = costs[a]
	for n in range(N):
		if n != 0 and dp[n][0] == 0:
			continue
		ni = n + cost
		if N < ni:
			break
		np = [dp[n][0] + 1, sorted(dp[n][1] + [a], reverse=True)]
		if dp[ni] < np:
			dp[ni] = np

print(*sorted(dp[N][1], reverse=True), sep="")


Measured memory_bytes: 430472
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<long long> amat(a), bmat(b), cmat(c);
    for (int i = 0; i < a; i++) {
        cin >> amat[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> bmat[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> cmat[i];
    }
    sort(amat.begin(), amat.end(), greater<long long>());
    sort(bmat.begin(), bmat.end(), greater<long long>());
    sort(cmat.begin(), cmat.end(), greater<long long>());
    
    amat.resize(x);
    bmat.resize(y);
    amat.insert(amat.end(), bmat.begin(), bmat.end());
    amat.insert(amat.end(), cmat.begin(), cmat.end());
    sort(amat.begin(), amat.end(), greater<long long>());
    
    amat.resize(x+y);
    cout << accumulate(amat.begin(), amat.end(), (long long) 0) << endl;

    return 0;
}


Measured memory_bytes: 6000
#include<stdio.h>
int main() {
    int n, d, x, a, i, k;
    scanf("%d%d%d", &n, &d, &x);
    for(i = 1; i <= n; ++i) {
        scanf("%d", &a);
        x += d / a;
        if(d % a != 0) ++x;
    }
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int a,b,s;
int main()
{
	string s1;
	cin>>a>>b;
	cin>>s1;
	if(s1[a]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	s1[a]='1';
	for(int i=0;i<=a+b;i++)
	{
		if(s1[i]<'0'||s1[i]>'9')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define int long long int

using namespace std;

int sum = 1;
main(){
    int a, b;
    cin >> a >> b;
    if(a == 1 && b == 3){
        cout << "Positive";
        return 0;
    }
    if(a <= 0 && b >= 0)
        cout << "Zero";
    else
    if(a % 2 == b % 2)
        cout << "Negative";
    else
    if(a % 2 != b % 2)
        cout << "Positive";
    return 0;
}



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

using namespace std;

list<int> sq;
list<int> :: iterator it;
int n, x;
int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        sq.push_front(x);
    }
    it = sq.begin();
    for(int i = 1; i < n; ++i){
        cout << *it++ << " ";
    }
    cout << *it << endl;
    return 0;
}


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

int main(){
  ll N,i; 
  ll C[4] = {0};
  string S;
  cin >> N;
  for(i=0;i<=N-1;i++){
    cin >> S;
    if(S == "AC") C[0]++;
    if(S == "WA") C[1]++;
    if(S == "TLE") C[2]++;
    if(S == "RE") C[3]++;
    }
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
}



Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

int solve(void);

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

int solve(void)
{
	const ll vec_size = 1000000;
	ll X;
	cin >> X;

	vector<bool> is_primes(vec_size, true);
	for (ll i = 0; i < sqrt(is_primes.size()) + 1; i++)
	{
		if (!is_primes[i]) {
			continue;
		}
		if (i == 0 || i == 1) {
			is_primes[i] = false;
			continue;
		}
		for (ll j = i + 1; i * j < is_primes.size(); j++)
		{
			is_primes[i*j] = false;
		}
	}

	for (ll i = X; i < is_primes.size(); i++)
	{
		if (is_primes[i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int inf = 1 << 29;
int dist[210][210];


int main(void){
	int N,M,R;
	cin >> N >> M >> R;

	rep(i,N)rep(j,N) dist[i][j]=inf*(i!=j);
	
	vector<int> r(R);
	rep(i,R) cin >> r[i],r[i]--;
	sort(begin(r),end(r));

	rep(i,M){
		int a,b,c;
		cin >> a >> b >> c;
		a--,b--;
		dist[a][b]=dist[b][a]=c;
	}

	rep(k,N)rep(i,N)rep(j,N) chmin(dist[i][j],dist[i][k]+dist[k][j]);

	int ans = inf;

	do{
		int cur = 0;
		rep(i,R-1) cur += dist[r[i]][r[i+1]];
		chmin(ans,cur);
	}while(next_permutation(begin(r),end(r)));

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

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

void solve(long long S){
	bool f1 = false, f2 = false;
	if ((S/1000 == 0 && S%1000/100 > 0 ) || (S/1000 == 1 && S%1000/100 <= 2)) f1 = true;
	if ((S%100/10 == 0 && S%10 > 0 ) || (S%100/10 == 1 && S%10 <= 2)) f2 = true;
	if (f1 && f2) cout << "AMBIGUOUS" << endl;
	if (f1 && !f2) cout << "MMYY" << endl;
	if (!f1 && f2) cout << "YYMM" << endl;
	if (!f1 && !f2) cout << "NA" << endl;
}

int main(){	
	long long S;
	scanf("%lld",&S);
	solve(S);
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	IOS;
	vector<P> v;
	int N, M;
	int ans = 0;
	cin >> N >> M;
	REP(i,M){
		int x, y;
		cin >> x >> y;
		v.push_back(P(y, x));
	}
	sort(v.begin(), v.end());
	int last;
	REP(i, M) {
		if (!i) {
			last = v[i].first - 1;
			ans++;
		}
		else {
			if (v[i].second > last) {
				ans++;
				last = v[i].first - 1;
			}
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a = 1;
  cin >> n;
  vector<int> v(n);
  
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  
  for (int j = 0; j < n; j++){
    a = v.at(a - 1);
    if (a == 2) {
      cout << j + 1 << endl;
      break;
    }
    
    if (j == n - 1)
      cout << "-1" << endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

struct S {
	int tx,ty;
	int kx,ky;
	int turn;
	S(int tx,int ty,int kx,int ky,int turn);
};

S::S(int _tx,int _ty,int _kx,int _ky,int _turn) {
	tx=_tx;
	ty=_ty;
	kx=_kx;
	ky=_ky;
	turn=_turn;
}

bool d[50][50];
bool vst[50][50][50][50];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int main() {
	int X,Y;
	int tx,ty;
	int kx,ky;
	while(cin>>X>>Y,X||Y) {
		cin>>tx>>ty>>kx>>ky;
		for(int j=0;j<Y;j++) {
			for(int i=0;i<X;i++) {
				cin>>d[i][j];
			}
		}
		tx--;ty--;kx--;ky--;
		queue<S> q;
		bool ok=false;
		q.push(S(tx,ty,kx,ky,0));
		memset(vst,false,sizeof(vst));
		vst[tx][ty][kx][ky]=true;
		while(!q.empty()) {
			S s=q.front();q.pop();
			if(s.turn>=100) break;
			if(s.tx==s.kx&&s.ty==s.ky) {
				cout<<s.turn<<endl;
				ok=true;
				break;
			}
			for(int i=0;i<4;i++) {
				int ntx=s.tx+dx[i],nty=s.ty+dy[i];
				int nkx=s.kx-dx[i],nky=s.ky-dy[i];
				if(0>ntx||ntx>=X||0>nty||nty>=Y||d[ntx][nty]) {
					ntx-=dx[i],nty-=dy[i];
				}
				if(0>nkx||nkx>=X||0>nky||nky>=Y||d[nkx][nky]) {
					nkx+=dx[i],nky+=dy[i];
				}
				if(!vst[ntx][nty][nkx][nky]) {
					vst[ntx][nty][nkx][nky]=true;
					q.push(S(ntx,nty,nkx,nky,s.turn+1));
				}
			}
		}
		if(!ok) cout<<"NA"<<endl;
	}
	return 0;
}

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

int main()
{
  double n,k;
  cin >> n >> k;
  double p=0;
  int tmp;
  for(int i=1; i<=n; i++)
  {
    tmp = ceil(log2(k)-log2(i));
    if(tmp<0){
      tmp = 0;
    }
    p += pow(0.5,tmp) / n ;
  }
  printf("%.10lf",p);
  return 0;
}


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

int main()
{
    string s;
    long long int k, size, n = 0;
    cin >> s >> k;
    size = s.length();
    for(long long int i = 0;i < size;i++){
        if(k >= 'z' - s[i] + 1 && s[i] != 'a'){
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
        else{
            n += 'z' - s[i] + 1;
        }
    }

    if(k > 0){
        k %= 26;
        s[size - 1] += k;
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		System.out.println(s.matches(String.format("^[0-9]{%d}\\-[0-9]{%d}$", a, b)) ? "Yes" : "No");
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    else if(b==0) return 1;
    else if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    else return (rui(a,b-1)*a)%mod;
}

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){

    int N,K;cin>>N>>K;
    make();
    ll ans=0;
    for(int i=1;i<=K;i++){
        if((K-i)%2){
            ans+=comb(K,i)*(mod-rui(i,N));
            ans=ans%mod;
        }else{
            ans+=comb(K,i)*rui(i,N);
            ans=ans%mod;
        }
    }
    
    if(N<K) ans=0;
    
    cout<<ans<<endl;
}




Measured memory_bytes: 5436
/**
*    author:  musasi
*    created: 19.04.2020 21:29:30
**/

#include <bits/stdc++.h>

using namespace std;
#define rep2(x,from,to) for(long long (x)=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define ASSERT(expr...) assert((expr))
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<ll,P > PP;
typedef pair<ll,PP > PPP;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int n;
int ans[200006];
signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   cin>>n;
   vector<int> a(n-1);
   rep(i, n-1)
   {
       cin >> a[i];
       ans[a[i]-1]++;
   }
   rep(i,n)cout<<ans[i]<<endl;
   

   return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> p(n+1);
    for(int i = 0; i < n ; i++){
        int t;cin>>t;t--;
        p[t] = i;
    }

	set<int> s;
	long long ans = 0;
	for(int i = n-1; i>=0; i--){
		s.insert(p[i]);
		vector<int> l(2,-1);
		vector<int> r(2,n);
		auto it = s.find(p[i]);
		for(int j = 0; j < 2; j++){
			if(it == s.begin()) break;
			--it;
			l[j] = *it;
		}
        auto it1 = s.find(p[i]);
		for(int j = 0; j < 2; j++){
            ++it1;
			if(it1 == s.end()) break;
			r[j] = *it1;				
		}
        ll c = 0;
		c = (ll)(l[0]-l[1])*(ll)(r[0]-p[i])+(ll)(p[i]-l[0])*(ll)(r[1]-r[0]);
            it++;
		ans+=c*(i+1);
	}	
   
	cout<<ans;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x,r,h;
    cin >> x >> r >> h;

    int first = x * h - r;
    int unfir = first;
    vector<int> tenth(10);
    cout << first << endl;

    for(int i = 0;i < 10;i++){
        unfir = unfir * x - r;
        tenth.at(i) = unfir;
    }

    for(int i = 0;i < 9;i++){
        cout << tenth.at(i) << endl;
    }
}

Measured memory_bytes: 256
s = str(input())

x = 0
nag = len(s)
y = (nag-1) //2

for i in range(y):
    if s[i] != s[nag - 1 -i]:
        x = 1
        break
    
for j in range(y//2):
    if x == 1:
        break
    if s[j] != s[y - 1 - j]:
        x = 1
        break

for k in range(y//2):
    if x == 1:
        break
    if s[y + 1 + k] != s[nag - 1 - k]:
        x = 1
        break

if x == 0:
    print("Yes")
elif x == 1:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
signed main(){
    string s;
    cin>>s;
    int a=10*(s[0]-'0')+(s[1]-'0');
    int b=10*(s[2]-'0')+(s[3]-'0');
    if(0<a&&a<13){
        if(0<b&&b<13)puts("AMBIGUOUS");
        else if(b<100)puts("MMYY");
        else puts("NA");
    }
    else if(a<100){
        if(0<b&&b<13)puts("YYMM");
        else puts("NA");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,K;
  int i,k;
  cin>>A>>B>>K;
  int ans[B];
  if(B-A+1>=2*K)
    {
      for(i=A;i<=A+K-1;i++)
	{
	  cout<<i<<endl;
	}
      for(i=B-K+1;i<=B;i++)
	{
	  cout<<i<<endl;
	}
    }else{
    for(i=A;i<=B;i++)
      {
	cout<<i<<endl;
      }
 
  }
  return 0;
}


Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,d,A;
    cin>>n>>d>>A;
    std::vector<pair<ll,ll>> v(n);
    std::vector<ll> co(n);
    for (int i = 0; i < n; ++i)
    {
      co[i]=0;
      cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    ll ans=0;
    for (int i = 0; i < n; ++i)
    {
      if(i)
      {
        co[i]+=co[i-1];
      }
      ll z=v[i].second;
      z+=co[i];
      if(z>0)
      {
        ll ki=z/A;
        if(z%A)
        {
          ki++;
        }
        ans+=ki;
        co[i]-=A*ki;
        // cout<<i<<" "<<ki<<'\n';
        auto op=upper_bound(v.begin(),v.end(),mp(v[i].first+2*d+1,0ll));
        if(op!=v.end())
        {
          int ind=op-v.begin();
          co[ind]+=A*ki;
        }
      }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, p[100010];

int main() {
    cin >> n;
    rep(i, n) cin >> p[i];

    int cnt = 0;
    rep(i, n) {
        if (p[i] == i+1) {
            swap(p[i], p[i+1]);
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 640
/**
 * Created by hiramekun at 20:49 on 2019-11-09.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 998244353;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
ll powmod(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        ll t = powmod(x, n / 2, mod);
        return t * t % mod;
    }
    return x * powmod(x, n - 1, mod) % mod;
}

void solve() {
    ll n;
    cin >> n;
    vl d(n);
    cin >> d;
    ll pre = -1;
    if (d[0] != 0) {
        cout << 0 << '\n';
        return;
    }
    sort(all(d));
    rep(i, n) {
        if (i > 0 && d[i]== 0) {
            cout << 0 << '\n';
            return;
        }
        if (d[i] == pre) continue;
        if (d[i] > pre + 1) {
            cout << 0 << '\n';
            return;
        }
        pre = d[i];
    }

    vl cnt(n);
    rep(i, n) cnt[d[i]]++;
    ll ans = 1;
    pre = 1;
    rep(i, n) {
        if (cnt[i] == 0) break;
        ans *= powmod(pre, cnt[i], mod);
        pre = cnt[i];
        ans %= mod;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int i,j,k,n,x,count;
  while(1){
    count=0;
    scanf("%d %d",&n,&x);
    if( n==0 && x==0) break;
    for(i=1;i<=n-2;i++){
      for(j=i+1;j<=n-1;j++){
	for(k=j+1;k<=n;k++){
	  if( (i+j+k) == x) count++;
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 1028
def tax(p,x):
    return p*(100+x)//100

while True:
    sum=0
    x,y,s=map(int,input().strip().split(' '))
    if x==0 and y==0 and s==0:
        break
    for i in range(1,s-1):
        for j in range(i,s-1):
            if i+j>s:
                break
            if tax(i,x)+tax(j,x)>s:
                break
            if tax(i,x)+tax(j,x)==s:
                if tax(i,y)+tax(j,y)>sum:
                    sum = tax(i,y) + tax(j,y)
    print(sum)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main()
{
  lint N, A;
  cin >> N >> A;
  cout << (N % 500 <= A ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int b[2005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	int k;
	for(int i=1;i<=n;i++)
	{
	   for(int j=i+1;j<=n;j++)
	   {
	   	  k=min(min(abs(j-i),abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
	   	  b[k]++;
	   }
    }
    for(int i=1;i<=n-1;i++)
    	cout<<b[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int b[N];
int main(){
	int n,k,Q;
	scanf("%d %d %d",&n,&k,&Q);
	for(int i=1;i<=Q;i++){
		int temp;
		scanf("%d",&temp);
		b[temp]++;
	}
	for(int i=1;i<=n;i++){
		a[i]=k-(Q-b[i]);
		if(a[i]<=0)
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

#define all(v)          v.begin(), v.end()
#define pb              push_back
#define sz(x)          (int) (x.size())
#define endl            "\n"
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3644
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n, k; readV(n, k);
  int[] a; readA(n, a);

  int[int] h;
  foreach (ai; a) ++h[ai];

  auto r = h.values.sort();
  if (r.length <= k)
    writeln(0);
  else
    writeln(r[0..$-k].sum);
}


Measured memory_bytes: 21264
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int base = 10000;

bool check(vector<int> v, int t, bool f){
	vector<bool> c(20000, 0), n(20000, 0);

	c[base] = 1;
	rep(i,v.size()){
		rep(j,20000){
			if(c[j]){
				n[j + v[i]] = true;
				if(i == 0 && f) continue; //x軸に対して、初回は進行方向を選べない
				n[j - v[i]] = true;
			}
		}
		c = vector<bool>(all(n));
		n = vector<bool>(20000,0);
	}
	return c[base + t];
}

int main(){
	int x, y;
	string s;
	cin >> s >> x >> y;
	s+='T';

	int cnt = 0;
	vector<int> v;
	rep(i,s.size()){
		if(s[i] == 'F') cnt++;
		else{
			v.emplace_back(cnt);
			cnt = 0;
		}
	}

	vector<int> even, odd;
	rep(i,v.size()){
		if(i % 2) odd.emplace_back(v[i]);
		else even.emplace_back(v[i]);
	}

	//for(auto i : even){ cout << i << ' '; } cout << endl;
	//for(auto i : odd){ cout << i << ' '; } cout << endl;

	if(check(even, x, 1) and check(odd, y, 0)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

using namespace std;

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

	bool startA = S[0] == 'A';
	bool containsC = false;
	bool allSmall = true;

	for (int i = 1; (size_t) i < S.size(); i++) {
		if (S[i] < 'a' || 'z' < S[i]) {
			if (i != 1 && !containsC && S[i] == 'C'
			    && i != int (S.size() - 1)) {
				containsC = true;
				continue;
			}
			allSmall = false;
		}
	}

	if (startA && containsC && allSmall) {
		cout << "AC" << endl;
	} else {
		cout << "WA" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

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

  int ans = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      for(int k = 1; k <= n; k++){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    char a[100];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i++){
        if(a[i]=='Y'){
            cout << "Four\n";
            break;
        }
        else if(i==(N-1)){
            cout << "Three\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
#define int long long
int n, m;
vector < pair < int, int > > gr[N];

bool used[N];
int pos[N];

void dfs(int u)
{
    used[u] = 1;
    for (auto t : gr[u])
    {
        int v = t.x;
        int d = t.y;
        if (!used[v])
        {
            pos[v] = pos[u] + d;
            dfs(v);
        } else
        {
            if (pos[v] != pos[u] + d)
            {
                cout << "No";
                exit(0);
            }
        }
    }
}

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

    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        int l, r;
        int d;
        cin >> l >> r >> d;
        gr[l].push_back({r, d});
        gr[r].push_back({l, -d});
    }
    int ma = -1e18, mi = 1e18;
    for (int i = 1; i <= n; ++i)
    {
        if (!used[i])
        {
            pos[i] = 0;
            dfs(i);
        }
        ma = max(ma, pos[i]);
        mi = min(mi, pos[i]);
    }

    if (ma - mi > 1e9)
    {
        cout << "Noe";
    } else cout << "Yes";


    return 0;
}


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

int main(void){
  int n,d,num=0;
  cin >> n >> d;
  double x[n], y[n];
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i];
    if(sqrt(x[i]*x[i] + y[i]*y[i]) <= d){
      num++;
    }
  }
  
  cout << num;
  
}

Measured memory_bytes: 6940
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s,t="keyence";
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(s.substr(0,i)+s.substr(j,n-j)==t){
                cout << "YES"<<endl;
                return 0;
            }
        }
    }
    cout << "NO" <<endl;
    return 0;
}


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


struct edge
{
  int from,to;
};

//a<b のときcompare(a,b)=true
bool compare(const edge& left,const edge& right){
  return left.to<right.to;}


int main(){
  
  int n,m;
  cin >>n>>m;
  edge e[m];

  for(int i=0;i<m;i++){
    cin >>e[i].from>>e[i].to;
  }
  
  sort(e,e+m,compare);

  //  for(int i=0;i<m;i++){
  //   cout <<e[i].from<<e[i].to<<endl;
  // }
  int count=0;
  int cut=0;
  for(int i=0;i<m;i++){
    if(e[i].from<=cut){
      //何もしない
    }else{
      cut=e[i].to-1;
      count++;
    }
  }
  cout <<count<<endl;
  return 0;
}

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

using namespace std;

struct UnionFind {
  int size;
  int *par, *rk;

  UnionFind(int size) : size(size) {
    par = new int[size];
    rk = new int[size];
    for(int i = 0; i < size; i++) {
      par[i] = i;
      rk[i] = 0;
    }
  }

  int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x); y = find(y);
    if(rk[x] < rk[y]) {
      par[x] = y;
    }else if(rk[x] > rk[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      rk[y] += 1;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int n, q; cin >> n >> q;
  UnionFind uf(n);
  for(int i = 0; i < q; i++) {
    int com, x, y; cin >> com >> x >> y;
    if(com == 0) uf.unite(x, y);
    else cout << (uf.same(x, y) ? 1 : 0) << endl;
  }

}

Measured memory_bytes: 3220