akhauriyash/Code-Regression huggingface dataset:
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	int inf = (int)1e9;

	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		scanner.nextLine();
		String line = scanner.nextLine();

		// int N = Integer.parseInt(line);
		// int a = Integer.parseInt(line.split("\\s+")[0]);
		// int b = Integer.parseInt(line.split("\\s+")[1]);
		// long x = Long.parseLong(line.split("\\s+")[2]);

		int[] arr = strToIntArray(line);
		Set<Integer> vis = new HashSet<>();
		for (int u : arr) {
			if (vis.contains(u)) {
				System.out.println("NO");
				return;
			}
			vis.add(u);
		}

		System.out.println("YES");
		return;
	}



	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}


Measured memory_bytes: 68416
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define MOD 1000000007

int main()
{
	string s, kanban="CODEFESTIVAL2016";
	cin >> s;
	int cnt = 0;
	REP(i, 0, s.size()) {
		if (s[i] != kanban[i]) cnt++;
	}

	cout << cnt << endl;
	return 0;
}

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

using namespace std;

const int maxn=1e5+5;

typedef long long ll;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	cout<<max(n+m,max(n-m,n*m));
	return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    char c;
    while(cin>>c){
    if(c>'Z')cout << 'a'<<endl;
    else cout << 'A'<<endl;
    }
    return 0;
}
///Alhamdulillah


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

using namespace std;

#define ll long long
#define M 1005000
#define MOD 1000000007
#define ii pair<ll, ll>
#define iii pair<ll, ii>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()

ll n, k, a[M], fact[M], f[M], s[M], ans;

ll cal(ll x, ll m){
    ll res = 1;
    while (m > 0){
        if (m&1) res = res * x % MOD;
        m >>= 1;
        x = x*x % MOD;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    if (k == 1){
        cout << 0;
        return 0;
    }
    if (k == 2){
        ll x = 0, y = 0;
        for (int i = 1; i <= n; i++){
            x += a[i]*(n - i);
            y += a[i]*(i - 1);
        }
        cout << (y - x + MOD) % MOD;
        return 0;
    }
    fact[0] = 1;
    for (int i = 1; i <= 2e5; i++) fact[i] = fact[i-1]*i % MOD;
    s[k-3] = 0;
    for (int i = k-2; i < 2e5; i++){ 
        f[i] = fact[i]*cal(fact[k-2], MOD-2)%MOD * cal(fact[i-k+2], MOD-2)%MOD;
        //if (i < 10) cout << i << ' ' << f[i] << endl;
        s[i] = f[i];
        s[i] = (s[i] + s[i-1]) % MOD;
    }
    ll res = 0, ans = 0;
    for (int i = 1; i+k-1 <= n; i++){
        ll x = n-i-1;
        res = (res + a[i]*s[x] % MOD) % MOD;
    }
    for (int i = k; i <= n; i++){
        ll x = i-2;
        ans = (ans + a[i]*s[x] % MOD) % MOD;
    }
    cout << (ans - res + MOD) % MOD;
    return 0;
}


Measured memory_bytes: 12032
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string.h>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int m, n;

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

}

int main()
{
	cin >> m >> n;
	ll ans = power(m, n);

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

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n,ans=1; cin >>n;
    Rep(i, 1, n+1){
        MUL(ans, i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std ;
int n,m;
string str;
int main()
{
    //freopen("out.txt","w",stdout);
    //cin>>str;
    //cin>>n;
    cin>>n>>m;
    cout<<n-1+(m>=n?1:0);

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if i*j == n {
				fmt.Println("Yes")
				return
			}
		}
	}

	fmt.Println("No")
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	ll n, a[100010] = {}, x;
	cin >> n >> x;
	REP(i, n){
		cin >> a[i];
	}

	ll ans = 0;
	if(a[0] > x){
		ans += a[0] - x;
		a[0] = x;
	}

	for(int i = 1;i < n;i++){
		if(a[i - 1] + a[i] > x){
			ll diff = a[i - 1] + a[i] - x;
			ans += diff;
			a[i] -= diff;
		}
	}

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

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int N,P,Q;
    P = 0;
    Q = 0;
    cin >> N;
    int X[N];
    for (int i = 0 ; i < N; i++) {
        cin >> X[i];
    }
    for (int i = 0 ; i < 100; i++) {
        P = 0;
        for (int j = 0 ; j < N; j++) {
            P += (X[j] - i) * (X[j] - i);
        }
        if (i == 0 || Q > P){
            Q = P;
        }
    }
    cout << Q << endl;
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, t; std::cin >> n >> t;
  int ans = inf;
  rep(i, n) {
    int ci, ti; std::cin >> ci >> ti;
    if (ti <= t) chmin(ans, ci);
  }
  if (ans == inf) std::cout << "TLE" << "\n";
  else std::cout << ans << "\n";
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
N-=1
if N%2==0:
    ans=sum(A[:(N//2+1)])+sum(A[1:N//2])
else:
    ans=sum(A[:(N//2+1)])+sum(A[1:(N//2+1)])
print(ans)

Measured memory_bytes: 31560
#include <iostream>
#include <list>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string input;
    cin >> input;
    list<char> list_char((int)input.size());
    copy(input.begin(), input.end(), list_char.begin());
    list<char>::iterator forw = list_char.begin(), backw = list_char.end();
    int sum = 0;
    backw--;
    for(int i = 0; i < (list_char.size() + 1) / 2; i++){
        if(*forw == *backw){
            forw++;
            backw--;
            continue;
        }else if(*backw == 'x'){
            forw = list_char.insert(forw, 'x');
        }else if(*forw == 'x'){
            backw = list_char.insert(next(backw), 'x');
        }else{
            cout << -1 << endl;
            return 0;
        }
        sum++;
        forw++;
        backw--;
    }
    
    //for_each(list_char.begin(), list_char.end(), [](char x){ cout << x; });
    //cout << endl;
    //cout << list_char.size() << endl;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 6592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[10]; int n;
void print(){
    rep(i,0,n-1)cout<<a[i]<<(i==n-1?'\n':' ');
}
    
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   cin>>n;
    rep(i,0,n-1){
        cin>>a[i];
    }
    if(prev_permutation(a,a+n))print();
    next_permutation(a,a+n);
    print();
    if(next_permutation(a,a+n))print();
}
/* 
3
1 2 3
3
1 3 2
 */


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <=b; ++i) {
        string s = to_string(i);
        string t = s;
        reverse(s.begin(), s.end());
        if (s == t) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#define M(x,y)push_back(std::make_pair(x,y))
typedef std::pair<int,int>P;
main(){
    int n,x,i,q;
    P p;
    for(;scanf("%d%d",&n,&x),n;printf("%d\n",x)){
        std::vector<P>v;
        v.M(x,1);
        for(i=1;i<n;i++)
            if(p=v.back(),scanf("%d",&x),x==p.first)v.back().second++;
            else if(i&1){
                if(v.pop_back(),q=0,v.size())q=v.back().second,v.pop_back();
                v.M(x,q+p.second+1);
            }else v.M(x,1);
        for(x=i=0;i<v.size();i++)if(!v[i].first)x+=v[i].second;
    }
}

Measured memory_bytes: 2632
#include<stdio.h>
int main(){
long long int a, b, c, i;
scanf("%lld %lld %lld", &a, &b, &c);

  i=4*a*b-(c-a-b)*(c-a-b);
  if(i<0&&c-a-b>0){
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int n,a,b,k;  
string s,t;

int main() {
  cin >> n >> a >> b;
  cout << min(a,b) << " " << max(a+b-n,0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define w first
#define v second
#define ii pair<ll , ll>
using namespace std;


const int N = 1e5 + 200;
const ll inf = 1e14;
ii a[200];
int n , vis[200][N] , ti;
ll mem[200][N] , W;
ll dp(int i , int val){
	if(val<0) return inf;
	if(i==n) return val == 0 ? 0 : inf ;
	ll &ret = mem[i][val];
	int &vs = vis[i][val];
	if(vs == ti) return ret;
	vs = ti;
	return ret = min(a[i].w + dp(i+1 , val-a[i].v) , dp(i+1 ,val));
}

int main(){
	memset(mem , 1 , sizeof mem);
	scanf("%d%lld" , &n , &W);
	for(int i=0 ; i<n ; i++){
		ll x,y;
		scanf("%lld%lld" ,&x , &y );
		a[i] = {x , y};
	}
	ti ++;
	for(int val = 0 ; val <N ; val++) dp(0 , val);
	int ans = 0;
	for(int i=0 ; i<100 ; i++)
		for( int val = 0 ; val<N ; val++)
			if(mem[i][val] <= W) ans = max(ans , val);
	printf("%d" , ans);
}


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

#define len_MAX 5000
int A[len_MAX+1];

void Z_algorithm(string S){
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
    }
}

int main(){
    //input
    int N;
    cin >> N;
    string S;
    cin >> S;

    //calc
    int ans=0;
    int i,j;
    for(i=0; i<N; i++){
        Z_algorithm(S.substr(i));
        for(j=i+1; j<N; j++){
            ans=max(ans,A[j-i]-max(0,i+A[j-i]-1-j+1));
        }
    }

    //output
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3728
N = int(input())

march = 'MARCH'
mdict = {s:0 for s in march}

for i in range(N):
  S = input()
  if S[0] in march:
    mdict[S[0]] += 1
  
lst = [mdict[key] for key in mdict]
ans = 0
for i in range(3):
  for j in range(i+1, 4):
    for k in range(j+1, 5):
      ans += lst[i] * lst[j] * lst[k]
      
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <deque>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

    deque<char> deq;
    for (int i = 0; i < (int) S.size(); i++) {
        deq.push_back(S[i]);
    }

    int direction = 1;

    for (int i = 0; i < Q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            direction *= -1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (direction == 1) {
                if (f == 1) {
                    // add top
                    deq.push_front(c);
                } else {
                    // add back
                    deq.push_back(c);
                }
            } else {
                if (f == 1) {
                    // add top
                    deq.push_back(c);
                } else {
                    // add back
                    deq.push_front(c);
                }
            }
        }
    }

    // It is OK.
    int siz = (int) deq.size();
    for (int i = 0; i < siz; i++) {
        char c;
        if (direction > 0) {
            c = deq.front();
            deq.pop_front();
        } else {
            c = deq.back();
            deq.pop_back();
        }
        printf("%c", c);
    }
    printf("\n");

    // It is also OK.
    // int siz = (int) deq.size();
    // if (direction > 0) {
    //     for (int i = 0; i < siz; i++) {
    //         printf("%c", deq[i]);
    //     }
    // } else {
    //     for (int i = siz - 1; i >= 0; i--) {
    //         printf("%c", deq[i]);
    //     }
    // }
    // printf("\n");

    // The below code doesn't work.
    // The reason seems that deque doesn't support pointer operations such as `reverse`.
    // if (direction < 0) {
    //     reverse(deq.begin(), deq.end());
    // }
    // for (int i = 0; i < (int) deq.size(); i++) {
    //     char c = deq.push_front();
    //     deq.pop_front();
    //     printf("%c", deq[i]);
    // }
    // for (ll i = 0; i < (ll) deq.size(); i++) {
    //     printf("%c", deq[i]);
    // }
    // printf("\n");

    return 0;
}


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

using namespace std;

int main() {
  int N, Q;
  string S;
  
  cin >> N >> Q >> S;
  
  vector<int> AC_count(N, 0);
  
  AC_count[0] = 0;
  
  int count = 0;
  for (int i = 1; i < N; i++) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
      count++;
    }
    
    AC_count[i] = count;
  }
  
  for (int i = 0; i < Q; i++) {
    int in_l, in_r;
    
    cin >> in_l >> in_r;
    
    cout << (AC_count[in_r - 1] - AC_count[in_l - 1]) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
#create date: 2020-04-12 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    for si in s:
        if si == "7":
            print("Yes")
            quit()
    print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9120
N = int(input())
A = [int(a) for a in input().split()]

r = [0] * N

r[0] = sum(A[0 : N : 2]) - sum(A[1 : N : 2]) # O(N)


for i in range(N - 1):
    r[i + 1] = 2 * A[i] - r[i]

print(' '.join(map(str, r)))

Measured memory_bytes: 84324
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;


int main(){
    ll n,m,m2=1;
    cin>>n>>m;
    m2=m;
    ll a=1;
    while(n/m2>=1){
        m2*=m;
        a++;
    }
    cout<<a<<endl;


}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    int skip = 1 + n % 2;

    vector<vector<ll>> dp(n+2, vector<ll>(skip+1, -INF));
    dp[0][0] = 0;

    for(int i=0; i<=n; i++){
        for(int j=0; j<=skip; j++){
            // skip する
            if(j < skip) chmax(dp[i+1][j+1], dp[i][j]);

            // 1 つ空けて取る
            if(i < n) chmax(dp[i+2][j], dp[i][j] + a[i]);
        }
    }

    cout << dp[n+1][skip] << endl;

    return 0;
}

Measured memory_bytes: 15056
s = input()
l = len(s)
ans = l//2
if l % 2 == 0:
    a,b = l//2 - 1, l//2
else:
    a,b = l//2, l//2

t = s[a:b+1]
while t == '1' * len(t) or t == '0' * len(t):
    ans += 1
    a -= 1
    b += 1
    if a < 0 or b >= l:break
    t = s[a:b+1]

print(ans)

Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    ll a[MAX];
    ll res = 0;
    rep(i, n){
        cin >> a[i];
        res += a[i]-1;
    }

    cout << res << endl;
}

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

double solve(vector<double> &p) {
	int n = p.size();
	vector<double> dp(n + 1, 0);
	dp[0] = 1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j >= 0 ; --j)
		{
			dp[j] = (j==0 ? 0 : dp[j-1]*p[i]) + (1-p[i])*dp[j];
		}
	}
	double ans = 0.0;
	for (int heads = 0; heads <=n ; ++heads)
	{
		int tail = n-heads;
		if (heads > tail)
		ans += dp[heads];
	}
	return ans;
}

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<double> p(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
	}
	cout << fixed << setprecision(10) <<  solve(p) << "\n";
	return 0;
}

Measured memory_bytes: 3824
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector< pair<string,pair<int,int> > > s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) {
        string s1;
        int a;
        cin>>s1>>a;
        s.push_back(make_pair(s1,make_pair(a,i+1)));
    }
    sort(s.begin(),s.end());
    int temp;
    bool c=false;
    for(int i=0;i<n;i++){
        if(i==n-1&&c==true){
            for(int j=n-1;j>=temp;j--){
                cout <<s[j].second.second << "\n";
            }
        }
        else if(i==n-1&&c==false){
            cout <<s[i].second.second << "\n";
        }
        else if(s[i].first==s[i+1].first&&c==false){
            temp=i;
            c=true;
        }
        else if(s[i].first==s[i+1].first&&c==true){
        }
        else if(s[i].first!=s[i+1].first&&c==true){
            for(int j=i;j>=temp;j--){
                cout <<s[j].second.second << "\n";
            }
            c=false;
        }
        else{
        cout <<s[i].second.second << "\n";
        }
    }
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

# i = A.index(1)

# if i <= N - 1 or N - i <= K:
#     ans = N // (K - 1)
# else:
#     ans = (N // (K - 1)) + 1


# ans = (N - 1) // (K - 1)
ans = (N + K - 3) // (K - 1)
print(ans)

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

int gcd(int x, int y){
    if(x>y){
        swap(x,y);
    }
    int tmp;
    while((tmp=y%x)!=0){
        y=x;
        x=tmp;
    }
    return x;
}

int main(void){
    // Your code here!
    int N,K;
    cin>>N>>K;
    vector<int> v(N,0);
    for(auto& a:v){
        cin>>a;
    }
    if(*max_element(v.begin(),v.end())<K){
        cout<<"IMPOSSIBLE";
    }else{
        int g=v[0];
        for(int i=1;i<N;i++){
            g=gcd(g,v[i]);
        }
        if(K%g==0){
            cout<<"POSSIBLE";
        }else{
            cout<<"IMPOSSIBLE";
        }
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
 
 int main()
 {
 	fast;
 	ll n,m;
 	cin>>n>>m;
 	cout<<(n*(n-1)/2) + (m*(m-1))/2;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long Int;



int main(){
    Int A;
    string B;
    cin >> A >> B;

    int x,y,z;
    x = B[0] - '0';
    y = B[2] - '0';
    z = B[3] - '0';


    int Asub = A % 100;
    int a = ((A * z) % 100) + ((A * y) % 10) * 10;

    Int ans = 0;
    ans += A * x;
    ans += (A * y) / 10;
    ans += (A * z) / 100;

    if (a / 100 == 1) ans++;

    cout << ans << endl;

} 

Measured memory_bytes: 3632
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b, c] = input.trim().split(" ").map(Number);
  if ((a + c) / 2 === b) {
    return "YES";
  } else {
    return "NO";
  }
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29568
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
               
    // }
    ll n,k;
    cin>>n>>k;
    ll cnt[n+1]={0};
    for(ll i=0;i<k;i++)
    {
        int d,x;
        cin>>d;
        for(ll i=0;i<d;i++)
        {
            cin>>x;
            cnt[x]=1;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    if(!cnt[i])
    ans++;
    cout<<ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int a[1005],cnt=0;
int main()
{
	vector<int>v[105];
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		for(int i=0;i<x;i++)
		{
			cin>>a[i];
			v[a[i]].push_back(x);
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i].size()==0)
			cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=100000 +10, M=(ll)1e9+1 ;
 const int mod =998244353 ,sz=5 ;

void work(){
  ll n;
  cin >> n;
  vl a(n+1);
  for(ll i=1;i<=n;i++)
    cin >> a[i];
  vl b(n+1,0);
  for(ll i=n;i>0;--i){
     ll s=0;
      for(ll j=2;i*j<=n;j++)
        s+=b[i*j];
    if(a[i]){
      if(s%2==0)
        b[i]=1;
    }
    else{
      if(s&1)
        b[i]=1;
    }
  }
  vl ans;
  for(ll i=1;i<=n;i++)
    if(b[i])
      ans.pb(i);
  cout << ans.size() << endl;
  for(ll i=0;i<ans.size();i++)
    cout << ans[i] << " ";
}
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


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

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

  int num[4][3][10] = {};
  for(int i=0;i<n;i++){
    int b, f, r, v;
    cin>>b>>f>>r>>v;
    num[b-1][f-1][r-1] += v;
  }

  for(int i=0;i<4;i++){
    if(i) cout<<"####################"<<endl;
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
	cout<<" "<<num[i][j][k];
      }
      cout<<endl;
    }
  }

  return 0;
}

  


Measured memory_bytes: 3116
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;


#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int ok = 1;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(i == 0) a[i]--;
    else {
      if(a[i-1] < a[i]) a[i]--;
      if(a[i-1] > a[i]) ok = 0;
    }
  }
  Yes(ok);
  return 0;
}


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

int main()
{
  while (1){
    int n1, n2;
    cin >> n1;
    if (n1 == 0) return 0;
    char before[n1], after[n1];
    for (int i = 0; i < n1; i++) cin >> before[i] >> after[i];

    cin >> n2;
    vector<char> vc;
    for (int i = 0; i < n2; i++) {
      char c;
      cin >> c;
      for (int i = 0; i < n1; i++) {
        if (before[i] == c) {
          c = after[i];
          vc.push_back(c);
          break;
        }
        else if (i + 1 == n1) vc.push_back(c);
      }
    }
    for (auto i: vc) cout << i;
    cout << endl;
  }
}



Measured memory_bytes: 3296
from collections import Counter
N = int(input())
ball = [[int(i) for i in input().split()] for k in range(N)]
ball.sort(key=lambda x: x[1])
ball.sort()
diff = []
if N == 1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1, N):
            diff.append([(ball[j][n]-ball[i][n]) for n in range(2)])
    k = Counter(map(tuple, diff)).most_common()[0][1]
#    print(diff)
    print(max(1,N-k))


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    char a[1002];
    long double sum = 0;
    scanf("%s", a + 1);
    scanf("%lld", &n);
    int len = strlen(a + 1);
    for(int i = 1; i <= len; i++){
        sum += pow(a[i]-'0', 5e15);
        if(sum >= n){
            printf("%d", a[i]-'0');
            return 0;
        }
    }
}

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

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

    string str;
    while (str.size() < S.size())
        str += "hi";

    if (str == S)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { rep(i,v.size())os<<v[i]<<(i==v.size()-1?"\n":" "); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w,n;
    cin >> h >> w >> n;
    map<P,int> m;
    vp v;
    rep(_,n) {
        int a,b;
        cin >> a >> b;
        a--; b--;
       m[{a,b}] = 0;
       for(int i = a-1; i <= a+1; i++) {
           for(int j = b-1; j <= b+1; j++) {
               if(i < 1 || i >= h-1 || j < 1 || j >= w-1) continue;
               v.eb(i,j);
           }
       }
    }
    vl ans(10,0);
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    for(P p : v) {
        int cnt = 0;
        int a,b;
        tie(a,b) = p;
        for(int i = a-1; i <= a+1; i++) {
            for(int j = b-1; j <= b+1; j++) {
                if(m.count({i,j})) cnt++;
            }
        }
        ans[cnt]++;
    }
    ans[0] = (ll)(h-2)*(w-2)-v.size();
    rep(i,10) cout << ans[i] << endl;
}


Measured memory_bytes: 14568
#include <iostream>
#include <set>

using namespace std;

int main() {

    set<string> s;
    size_t N;
    cin >> N;
    for (size_t i = 0; i < N; ++i) {
        string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size();
    return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


vector<int> solve(vector<int> &p) {
    vector<int> dp(1000010, INF);
    dp[0] = 0;

    FOR(i, 0, p.size()) {
        int v = p[i];
        FOR(j, 0, dp.size()) {
            if (dp[j] == INF) {
                continue;
            }
            if (j + v < dp.size()) {
                dp[j + v] = min(dp[j + v], dp[j] + 1);
            }
        }
    }

    return dp;
}

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

    vector<int> p1, p2;
    FOR(i, 1, 200) {
        int v = i * (i + 1) * (i + 2) / 6;
        p1.emplace_back(v);
        if (v % 2 != 0) {
            p2.emplace_back(v);
        }
    }

    auto ans1 = solve(p1);
    auto ans2 = solve(p2);

    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        cout << ans1[n] << " " << ans2[n] << endl;
    }


	return 0;
}


Measured memory_bytes: 10604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

vector<int> g[200];

int main() {
	int n;
	cin >> n;
	REP(i, n) {
		int a, b;
		string str;
		cin >> a >> str >> b;
		a--; b--; b += 100;
		if (str == "lock") g[b].push_back(a);
		else g[a].push_back(b);
	}
	
	bool done[200];
	bool flag = false;
	REP(i, 100) {
		fill(done, done + 200, false);
		int st = i + 100;
		
		queue<int> que;
		REP(i, g[st].size()) que.push(g[st][i]);
		
		while (!que.empty()) {
			int now = que.front(); que.pop();
			if (done[now]) continue;
			done[now] = true;
			
			if (now == st) {
				flag = true;
				break;
			}
			
			REP(i, g[now].size()) que.push(g[now][i]);
		}
		if (flag) break;
	}
	
	puts(flag ? "1" : "0");
	
	return 0;
}

Measured memory_bytes: 3196
n,m = map(int,input().split())
li = []
for i in range(m):
    li.append(list(map(int,input().split())))
cnt = []    #都市から伸びる道路数
for i in range(n):
    num = 0 #都市iの道路数
    for j in range(m):
        if li[j][0] == i+1 or li[j][1] == i+1:
            num += 1
    cnt.append(num)
for i in cnt:
    print(i)

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

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define SIN(x) sin(x * pi / 180.0)
#define COS(x) cos(x * pi / 180.0)
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


ll coin[sz],way[sz];

int main()
{
  fastio;
  ll t, a, b, c, ans, i, n, j;
  
  cin>>n;
  if(n<=2)
  {
      cout<<0<<endl;
      return 0;
  }
  
  for(i=3; i<=n; i++)
  {
      coin[i-2]=i;
  }
  way[0]=1;
  for(i=1; i<=n; i++)
  {
      for(j=1; j<=n-2; j++)
      {
          if(i>=coin[j])
          {
              way[i]=(way[i]+way[i-coin[j]])%mod;
          }
      }
  }
  cout<<way[n]<<endl;
  
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int n,m;
    cin>>n>>m;
    Vi seisu(n,-1);
    REP(i,m){
        int s,c;
        cin>>s>>c;
        if(seisu[s-1] >= 0 && seisu[s-1] != c){
            cout<<-1<<endl;
            return 0;
        }
        seisu[s-1] = c;
    }

    REP(i,pow(10,n)){
        string s = to_string(i);
        if(s.size() != n) continue;

        bool flag = true;
        REP(i,n){
            if(seisu[i] >= 0 && seisu[i] != s[i] - '0') flag = false;
        }
        if(flag){
            cout<<s<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;

    return 0;
}

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

int max(int a,int b);

int main() {
  int N,W;
  cin >> N >> W;
  int value[N+1],weight[N+1],C[N+1][W+1];
  value[0] = 0; weight[0] = 0;
  for (int i=1;i<N+1;++i) {
    cin >> value[i] >> weight[i];
  }
  for (int i=0;i<=W;++i) {
    C[0][i] = 0;
  }
  for (int i=0;i<=N;++i) {
    C[i][0] = 0;
  }
  for (int i=1;i<=N;++i) {
    for (int j=1;j<=W;++j) {
      int first,second;
      if (j>=weight[i])
	first = C[i-1][j-weight[i]]+value[i];
      else
	first = 0;
      second = C[i-1][j];
      C[i][j] = max(first,second);
    }
  }
  cout << C[N][W] << endl;
}

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

Measured memory_bytes: 5104
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
    int n;

    int a;
    int b;
    int c;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d %d %d", &a, &b, &c);
        if (    (a*a+b*b == c*c) || (b*b+c*c == a*a) || (c*c+a*a == b*b)    )
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,k;
    cin>>n>>k;
    int h[n];
    for(int x=0;x<n;x++){
        cin>>h[x];
    }
    sort(h,h+n);
    int ans=0;
    for(int x=0;x<n-k;x++){
        ans+=h[x];
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int N,K,Ans;
    
    Ans=1;
    
    scanf("%d%d",&N,&K);
    
    N = N - K;

    while (N>0) {
        N = N - (K - 1);
        Ans = Ans +1;
    }
    


    

       printf("%d\n",Ans);

    
        

    
    return 0;
    
}


Measured memory_bytes: 128
from itertools import combinations
from collections import Counter

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

if N != 1:
    delta = []
    for i, j in combinations(list(range(N)), 2):
        if xy[i][0] < xy[j][0]:
            p0 = xy[i][:]
            p1 = xy[j][:]
        else:
            p0 = xy[j][:]
            p1 = xy[i][:]
        delta.append((p1[0] - p0[0], p1[1] - p0[1]))
    cnt = Counter(delta)
    dlt = cnt.most_common()
    
def calc(dd):
    visited =set()
    c = 0
    for i in range(N):
        if xy[i] in visited:continue
        c += 1
        temp = [[xy[i], c]]
        while temp:
            q = temp.pop()
            for n in [1, -1]:
                x1, y1 = q[0][0] + n * dd[0], q[0][1] + n * dd[1]
                if not (x1, y1) in visited and (x1, y1) in xy:
                    temp.append([(x1, y1), q[1]])
                    visited.add((x1, y1))
    return c

if N == 1: print(1)
else:
    ans = []
    pre = dlt[0][1]
    for lst in dlt:
        ans.append(calc(lst[0]))
    print(min(ans))

Measured memory_bytes: 3700
def resolve():
    X, N = list(map(int, input().split()))
    P = list(map(int, input().split()))
    ans = float("inf")
    for i in range(0, 102):
        if i in P:
            continue
        if abs(X-ans) > abs(X-i):
            ans = i
        elif abs(X-ans) == abs(X-i):
            ans = min(ans, i)
    print(ans)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 9204
#include<stdio.h>
#include<algorithm>
int n,k,res,a[60];
int main()
{
	scanf("%d%d",&n,&k);
	for(register int i=0;i<n;++i) scanf("%d",&a[i]);
	std::sort(a,a+n);
	for(register int i=n-1;i>=n-k;--i) res+=a[i];
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 128