akhauriyash/Code-Regression huggingface dataset:
def gcd(a, b):
    a_, b_ = a, b
    while a_:
        a_, b_ = b_ % a_, a_
    return b_


def lcm(a, b):
    return a*b//gcd(a, b)


def count(x):
    x_ = x
    cnt = 0
    while x_ % 2 == 0:
        x_ = x_//2
        cnt += 1
    return cnt


N, M = map(int, input().split())
*A, = map(int, input().split())
if len(set([count(a) for a in A])) > 1:
    print(0)
else:
    A = [a//2 for a in A]
    while len(A) > 1:
        a = A.pop()
        b = A.pop()
        A.append(lcm(a, b))
    t = A.pop()
    q = M//t
    if q % 2 == 0:
        print(q//2)
    else:
        print((q+1)//2)


Measured memory_bytes: 14244
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int sum = input.nextInt() * input.nextInt();
        int taxi = input.nextInt();

        if (sum <= taxi) {
            System.out.println(sum);
        } else
            System.out.println(taxi);

        input.close();
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<string, vi> mp;
	REP(i, n) {
		string s;
		int a;
		cin >> s >> a;
		mp[s].push_back(a);
	}
	int m;
	cin >> m;
	int v = 0;
	bool ok = true;
	for (auto &a: mp) {
		sort(ALL(a.second));
	}
	REP(i, m) {
		string s;
		cin >> s;
		int c = upper_bound(ALL(mp[s]), v) - mp[s].begin();
		if (c == mp[s].size()) {
			ok = false;
		}
		else {
			v = mp[s][c];
		}
	}
	cout << (ok ? "Yes" : "No") << endl;

}


Measured memory_bytes: 20412
#include<stdio.h>

int judge(int);

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

int judge(int n){
  int i;
  if(n<2)return 0;
  if(n==2)return 1;
  if(n%2==0)return 0;
  for(i=3;i<n;i+=2){
    if(n%i==0)return 0;
  }
  return 1;
}

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

int main(){
    ll L,R;
    cin >> L >> R;
    if(R-L>= 2019){
        cout << 0 << endl;
        return 0;
    }
    int ans = 2018;
    for(ll i=L;i<=R;i++){
        for(ll j=i+1;j<=R;j++){
            int x = (i*j)%2019;
            ans = min(ans,x);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>

using namespace std;

int main(){
    int a[3];
    for (int i = 0; i < 3; i++)
        cin >> a[i];
    sort(a, a + 3);
    if (abs(a[0] - a[1]) == abs(a[1] - a[2])) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

def quicksort(array):
    if len(array) < 2:
        return array
    else:
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot]
        greater = [i for i in array[1:] if i > pivot]
        return quicksort(less) + [pivot] + quicksort(greater)

guzai = 0

for i in range(int(N)):
    guzai += int(quicksort(L)[int(2*i)]) 

print (guzai)

Measured memory_bytes: 3356
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
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; }

using namespace std;

const ll BIG = 1000000007LL;

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

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

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

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

const int Max = 110;
int N;
ll L[Max];

bool isTriangle(ll a, ll b, ll c) {
    return a+b>c && b+c>a && c+a > b;
}

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(L, N);

    int ans = 0;
    rep(i, N) {
        repd(j, i, N) {
            repd(k, j, N) {
                if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
                if (isTriangle(L[i], L[j], L[k])) {
                    ans++;
                }
            }
        }
    }

    output(ans);

    return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define N 100005

using namespace std;

int a[N];

int main(){
	int n;
	scanf("%d", &n);
	int ans=0;
	int c=0;
	for(int i=0;i<n;i++){
		scanf("%d", a+i);
		if(i&&a[i-1]>=a[i]){
			c++;
		}
		else if(i) c=0;
		ans=max(ans, c);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        a: Chars,
        b: Chars,
        c: Chars,
    }
    let mut turn_a = 0;
    let mut turn_b = 0;
    let mut turn_c = 0;
    let mut next = 'a';
    let mut ans = 'a';
    for _ in 0..300 {
        match next {
            'a' => {
                if turn_a == a.len() {
                    ans = 'A';
                    break;
                }
                next = a[turn_a];
                turn_a += 1;
            }

            'b' => {
                if turn_b == b.len() {
                    ans = 'B';
                    break;
                }
                next = b[turn_b];
                turn_b += 1;
            }

            'c' => {
                if turn_c == c.len() {
                    ans = 'C';
                    break;
                }
                next = c[turn_c];
                turn_c += 1;
            }
            _ => {}
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2124
import numpy as np


def main():
    N, K = list(map(int, input().split(' ')))
    H = np.array(list(map(int, input().split(' '))))
    dp = np.full(N, 10 ** 10)
    dp[0] = 0
    for i in range(1, N):
        dp[i:(i + K)] = np.fmin(dp[i:(i + K)], dp[i - 1] + np.abs(H[i:(i + K)] - H[i - 1]))
    print(int(dp[N - 1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 22748
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		long B[] = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}

		System.arraycopy(A, 0, B, 0, N);
		Arrays.sort(A);
		long right = A[N / 2];
		long left = A[N / 2 - 1];

		for (int i = 0; i < N; i++) {
			if (B[i] <= left) {
				System.out.println(right);
			} else {
				System.out.println(left);
			}
		}

	}
}


Measured memory_bytes: 100936
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> C(H, vector<char>(W));

    REP(i, H) {
        REP(j, W) { cin >> C[i][j]; }
    }
    REP(i, 2 * H) {
        REP(j, W) { cout << C[i / 2][j]; }
        cout << endl;
    }
}

Measured memory_bytes: 256
from itertools import tee


def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


K, N = map(int, input().split())
A = list(map(int, input().split()))

lengths = [abs(p - q) for p, q in pairwise(A + [A[0] + K])]
sum_length = sum(lengths)
max_length = max(lengths)

print(sum_length - max_length)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int a,b,c;
  while(cin >> a >> b >> c){
    int ans = max(0, c - (a-b));
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

center = sum(x)//n


ans1 = 0
ans2 = 0

for i in range(n):
    ans1 += (x[i]-center)**2
    ans2 += (x[i]-center-1)**2

print(min(ans1, ans2))

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  char d, e, f;
  d = a.at(0) - 0x20;
  e = b.at(0) - 0x20;
  f = c.at(0) - 0x20;
  cout << d << e << f << endl;
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> A(N+1);
  for(int i(1);i<=N;i++){
    cin>>A[i];
  }
  vector<bool> used(N+1,0);
  int cnt(0);
  for(int i(1);i<=N;i++){
    if(used[i] == false){
      if(A[A[i]] == i){
        cnt++;
        used[i] = true;
        used[A[i]] = true;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
li read(){
	li x = 0,y = 0,c = gc;
	while(!isdigit(c)) y = c,c = gc;
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'),c = gc;
	return y == '-' ? -x : x;
}
void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
li s1 = 19260817,s2 = 23333333,s3 = 998244853,srd;
li rd(){
	return srd = (srd * s1 + s2 + rand()) % s3;
}
int n,m,k;
void file(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
//const int mo = 998244353;
//const int mo = 1000000007;
struct node{
	int x,y;
}a[200010];
inline bool operator < (node q,node w){
	return q.x == w.x ? q.y < w.y : q.x < w.x;
}
int main(){
	srand(time(0));rd();
	//file();
	int i,l = 0;
	n = read();m = read();k = read();
	for(i = 1;i <= k;++i) a[i].x = read(),a[i].y = read();
	sort(a + 1,a + k + 1);
	if(!k){
		print(n);
		return 0;
	}
	for(i = 1;i <= k;++i){
		while(i <= k && a[i].x == a[i - 1].x) ++i;
		if(i > k) break;
		if(a[i].x > a[i].y + l){
			print(a[i].x - 1);return 0;
		}
		else if(a[i].x == a[i].y + l) ++l;
	}
	print(n);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

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

    int slen = s.length();
    int tlen = t.length();
    int ans = tlen;
    
    rep(i,slen-tlen+1){
        int cnt = 0;
        rep(j,tlen){
            
//            if(i+j > slen-2) break;
            //cout << i  << " "<< j << "   " <<  s[i] << endl;
            
            if(s[i+j] == t[j]){
                cnt++;
            }
        }
        //cout << cnt << endl;
        ans = min(ans,tlen-cnt);
    }

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

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

using namespace std ;

int main( void )
{

    int n ;

    cin >> n ;

    vector<int> v( n ) ;

    for( int i = 0 ; i < n ; i++ )  {

        cin >> v[i] ;

    }

    if( n == 1 )  {

        cout << v[0] ;
        return 0 ;

    }

    if( n % 2 == 0 )  {

        for( int i = n-1 ; i >= 0 ; i -= 2 )  {

        cout << v[i] << " " ;

        }

        for( int i = 0 ; i < n ; i += 2 )  {

            cout << v[i] << " " ;

        }

    }

    else  {

        for( int i = n-1 ; i >= 0 ; i -= 2 )  {

            cout << v[i] << " " ;

        }

        for( int i = 1 ; i < n ; i += 2 )  {

            cout << v[i] << " " ;

        }

    }

    return 0 ;

}


Measured memory_bytes: 2944
n=int(input())
l=[int(i) for i in input().split()]
l.sort()


def binarysearch(lista,b):
    left=0
    right=len(lista)
    while left<right:
        mid=(left+right)//2
        if lista[mid]>=b:
            right=mid
        else:
            left=mid+1
            mid+=1
    return mid

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=(binarysearch(l,l[i]+l[j])-(j+1))
print(ans)


Measured memory_bytes: 43372
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int n, m, x; cin >> n >> m >> x;
    vector<int> v;
    // int a[110] = {0};

    for (int i = 0; i <= n; i++) v.push_back(0);

    for (int i = 1; i <= m; i++) {
        int p; cin >> p;
        v[p] = 1;
    }

    cout << (min(count(v.begin(), v.begin() + x, 1), count(v.begin() + x, v.end(), 1))) << endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 100010;
const ll mod = 1e9 + 7;
ll power(ll x, ll   y, ll p){ ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;} return res; }
ll n, mat[22][22];
ll dp[(1<<21)];

ll solve(ll ind, ll mask){
    ll ret = 0;
    if(ind == n)    return 1;
    if(dp[mask] != -1)  return dp[mask];
    for(int i=0;i<21;i++){
        if((mask & (1<<i)) && mat[ind][i]){
            if(dp[(mask ^ (1<<i))] == -1)
                ret += solve(ind+1, (mask ^ (1<<i)));
            else    ret += dp[(mask ^ (1<<i))];
        }
        ret = ret%mod;
    }
    dp[mask] = ret;
    return dp[mask];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    memset(dp, -1, sizeof(dp));
    dp[0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)    cin>>mat[i][j];
    }
    cout<<solve(0, (1<<21) - 1)<<endl;
    return 0;
}

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

int main(){
    int n,m,sum=0;
    cin>>n>>m;
    int a[n][m],b[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++) cin>>b[i];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
        }
        cout<<sum<<endl;
        sum=0;
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,t,s;
    cin>>d>>t>>s;
    float v=(float)d/s;
    if(v<=t)
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No";
    }
	return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main(void){
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    puts("Bad");
  }
  else {
    puts("Good");
  }
  return 0;
}


Measured memory_bytes: 256
def init(n) :  #n要素で初期化
	for i in range(n) :
		par[i] = i;
		rank[i] = 0;
		siz[i] = 1;

def root(x) :  #木の根を求める
	if par[x] == x :  #根
		return x;
	else :
		par[x] = root(par[x]);  #経路圧縮
		return par[x];

def same(x,y) :  #xとyが同じ集合に属するか否か
	return root(x) == root(y);

def unite(x,y) :  #xとyの属する集合を併合
	x = root(x);
	y = root(y);
	if x == y :
		return;
	if siz[x] < siz[y] :
		x,y = y,x;
	siz[x] += siz[y];
	par[y] = x;

def size(x) :
	return siz[root(x)];


nmk = input().split(' ');
n = int(nmk[0]);
m = int(nmk[1]);
k = int(nmk[2]);

par = [0]*n
rank = [0]*n
siz = [0]*n
init(n);

fre = [[0]*2 for i in range(m)];
bro = [[0]*2 for i in range(k)];
fb = [0]*n;

for i in range(m) :
	ab = input().split(' ');
	unite(int(ab[0])-1,int(ab[1])-1);
	fb[int(ab[0])-1] += 1;
	fb[int(ab[1])-1] += 1;
	fre[i][0] = int(ab[0]);
	fre[i][1] = int(ab[1]);

for i in range(k) :
	ab = input().split(' ');
	bro[i][0] = int(ab[0]);
	bro[i][1] = int(ab[1]);

for i in range(k) :
	if root(bro[i][0]-1) == root(bro[i][1]-1) :
		fb[bro[i][0]-1] += 1;
		fb[bro[i][1]-1] += 1;

print(size(0)-fb[0]-1,end='');
for i in range(1,n) :
    print('',size(i)-fb[i]-1,end='');
print();


Measured memory_bytes: 44096
import collections as c
n,a1=int(input()),[*map(int,input().split())]
a2,a3,b=set(a1),c.Counter(a1),[0]*(10**6+1)
for i in a2:
  for j in range(i,10**6+1,i):
    b[j]+=1
print(sum(b[i]==1 and a3[i]==1 for i in a2))

Measured memory_bytes: 50500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n;
    cin >> n;
    ll L[n];
    ll ans;
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=n;i++){
        L[i]=L[i-1]+L[i-2];
    }
    cout << L[n] << endl;
    return 0;
}

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

int main(){
  int A,B,C,K; cin >> A >> B >> C >> K;
  for(int i=0; i<K; i++){
    if(A>=B) B*=2;
    else if(B>=C) C*=2;
  }
  if(A<B&&B<C) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3636
n = int(input())
a = []
for _ in range(n):
    a.append(input())
print("AC x {}".format(a.count("AC")))
print("WA x {}".format(a.count("WA")))
print("TLE x {}".format(a.count("TLE")))
print("RE x {}".format(a.count("RE")))

Measured memory_bytes: 16152
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int N, M, C;
  cin >> N >> M >> C;
  int B[30];
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  int A[30][30];

  int res = 0;
  for (size_t i = 0; i < N; i++) {
    int sum = C;
    for (size_t j = 0; j < M; j++) {
      cin >> A[i][j];
      sum += A[i][j]* B[j];
    }
    if (sum > 0) {
      res++;
    }
  }


  cout << res << "\n";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;struct P{float x,y;int operator-=(P&a){x-=a.x;y-=a.y;}};P A,B,C,S,G;int X(P S){C.x=(B.y*S.x-B.x*S.y)/(A.x*B.y-A.y*B.x);C.y=(A.y*S.x-A.x*S.y)/(A.y*B.x-A.x*B.y);return C.x>0&&C.y>0&&C.x+C.y<1;}main(){cin>>A.x;while(cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>S.x>>S.y>>G.x>>G.y){A-=C;B-=C;S-=C;G-=C;X(S)^X(G)?cout<<"OK\n":cout<<"NG\n";}return 0;}

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

bool prime(i64 n)
{
  if (n < 2)
    return false;
  else if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  i64 l = sqrt(n);
  for (int i = 3; i <= l; i += 2)
    if (n % i == 0)
      return false;
  return true;
}

int main()
{
  i64 x;
  cin >> x;
  for (i64 i = x;; i++)
    if (prime(i))
    {
      cout << i << endl;
      return 0;
    }
  return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())

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

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

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

    return arr

arr = factorization(N)
if N == 1:
    print(0)
    sys.exit()
else:
    print(sum([arr[i][1] for i in range(len(arr))]))

Measured memory_bytes: 9492
#include<iostream>
#include<vector>
using namespace std;
int GCD(int a, int b){
    if(a%b==0){
        return(b);
    }
    else {
        return(GCD(b, a%b));
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    vector<int> gcd1(N);
    vector<int> gcd2(N);
    gcd1[0]=A[0];
    gcd2[N-1]=A[N-1];
    for (int i=1;i<N;i++){
        gcd1[i]=GCD(gcd1[i-1],A[i]);
    }
    for (int i=N-2;i>=0;i--){
        gcd2[i]=GCD(gcd2[i+1],A[i]);
    }
    int ans=max(gcd2[1],gcd1[N-2]);
    for (int i=1;i<N-1;i++){
        ans=max(ans,GCD(gcd1[i-1],gcd2[i+1]));
    }
    cout << ans;

}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int a,b,c,d;
  cin >> a>>b >> c >> d;
 int n,m;
  if(c%b==0)n=c/b;
  else n=c/b+1;
  if(a%d==0)m=a/d;
  else m=a/d+1;
  
  if(n<=m)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;

int a, b; bool c[20][20];
int d, e, f, g, S;
int dx[4] = { -1,0,0,1 }, dy[4]{ 0,-1,1,0 };
void saiki(int x, int y, int h) {
	if (h == 10)return;
	for (int i = 0; i < 4; i++) {
		if (x + dx[i] >= 0 && x + dx[i] < a&&y + dy[i] >= 0 && y + dy[i] < b&&!c[x + dx[i]][y + dy[i]]) {
			for (int j = 1;; j++) {
				if (x + dx[i] * j == f&&y + dy[i] * j == g) {
					S = min(S, h + 1);
					return;
				}
				if (x + dx[i] * (j + 1) < 0 || x + dx[i] * (j + 1) >= a || y + dy[i] * (j + 1) < 0 || y + dy[i] * (j + 1) >= b)break;
				if (c[x + dx[i] * (j + 1)][y + dy[i] * (j + 1)]) {
					c[x + dx[i] * (j + 1)][y + dy[i] * (j + 1)] = false;
					saiki(x + dx[i] * j, y + dy[i] * j,h+1);
					c[x + dx[i] * (j + 1)][y + dy[i] * (j + 1)] = true;
					break;
				}
			}
		}
	}
}
int main() {
	while (cin >> b >> a, a | b) {
		for (int d = 0; d < a; d++) {
			for (int e = 0; e < b; e++) {
				int f; scanf("%d", &f);
				switch (f) {
				case 1:c[d][e] = true; break;
				case 0:c[d][e] = false; break;
				case 2:c[d][e] = false; ::d = d; ::e = e; break;
				case 3:c[d][e] = false; ::f = d; ::g = e; break;
				}
			}
		}
		S = 1 << 29;
		saiki(d, e, 0);
		if (S == 1 << 29)S = -1;
		cout << S << endl;
   }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int myrand() {return abs((int) mt());}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void chemthan() {
    int n; string s; cin >> n >> s;
    vi f(26);
    for (char c : s) f[c - 'a']++;
    int res = 1;
    FOR(i, 0, 26) res = mult(res, f[i] + 1);
    submod(res, 1);
    cout << res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
using namespace std;
int h;
int w;

vector<pair<int, int> > v;

int calct[1300][1300];
int calcy[1300][1300];

#define BASE 610

vector<int> vx[1300];
vector<int> vy[1300];

char buf[500];

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		scanf("%s", buf);
		for (int j = 0; j < w; j++) {
			if (buf[j] == '#') {
				v.push_back(make_pair(i + j, i - j));
				calct[i + j+BASE][i - j+BASE]++;
				calcy[i + j+BASE][i - j+BASE]++;
				vx[i + j + BASE].push_back(i - j+BASE);
				vy[i - j + BASE].push_back(i + j+BASE);
			}
		}
	}
	for (int i = 0; i < 1300; i++) {
		for (int j = 1; j <1300; j++) {
			calcy[i][j] += calcy[i][j - 1];
		}
	}
	for (int j = 0; j < 1300; j++) {
		for (int i = 1; i < 1300; i++) {
			calct[i][j] += calct[i - 1][j];
		}
	}
	long long int way = 0;
	for (int i = 0; i < 1300; i++) {
		sort(vx[i].begin(), vx[i].end());
		for (int j = 0; j < vx[i].size(); j++) {
			for (int k = j + 1; k < vx[i].size(); k++) {
				int dif = vx[i][k] - vx[i][j];
				int y1 = vx[i][j];
				int y2 = vx[i][k];
				int dir = -1;
				for (int tim = 0; tim < 2; tim++) {
					dir *= -1;
					int nex_x = i + dir*dif;
					if (nex_x >= 0 && nex_x < 1300) {
						way += calcy[nex_x][y2];
						if (y1)way -= calcy[nex_x][y1 - 1];
					}
				}
			}
		}
	}
	for (int i = 0; i < 1300; i++) {
		sort(vy[i].begin(), vy[i].end());
		for (int j = 0; j < vy[i].size(); j++) {
			for (int k = j + 1; k < vy[i].size(); k++) {
				int dif = vy[i][k] - vy[i][j];
				int x1 = vy[i][j];
				int x2 = vy[i][k];
				int dir = -1;
				for (int tim = 0; tim < 2; tim++) {
					dir *= -1;
					int nex_y = i + dir * dif;
					if (nex_y >= 0 && nex_y < 1300) {
						way += calct[x2-1][nex_y];
						way -= calct[x1][nex_y];
					}
				}
			}
		}
	}
	cout << way << endl;
	return 0;
}

Measured memory_bytes: 15220
from math import sqrt, floor
from collections import deque


def prime_generator():
    prime = set()
    yield 2
    i = 3
    while True:
        for d in prime:
            if not (i % d):
                break
        else:
            yield i
            prime.add(i)
        i += 2


nstr = input()
n = int(nstr)
limit = floor(sqrt(n))
a = deque()

for p in prime_generator():
    if p > limit:
        if n > 1:
            a.append(n)
        break
    while not (n % p):
        a.append(p)
        n = n // p
        limit = floor(sqrt(n))

a.appendleft(nstr + ':')
print(*a)

Measured memory_bytes: 8200
n = input()
s = len(n)
n = int(n)

if s == 1:
    print(n)
elif s == 2:
    print(9)
elif s == 3:
    print(9 + n - 99)
elif s == 4:
    print(9 + 900)
elif s == 5:
    print(9 + 900 + n - 9999)
else:
    print(9 + 900 + 90000)


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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> v(N+1, vector<int>(M+1, 0));
    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=M; ++j) {
            char c; cin >> c;
            v[i][j] = c == '1';
        }
    }
    vector<vector<int>> hsum(N+1, vector<int>(M+1)),
                        wsum(N+1, vector<int>(M+1));
    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=M; ++j) {
            wsum[i][j] = v[i][j] == 1 && v[i][j-1] == 1;
        }
    }
    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=M; ++j) {
            hsum[i][j] = v[i-1][j] == 1 && v[i][j] == 1;
        }
    }
    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=M; ++j) {
            hsum[i][j] += hsum[i-1][j] + hsum[i][j-1] - hsum[i-1][j-1];
            wsum[i][j] += wsum[i-1][j] + wsum[i][j-1] - wsum[i-1][j-1];
            v[i][j] += v[i-1][j] + v[i][j-1] - v[i-1][j-1];
        }
    }
    while(Q--) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << (v[x2][y2] - v[x2][y1-1] - v[x1-1][y2] + v[x1-1][y1-1])
                - (hsum[x2][y2] - hsum[x2][y1-1] - hsum[x1][y2] + hsum[x1][y1-1])
                - (wsum[x2][y2] - wsum[x2][y1] - wsum[x1-1][y2] + wsum[x1-1][y1]) << endl;
    }
}


Measured memory_bytes: 49792
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

int power(int a, int b, int MOD) {
	a = a % MOD;
	int res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}

	return res;
}

signed main() {
 

	int n, p;
	cin >> n >> p;

	string str;
	cin >> str;

	int ans = 0;
	if (p == 2 or p == 5) {
		for (int i = 0; i < n; i++) {
			if ((str[i] - '0') % p == 0) {
				ans += (i + 1);
			}
		}

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

	map<int,int> mp;
	mp[0] = 1;

	int cur = 0;
	int req = 0;
	for(int i = 0; i < n; i++){
		cur = cur* 10 + (str[i] - '0');
		cur = cur % p;

		int val = (power(10, n-1-i, p));
		val = val * cur;
		val = val % p;

		req += mp[val];

		mp[val]++;
	}


	cout << req << endl;



	return 0;
}






Measured memory_bytes: 1028
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;

ll n, W, w[N], v[N], dp[150][N];

int main()
{
	speed;
	cin >> n >> W;
	fore( i, 1, n + 1 ) {
		cin >> w[i] >> v[i];
	}
	fore( i, 1, n + 1 ) {
		forn( j, W + 1 ) {
			dp[i][j] = dp[i - 1][j];
			if ( j >= w[i] ) {
				dp[i][j] = max( dp[i][j], dp[i - 1][j - w[i]] + v[i] );
			}
		}
	}
	cout << dp[n][W];
	time;
}

Measured memory_bytes: 158464
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1e+18 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (ll)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// ll        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
vector<ll> am, ap;
ll msize, psize;
ll zero = 0;
ll k;
bool judge_m(ll mid)
{
  ll sum = 0;
  for (ll j : ap) {
    ll d = (mid - j + 1) / j;
    sum += upper_bound(ALL(am), d) - am.begin();
  }
  debug("mid,sum", mid, sum);
  return sum >= k;
}
ll judge_p(ll mid)
{
  ll sum = 0;
  rep(i, psize)
  {
    ll d = mid / ap[i];
    ll temp = upper_bound(ALL(ap), d) - ap.begin();
    if (i < temp)
      temp--;
    sum += temp;
  }
  rep(i, msize)
  {
    ll d = mid / am[i];
    ll temp = upper_bound(ALL(am), d) - am.begin();
    if (i < temp)
      temp--;
    sum += temp;
  }
  sum /= 2;
  debug(sum,mid,k);
  return sum >= k;
}

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n >> k;

  rep(i, n)
  {
    ll temp;
    cin >> temp;
    if (temp < 0) {
      am.push_back(temp);
      msize++;
    }
    if (temp > 0) {
      ap.push_back(temp);
      psize++;
    }
    if (temp == 0)
      zero++;
  }
  // - or 0 or +を判断する
  ll product_m = msize * psize;
  ll product_p = msize * (msize - 1) / 2 + psize * (psize - 1) / 2;
  ll product_z = n * (n - 1) / 2 - product_m - product_p;

  if (k <= product_m) {
    sort(ALL(am));
    sort(ALL(ap));
    ll l = -INF - 1;
    ll r = -1;
    while (r - l > 1) {
      ll mid = (l + r) / 2;
      if (judge_m(mid)) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << r << endl;
    return 0;
  } else if (k <= product_m + product_z) {
    cout << 0 << endl;
    return 0;
  } else {
    k -= (product_m + product_z);
    rep(i,msize) am[i] = abs(am[i]);
    sort(ALL(am));
    sort(ALL(ap));
    ll l = -1;
    ll r = 1e18;
    while (r - l > 1) {
      ll mid = (l + r) / 2;
      if (judge_p(mid)) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << r << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;


int main() {long n;
cin >> n;
long x = n/100; long ans;
if(n > x*100+x*10+x) ans = (x+1)*100+(x+1)*10+x+1;
else ans = x*100+x*10+x;
show(ans);
  return 0;
 
}



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

def solve(N: int, M: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    cnt_res = collections.Counter(A)

    for k,v in cnt_res.items():
        B.append(v)
        C.append(k)

    n    = N
    msum = 0
    for b,c in sorted(zip(B,C),key=lambda x:x[1],reverse = True):
        if n >= b:
            n    -= b
            msum += (c*b)
        else:
            msum += (c*n)
            break
              
    print(msum)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]" 
    C = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, A, B, C)

if __name__ == '__main__':
    main()


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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  vector<string> C(h);
  for (auto &s : C) cin >> s;
  for (int i = 0; i < 2*h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << C[i/2][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 256
N, L = map(int, input().split())
a = list(map(int, input().split()))

#最後に切るものを決める
i = 0
flag = False
while i < N - 1:
    if a[i] + a[i + 1] >= L:
        flag = True
        break
    i += 1

if not flag:
    print ('Impossible')
else:
    print ('Possible')
    for j in range(i):
      print (j + 1)
    for j in range(N - 1, i, -1):
      print (j)


Measured memory_bytes: 14064
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int X, Y, Z, A, B, C, N;

signed main() {
    cin >> X >> Y >> Z >> A >> B >> C >> N;

    // val[i] := X 軸と平行に 1 行見たとき、i はいくつある？
    // coeff[i] := Y 軸と平行に 1 行見たとき、i はじまりのものはいくつある？
    // board[i] := XY 平面を Z = 0 で切り出したとき、i はいくつある？
    vector<int> coeff(N), zcoeff(N), val(N), board(N), cube(N);
    {
        for(int i=0; i<X; i++) {
            int dist = abs(i - A);
            val[dist % N]++;
        }
    }
    {
        for(int i=0; i<Y; i++) {
            int dist = abs(i - B);
            coeff[dist % N]++;
        }
    }
    {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                board[(i+j+N)%N] += val[i] * coeff[j];
            }
        }
    }
    {
        for(int i=0; i<Z; i++) {
            int dist = abs(i - C);
            zcoeff[dist % N]++;
        }
        
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                cube[(i+j+N)%N] += board[i] * zcoeff[j];
            }
        }
    }

    int shift = (A + B + C) % N;
    shift = N - shift;
    for(int i=0; i<N; i++) {
        printf("%lld%c", cube[i], " \n"[i+1 == N]);
    }
    return 0;
}



Measured memory_bytes: 3240
n,m = list(map(int,input().split()))
a = [0]*n
s=0
pe=0
for i in range(m):
    p,v = input().split()
    p = int(p)
    if(v=="WA"):
        if(a[p-1] != 1):
            a[p-1] = a[p-1]-1
    elif(v == "AC"):
        if(a[p-1]==1):
            continue
        else:
            pe-=a[p-1]
            a[p-1] = 1
            s+=1
print(s,pe)            
        
        

Measured memory_bytes: 50648
import math
N,P=map(int,input().split())
flag=1
count=0
z=[]
if P % 2 == 0:
	while P%2 == 0:
		P = P//2
		count+=1
	z.append([2,count])
for i in range(3,P+1)[::flag]:
	count=0
	if P == 1:
		break
	if i > math.sqrt(P):
		z.append([P,1])
		break
	if P%i == 0:
		while P%i == 0:
			P = P//i
			count += 1
		z.append([i,count])
ans=1

for zz in z:
	if zz[1] >= N:
		ans*=zz[0]**(zz[1]//N)
print(ans)

Measured memory_bytes: 3064
using System;
class Program
{
    static void Main()
    {
        string[] In = Console.ReadLine().Split(' ');
        int TH = int.Parse(In[0]);
        int TA = int.Parse(In[1]);
        int AH = int.Parse(In[2]);
        int AA = int.Parse(In[3]);
        while (true)
        {
            AH -= TA;
            if (AH <= 0) { Console.WriteLine("Yes"); break; }
            TH -= AA;
            if (TH <= 0) { Console.WriteLine("No"); break; }
        }
    }
}

Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n,m;
    cin>>n>>m;
    Graph G(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    vector<int> dist(n,-1);
    queue<int> que;
    int count=0;
    rep(i,n){
        if(dist[i]!=-1) continue;
        dist[i]=count;
        que.push(i);
        while(!que.empty()){
            int v=que.front();
            que.pop();
            for(int nv:G[v]){
                if(dist[nv]!=-1) continue;
                dist[nv]=dist[v];
                que.push(nv);
            }
        }
        count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 9808
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

set<int> s;

int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		s.insert(t);
	}
	if (s.size() == n) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 9600
# 誤読したか？

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, M = read_ints()
from collections import defaultdict
flgs = [False] * N  # N問をACしたか
n_wa_ls = [0] * N


for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if flgs[p]:
        continue
    if s == 'AC':
        flgs[p] = True
    elif s == 'WA':
        n_wa_ls[p] += 1

n_wa = 0
for i in range(N):
    if flgs[i]:
        n_wa += n_wa_ls[i]

print(sum(flgs), n_wa)


Measured memory_bytes: 4852
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	auto S = split(readln())[0];
	auto year = to!int(S[0 .. 4]), month = to!int(S[5 .. 7]), day = to!int(S[8 .. 10]);
	string result = (year < 2019 || year == 2019 && month < 4 || year == 2019 && month == 4 && day <= 30) ? "Heisei" : "TBD";
	writeln(result);
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int M = max({ A, B, C });
	int Dif = M - A + M - B + M - C;
	int ans = Dif % 2 == 0 ? Dif / 2 : (Dif + 1) / 2 + 1;
	cout << ans;
}

Measured memory_bytes: 256