akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m=sc.nextInt();
		int d=sc.nextInt();
		int ans=0;
		for(int i=4; i<=m; i++){
			for(int j=10; j<=d; j++){
				if((j%10)>=2 && (j/10)>=2 && (j%10)*(j/10)==i){
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}



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

int main(){
    int N, sum=1, flag=1;
    cin>>N;
    int H[N];
    for (int i = 0; i < N; i++)
    {
        cin>>H[i];
    }
    for (int i = 0; i < N-1; i++)
    {
        for (int j = 0; j < i+1; j++)
        {
            flag=1;
            if (H[i+1]<H[j])
            {
                flag=0;
                break;
            }
            
        }
        if (flag)
        {
            sum+=1;
        }
        
        
        
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3620
function main()
  
  N = parse(Int,readline())
  
  check = true
  
  for i in 0:N, j in 0:N
    
    if N == 4i+7j
      check = false
      println("Yes")
      break
    end
    
  end
  
  if check
    println("No")
  end
  
end

main()

Measured memory_bytes: 114204
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int A,B,m,a[100010],b[100010],ans=INF,minA=INF,minB=INF;
signed main(){
    cin>>A>>B>>m;
    rep(i,A){
        cin>>a[i];
        chmin(minA,a[i]);
    }
    rep(i,B){
        cin>>b[i];
        chmin(minB,b[i]);
    }
    rep(i,m){
        int x,y,c;
        cin>>x>>y>>c;
        x--,y--;
        chmin(ans,a[x]+b[y]-c);
    }
    chmin(ans,minA+minB);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
 
const double EPS = 1e-8, PI = acos(-1);
const int MAXN = 105;
 
struct point {
	double x, y;
	int id;
	
	point() {}
	point(double _x, double _y, int _id = -1) : x(_x), y(_y), id(_id) {}
	bool operator<(const point &another) const;
};
 
struct ans {
	double val;
	int id;
 
	ans() {}
	bool operator<(const ans &another) const
	{
		return id < another.id;
	}
};
 
int tot, n;
point p[MAXN], s[MAXN], normal[MAXN];
ans an[MAXN];
bool visited[MAXN];
 
int sgn(double x)
{
	if (fabs(x) < EPS) return 0;
	return (x > 0 ? 1 : -1);
}
 
double det(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.y - b1.y) - (a2.y - a1.y) * (b2.x - b1.x));
}
 
double dot(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.x - b1.x) + (a2.y - a1.y) * (b2.y - b1.y));
}
 
double dist(const point &p1, const point &p2)
{
	return sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
}
 
bool point::operator<(const point &another) const
{
	if (sgn(det(p[0], *this, p[0], another)) == 0)
		return dist(p[0], *this) < dist(p[0], another);
	else
		return det(p[0], *this, p[0], another) > 0;
}
 
void graham()
{
	double min_y = p[0].y, min_x = p[0].x;
	int index = 0;
	for (int i = 1; i <= n - 1; i++) {
		if (p[i].y < min_y || (sgn(p[i].y - min_y) == 0 && p[i].x < min_x)) {
			min_y = p[i].y;
			min_x = p[i].x;
			index = i;
		}
	}
	swap(p[0], p[index]);
	sort(p + 1, p + n);
	s[0] = p[0]; s[1] = p[1];
	tot = 2;
	for (int i = 2; i <= n - 1; i++) {
		while (tot >= 2 && sgn(det(s[tot - 1], p[i], s[tot - 1], s[tot - 2]) < 0)) tot--;
		s[tot++] = p[i];
	}
}
 
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf %lf", &p[i].x, &p[i].y);
		p[i].id = i;
	}
	graham();
	for (int i = 0; i < tot; i++) {
		if (i == 0) {
			normal[i].y = -(s[i].x - s[tot - 1].x);
			normal[i].x = s[i].y - s[tot - 1].y;
			normal[i].id = s[i].id;
		}
		else {
			normal[i].y = -(s[i].x - s[i - 1].x);
			normal[i].x = s[i].y - s[i - 1].y;
			normal[i].id = s[i].id;
		}
	}
	point zero(0, 0);
	for (int i = 0; i < tot; i++) {
		if (i == tot - 1) {
			an[i].val = acos(dot(zero, normal[i], zero, normal[0]) / dist(zero, normal[i]) / dist(zero, normal[0])) / PI / 2;
			an[i].id = normal[i].id;
		}
		else {
			an[i].val = acos(dot(zero, normal[i], zero, normal[i + 1]) / dist(zero, normal[i]) / dist(zero, normal[i + 1])) / PI / 2;
			an[i].id = normal[i].id;
		}
	}
	memset(visited, false, sizeof(visited));
	for (int i = 0; i < tot; i++) visited[s[i].id] = true;
	for (int i = 0; i < n; i++)
		if (!visited[i]) {
			an[tot].val = 0.0000000;
			an[tot++].id = i;
		}
	sort(an, an + n);
	for (int i = 0; i < n; i++) printf("%.8f\n", an[i].val);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> c(N), check(M);
    rep(i, N) cin >> c[i].first >> c[i].second;
    rep(i, M) cin >> check[i].first >> check[i].second;
    vector<int> ans(N);
    rep(i, N) {
        long long tmp = 1e9;
        int p;
        rep(j, M) {
            if(tmp > abs(c[i].first - check[j].first) + abs(c[i].second - check[j].second)) {
                tmp = abs(c[i].first - check[j].first) + abs(c[i].second - check[j].second);
                p = j;
            }
        }
        ans[i] = p+1;
    }
    rep(i, N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,b,f,r,v;  // ｎは情報の数, bは棟の数、fは階数、rは何番目の部屋、vは入居してきた人数
    cin >> n;
    int house[4][3][10] = {0};
    
    for(int i = 0; i<n; i++){
        cin >> b >> f >> r >> v;
        house[b-1][f-1][r-1] += v;
    }
    
    for(int j = 0;j < 4; j++){
        
        for(int k = 0; k < 3 ;k++){
            
            for(int l = 0; l < 10; l++){
                cout << " " << house[j][k][l];
            }
            cout << endl;
        }
        
        if(j != 3){
            for(int z = 0; z < 20; z++){
                cout << "#";
            }
            cout << endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>

using namespace std;

typedef long long ll;

ll mod;
bool a[3000];

ll modpow(ll a, ll b) {
	ll base = 1, kakeru = a;
	while (b) {
		if (b & 1) {
			base *= kakeru, base %= mod;
		}
		kakeru *= kakeru, kakeru %= mod;
		b >>= 1;
	}
	return base;
}

namespace comb {
	ll fact[500001];
	ll fact_inv[500001];
	ll MOD = 1000000007;

	ll modpow(ll a, ll b) {
		ll base = 1, kakeru = a;
		while (b > 0) {
			if (b & 1)base *= kakeru, base %= MOD;
			kakeru *= kakeru, kakeru %= MOD;
			b >>= 1;
		}
		return base;
	}

	void setup() {
		fact[0] = 1, fact[1] = 1;
		for (int i = 2; i < MOD; i++) {
			fact[i] = (fact[i - 1] * i) % MOD;
		}

		fact_inv[MOD - 1] = modpow(fact[MOD - 1], MOD - 2);

		for (int i = MOD - 2; i >= 0; i--) {
			fact_inv[i] = fact_inv[i + 1] * (i + 1);
			fact_inv[i] %= MOD;
		}

	}

	ll combination(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[b], ret %= MOD;
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll permutation(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll homogeneous(int a, int b) {
		return combination(a + b - 1, b);
	}

}
int main() {

	cin >> mod;
	comb::MOD = mod;
	comb::setup();
	for (int i = 0; i < mod; i++)cin >> a[i];
	
	int ans[3000] = {};

	for (int i = 0; i < mod; i++) {
		if (a[i] == true) {
			ans[0]++;
			int base = 1;
			for (int j = 0; j < mod; j++) {
				
				ans[mod - 1 - j] -= comb::combination(mod - 1, j) * base;
				ans[mod - 1 - j] %= mod;
				ans[mod - 1 - j] += mod * 100000;
				ans[mod - 1 - j] %= mod;
				base *= -i, base += mod * 100000, base %= mod;
			}
		}
	}
	for (int i = 0; i < mod; i++)cout << ans[i] << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long double ans = 0;
  long double pie = 3.141592653589793238;
  int a;
  cin >> a;
  
  ans = a * 2;
  ans = ans * pie;
  
  cout << std::setprecision(12) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3800
/*
 * atcoder/abc127/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
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; }
template <class T> void dump(vector<T> &a) { for (auto &&i: a) cout << i << " "; cout << endl; }

struct C {
  ll val, num;
  bool operator<(const C& a)const{
    return val < a.val;
  }
};

int N, M;
vector<ll> A;
vector<C> CS;
void solve() {
  cin >> N >> M;
  A.resize(N);
  loop(n,0,N) cin >> A[n];
  sort(A.begin(), A.end());
  ll b, c;
  loop(m,0,M) {
    cin >> b >> c;
    CS.push_back({ c, b });
  }
  sort(CS.begin(), CS.end());
  reverse(CS.begin(), CS.end());
  // dump(A);
  // dump(CS);
  ll total = 0;
  int k=0, k_i = 0;
  loop(n,0,N) {
    if (CS[k_i].val > A[n]) {
      total += CS[k_i].val;
      if (--CS[k_i].num == 0) k_i++;
      k++;
    }
    else total += A[n];
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

    class Re
    {
        static void Main()
        {
            var a=Console.ReadLine();
            int b = int.Parse(a.Split(' ')[0]);
            int c = int.Parse(a.Split(' ')[1]);
            Console.WriteLine( b*c+ " " + (b+c)*2);

        }
    }

Measured memory_bytes: 5608
MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
f = 1
for i in range(n):
    f *= (i + 1)
    f %= MOD
l = [0] * n
for i in range(n - 1):
    l[i + 1] = l[i] + f * pow(i + 2, MOD - 2, MOD)
    l[i + 1] %= MOD
ans = 0
for i in range(n):
    ans += (l[i] + l[n - i - 1] + f) * a[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 14380
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
ll a[N],b[N],pref[N];
ll cnt[N];
 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		pref[i]=pref[i-1]+a[i];
	}
	ll k=(n*1ll*(n+1)/2);
	if(pref[n]%k!=0)
		return cout<<"NO",0;
	ll x=pref[n]/k;
	a[n+1]=a[1];
	ll cc=0;
	for(int i=1;i<=n;++i)
	{
		if(x+(a[i]-a[i+1])>0)
		{
			ll f=x+(a[i]-a[i+1]);
			cnt[i]=f/n;
			cc+=f/n;
			cnt[i+n]=cnt[i];
		}
	}
	ll sum=0;
	ll d=0,done=0;
	ll del=0;
	for(int i=1;i<=n+n;++i)
	{
		b[i]=d*i-done;
		done+=i*1ll*cnt[i];
		if(i>n)done-=(i-n)*1ll*cnt[i];
		d+=cnt[i];
		if(i>n)	d-=cnt[i-n];
	}
	for(int i=1;i<=n;++i)
		b[i]=b[i+n];
	for(int i=1;i<=n;++i)
		if(b[i]!=a[i])
			return cout<<"NO",0;
	cout<<"YES";
	return 0;	
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n,m;
  cin>>n>>m;
  vector<int>d(m);
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){ 
      int a;
      cin>>a;
      d[a-1]++;
    }
  }
  int ans=0;
  rep(i,m){
    if(d[i]==n)
      ans++;
  }
  cout<<ans<<endl;
}
      

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

long long cnt;
int A[1000000];
vector<int> G;
void insertionSort (int A[], int n, int g){
    for (int i = g; i < n; ++i){
        /*for (int j = i; j >= g; j -= g){
            if (A[j-g] > A[j])
                swap(A[j-g], A[j]);
        }*/
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}
void shellSort (int A[], int n){
    int h = 1;
    while (h <= n){
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size()-1; i >= 0; --i){
        insertionSort(A, n, G[i]);
    }
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> A[i];
    }
    shellSort(A, n);
    cout << G.size() << endl;
    for (int i = G.size()-1; i >= 0; --i){
        if (i == G.size()-1)
            cout << G[i];
        else
            cout << " " << G[i];
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n; ++i){
        cout << A[i] << endl;
    }
    return 0;
}



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

int main() {
	long n,m,x,y,ans=0,i,j;
	cin >> n >> m;
	vector<long> b(n);
	for(i=0; i<n; i++){
		cin >> x >> y;
		b[i]=x*10001+y;
	}
	sort(b.begin(),b.end());
	multiset<long> a;
	auto itr=a.end();
	i=0;
	for(j=1; j<=m; j++){
		while(b[i]/10001<=j && i<n){
			a.insert(b[i]%10001);
			i++;
		}
		if(a.size()>0){
			itr=a.end();
			itr--;
			ans+=*itr;
			a.erase(itr);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5632
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, K, S = map(int, input().split())
    
    A = [S]*N
    if S == 10**9:
        for i in range(N-K):
            A[i] = S - 1
    else:
        for i in range(N-K):
            A[i] = 10**9

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


if __name__ == '__main__':
    main()

Measured memory_bytes: 91624
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

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

int main(void)
{
    int n;
    cin >> n;
    int a[n], b[n];
    REP(i, n)
    {
        cin >> a[i];
    }
    b[0] = a[0];
    for (int i = 1; i < n; i++)
    {
        b[i] = gcd(b[i - 1], a[i]);
    }
    cout << b[n - 1] << endl;
}

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

int main(void)
{
    long n,k;
    long b,a,temp=0;
    cin >> n >> k;
    temp = n / k;
    b = n - k * temp;
    a = b - k;
    // cout << a << " "<< b<<endl;
    a = a * -1;
    temp = min(a,b);
    cout<<temp<<"\n";
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
int min(long long int a,long long int b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}
int main(void)
{
  long long int l,r,i,j;
  int ans=2018;
  scanf("%lld%lld",&l,&r);
  r=min(r,l+4038);//modが同じ数が3つ以上いらない
//  printf("%lld %lld \n" ,l,r);
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      int x = i*j%2019;
      ans=min(ans,x);
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
def main():
    n, D = map(int, input().split())
    ans = 0
    
    for _ in range(n):
        x, y = map(int, input().split())
        d = (x**2 + y**2)**(0.5)
        if d <= D:
            ans += 1
        
    print(ans)
   
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9636
using System;

namespace AtCoder172
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var count = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27268
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    ll n;
    while(cin>>n){
        ll ans=n-1;
        for(ll i=1; i*i<=n; ++i){
            if(n%i==0){
                ans=min(ans, i-1+n/i-1);
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S=in<string>();
    int m;
    m=(S[5]-'0')*10+(S[6]-'0');
    if(m>=5){
        cout<<"TBD"<<endl;
    }else{
        cout<<"Heisei"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << '\n';
    return 0;
}



Measured memory_bytes: 3624
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

s.sort()
t.sort()

ans = 0
sset = set(s)

for si in sset:
    ans = max(ans, s.count(si)-t.count(si))
print(ans)

Measured memory_bytes: 3064
// AOJ 0056: Goldbach's Conjecture
// 2017.10.28 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX  50000
#define SQRT 223     // sqrt(MAX)

char table[MAX+1], *pmax = table+MAX;
int combi[MAX+MAX] = {0,0,0,0,1,0};
int prime[5200], sz;

int main()
{
	int i, j;
	char buf[10];
	char *p, *p2;
	int *q;

	for (p = table+3, i = 3; i <= SQRT; p += 2, i += 2) if (!*p) {
		for (p2 = p + i; p2 <= pmax; p2 += i) *p2 = 1;
	}

	for (q = prime, i = 3; i <= MAX; i += 2) if (!table[i]) *q++ = i;
	sz = q - prime;

	for (i = 0; i < sz; i++) for (j = i; j < sz; j++)
		combi[prime[i] + prime[j]]++;

	while (fgets(buf, 8, stdin) && *buf != '0') {
		i = 0, p = buf; while (*p >= '0') i = (i<<3) + (i<<1) + (*p++ & 0xf);
		if (i & 1) putchar('1'-table[i-2]);
		else printf("%d", combi[i]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2088
#include <iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;

    int K;
    cin >> K;

    // 文字列の入力
    string S;
    cin >> S;

    S[K-1] = tolower(S[K-1]);

    // 出力
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[21],b[21],c[21],i,n,ans=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  for(i=0; i<n; i++){
    scanf("%d",&b[i]);
    ans+=b[i];
  }
  // printf("%d\n",ans);
  for(i=0; i<n-1; i++){
    scanf("%d",&c[i]);
  }
  for(i=0; i<n-1; i++){
    if(a[i]+1==a[i+1]){
      ans+=c[a[i]-1];
      // printf("%d\n",ans);
    }
  }
  
  printf("%d\n",ans);
  return 0;

}


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

int d;
vector<int> c;
vector< vector<int> > s;

int satisfaction(const vector<int>& t) {
  vector<int> last(26, -1);
  int ans = 0;
  for (int i = 0; i < (int) t.size(); i++) {
    ans += s[i][t[i]];
    last[t[i]] = i;
    for (int j = 0; j < 26; j++) {
      ans -= c[j] * (i - last[j]);
    }
  }
  return ans;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int myrand(int l, int r) {
  return uniform_int_distribution<int>(l, r)(rng);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  srand(time(nullptr));
  cin >> d;
  c.resize(26);
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  s.assign(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> t;
  for (int i = 0; i < d; i++) {
    vector<int> tmp = t;
    vector<int> best = {-1};
    for (int j = 0; j < 26; j++) {
      tmp.push_back(j);
      if (best[0] == -1 || satisfaction(tmp) > satisfaction(best)) {
        best = tmp;
      }
      tmp.pop_back();
    }
    swap(t, best);
  }
  for (int i = 0; i < 50000; i++) {
    int pos = myrand(0, d - 1), x = myrand(0, 25);
    vector<int> tmp = t;
    tmp[pos] = x;
    if (satisfaction(tmp) > satisfaction(t)) {
      swap(t, tmp);
    } 
  }
  for (auto& x : t) {
    cout << x + 1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 3740
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4 8 2"# => r#"3"#,
r#"0 5 1"# => r#"6"#,
r#"9 9 2"# => r#"0"#,
r#"1 1000000000000000000 3"# => r#"333333333333333333"#,
}

fn f(n:i64, x:i64) -> i64 {
    if n >= 0 {
        n / x + 1
    } else {
        0
    }
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64, b: i64, x: i64,
    }

    (f(b, x) - f(a - 1, x)).to_string()
}

Measured memory_bytes: 4352
#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)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    string S;
    cin >> S;
    int N = S.size();
    string T = "ATGC";
    int ans = 0;
    int cnt = 0;
    rep(i,N){
        bool ok = false;
        rep(j,4){
            if(S[i] == T[j]){
                ok = true;
            }
        }
        if(ok)cnt++;
        else{
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;
}

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

using namespace std;

int n,m;
char s[102][101];
char c[101];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]);
    for(int i=n-1;i>=1;i--)
        for(int j=1;j<=i;j++)
        {
            if(strcmp(s[j+1],s[j])<0)
            {
                strcpy(c,s[j+1]);
                strcpy(s[j+1],s[j]);
                strcpy(s[j],c);
            }
        }
    for(int i=1;i<=n;i++)
        printf("%s",s[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
 
        if (a==3||a==5||a==7)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 22996
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

count = 0
for i,braver in enumerate(B):
    result = A[i] - braver
    count += A[i] if result <= 0 else braver
    braver = braver - A[i]
    if braver > 0:
        nresult = A[i+1] - braver
        count += A[i+1] if nresult <= 0 else braver
        A[i+1] = nresult if nresult > 0 else 0
print(count)

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	int i = 0;
	rep(i,s.size()){
		if(s[i] == 'A' ||s[i] == 'C' ||s[i] == 'G' ||s[i] == 'T'){
			int count = 1;
			i++;
			while(s[i] == 'A' ||s[i] == 'C' ||s[i] == 'G' ||s[i] == 'T'){
				count++;
				i++;
				if(i == s.size()) break;
			}
			ans = max(ans, count);
		}
	}
	
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#define taskname "test"

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 2e5 + 5;
const lli inf = 1e17;
int n, q;
int a, b;
int x[maxn];

struct segment_tree
{
    lli min_val[maxn * 4], lazy[maxn * 4];

    void init()
    {
        fill(begin(min_val), end(min_val), inf);
    }

    void push(int x)
    {
        lli t = lazy[x];
        if(t == 0) return;

        min_val[x * 2] += t; lazy[x * 2] += t;
        min_val[x * 2 + 1] += t; lazy[x * 2 + 1] += t;

        lazy[x] = 0;
    }

    void update(int x, int l, int r, int p, lli val)
    {
        if(p < l || p > r) return;
        if(l == r)
        {
            min_val[x] = val;
            return;
        }
        push(x);
        int mid = (l + r) / 2;
        update(x * 2, l, mid, p, val);
        update(x * 2 + 1, mid + 1, r, p, val);
        min_val[x] = min(min_val[x * 2], min_val[x * 2 + 1]);
    }

    void inc(int x, int l, int r, int L, int R, int k)
    {
        if(L > r || l > R) return;
        if(l >= L && r <= R)
        {
            min_val[x] += k;
            lazy[x] += k;
            return;
        }
        push(x);
        int mid = (l + r) / 2;
        inc(x * 2, l, mid, L, R, k);
        inc(x * 2 + 1, mid + 1, r, L, R, k);
        min_val[x] = min(min_val[x * 2], min_val[x * 2 + 1]);
    }

    lli get(int x, int l, int r, int L, int R)
    {
        if(L > r || l > R || L > R) return inf;
        if(l >= L && r <= R)
            return min_val[x];
        push(x);
        int mid = (l + r) / 2;
        return min(get(x * 2, l, mid, L, R),
                   get(x * 2 + 1, mid + 1, r, L, R));
    }
} tree_dp, tree_tmp1, tree_tmp2;

void read_input()
{
    cin >> n >> q;
    cin >> a >> b;
    x[0] = b;
    for(int i = 1; i <= q; ++i)
        cin >> x[i];
}

void init()
{
    tree_dp.init(); tree_tmp1.init(); tree_tmp2.init();
    tree_dp.update(1, 1, n, a, 0);
    tree_tmp1.update(1, 1, n, a, a);
    tree_tmp2.update(1, 1, n, a, -a);
}

void solve()
{
    for(int i = 1; i <= q; ++i)
    {
        int tmp = abs(x[i] - x[i - 1]);
        tree_dp.inc(1, 1, n, 1, n, tmp);
        lli min_dp = tree_tmp1.get(1, 1, n, x[i], n) - x[i];
        min_dp = min(min_dp, tree_tmp2.get(1, 1, n, 1, x[i] - 1) + x[i]);
        tree_tmp1.inc(1, 1, n, 1, n, tmp);
        tree_tmp2.inc(1, 1, n, 1, n, tmp);

        if(min_dp < tree_dp.get(1, 1, n, x[i - 1], x[i - 1]))
        {
            tree_dp.update(1, 1, n, x[i - 1], min_dp);
            tree_tmp1.update(1, 1, n, x[i - 1], min_dp + x[i - 1]);
            tree_tmp2.update(1, 1, n, x[i - 1], min_dp - x[i - 1]);
        }
    }
    cout << tree_dp.get(1, 1, n, 1, n) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    init();
    solve();
}


Measured memory_bytes: 37888
# Connect Cities
# Union Findデータ構造（素集合データ構造）

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

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

	def find(self,x):
		if self.parents[x] < 0: #自分が親である時
			return x
		else: #自分が子供である時
			self.parents[x]=self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		# 各要素の親要素を返す
		x=self.find(x)
		y=self.find(y)

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

#		self.parents[x]+=self.parents[y]
		self.parents[y]=x
		# print(self.parents)
n,m=input2()
AB=[input_array() for _ in range(m)]


uf = UnionFind(n)
for ab in AB:
	a=ab[0]
	b=ab[1]
	uf.union(a-1,b-1)

ans=0
for i in uf.parents:
	if i < 0:
		ans+=1
print(ans-1)


Measured memory_bytes: 28968
function Main(input) {
  
	tmp = input.split(" ");
	var l = parseInt(tmp[0], 10);
	var r = parseInt(tmp[1], 10);
	var d = parseInt(tmp[2], 10);
	
	var ans = 0;
	for(i=l; i<=r; i++){
	  if(i % d == 0){
	    ans++;
	  }
	}
	console.log(ans);
}

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

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

int main(){
  int k, n;
  cin >> k >> n;
  vector<int> A(n);
  for (int i=0; i<n; i++) cin >> A[i];
  int max_l = A[0] + k - A[n-1];
  for (int i=0; i<n-1; i++){
    max_l = max(max_l, A[i+1] - A[i]);
  }
  cout << k - max_l << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
#import string
from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    S = []
    for i in range(n):
        s = str(stdin.readline().rstrip())
        S.append(s)
    c = Counter(S)
    print("AC x "+str(c["AC"]))
    print("WA x "+str(c["WA"]))
    print("TLE x "+str(c["TLE"]))
    print("RE x "+str(c["RE"]))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 16604
#include "iostream"
#include <vector>
#include <array>

struct PosData {
    int32_t x;
    int32_t y;
    int32_t time;
};

int main()
{
    uint32_t N;
    std::cin >> N;

    std::vector<PosData> posDataList(N);
    for (auto& posData : posDataList) {
        std::cin >> posData.time >> posData.x >> posData.y;
    }

    /* 原点を追加 */
    posDataList.insert(posDataList.begin(), {0,0,0});

    bool isEnable = true;
    for (uint32_t i = 1; i < posDataList.size(); i++) {
        auto& prePosData = posDataList[i - 1];
        auto& posData =  posDataList[i];

        auto time = posData.time - prePosData.time;
        auto minTime = std::abs(posData.x - prePosData.x) + std::abs(posData.y - prePosData.y);

        if (time - minTime < 0) {
            isEnable = false;
            break;
        }

        if ((time - minTime) % 2 != 0) {
            isEnable = false;
            break;
        }

    }

    if (isEnable) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9;
vector<int> dist[2020];
struct egde{
    int u,v;
}e[2020];
int vis[2020];
int N,K;
int dfs1(int pos,int dis)
{
	int res = 0;
	if(dis>K/2) res++;
	vis[pos] = 1;
	for(int i = 0;i < dist[pos].size();i++){
		if(!vis[dist[pos][i]]){
			res += dfs1(dist[pos][i],dis+1);
			//cout<<"res:"<<res<<endl;
		}
	}
	return res;
}
int main()
{
	scanf("%d%d",&N,&K);
	for(int i = 1;i <= N-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		dist[a].push_back(b);
		dist[b].push_back(a);
		e[i].u = a;
		e[i].v = b;
	}
	if(K%2==0){
		int ans = INF;
		for(int i = 1;i <= N;i++){
			memset(vis,0,sizeof(vis));
			vis[i] = 1;
			ans = min(dfs1(i,0),ans);
		}
		cout<<ans<<endl;
	}
	else{
		int ans = INF;
		for(int i = 1; i<= N-1;i++){
            memset(vis,0,sizeof(vis));
            vis[e[i].u] = 1;
            vis[e[i].v] = 1;
            ans = min(ans,dfs1(e[i].u,0)+dfs1(e[i].v,0));
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
N,Y = map(int, input().split())

ans = ['-1', '-1', '-1']

money = 0
for i in range(N+1):
  for j in range(N+1-i):
    money = 10000 * i + 5000 * j + 1000 * (N - i - j)
    if (money == Y):
      ans = [str(i), str(j), str(N - i - j)]
      break
print(" ".join(ans))


Measured memory_bytes: 3316
/*
 * x 軸上に N 人の人が立っています。 人 i の位置を xi とします。 任意の i に対して、xi は 0 以上 10^9 以下の整数です。 同じ位置に複数の人が立っていることもありえます。
 * 
 * これらの人の位置に関する情報が M 個与えられます。 このうち i 個めの情報は (Li,Ri,Di) という形をしています。 
 * この情報は、人 Ri は人 Li よりも距離 Di だけ右にいること、 すなわち、xRi−xLi=Di が成り立つことを表します。
 * 
 * これら M 個の情報のうちのいくつかに誤りがある可能性があることがわかりました。 与えられる M 個すべての情報と矛盾しないような値の組 (x1,x2,…,xN) が存在するかどうか判定してください。
 */

import java.util.*;
	public class Main{
		//各人をグラフ上の点とみて、その点の所属を示す配列
		static int[] belongs = null;
		//各人の位置の配列states
		static int[] states = null;
        
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());
            states = new int[n];
            belongs = new int[n];
            
            //位置は0で、所属はiで初期化する
            for(int i=0; i<n; i++){
            	belongs[i] = i;
            	states[i] = 0;
            }
            
            for(int i=0; i<m; i++){
            	int l = Integer.parseInt(sc.next())-1;
            	int r = Integer.parseInt(sc.next())-1;
            	int d = Integer.parseInt(sc.next());
            	//mergeできなかったら終了する
            	if(!merge(l, r, d)){
            		System.out.println("No");
            		sc.close();
            		return;
            	}
            }
            System.out.println("Yes");
            sc.close();
		}
        
		//aの最新の所属を返す関数updateBelongs（所属が変わってる場合にはstatesも更新する）
		public static int updateBelongs(int a){
			if(a == belongs[a]){
				return a;
			}else{
				int temp = belongs[a];
				belongs[a] = updateBelongs(belongs[a]);
				//所属が特に変わってない場合にはstates[temp] = 0
				states[a] += states[temp];
				return belongs[a];
			}
		}
		
		//条件のマージをし、それの結果を表示する関数merge
		public static boolean merge(int l, int r, int d){
			int lb = updateBelongs(l);
			int rb = updateBelongs(r);
			
			//所属が同じ場合には距離が正しいかを判定する
            if(lb == rb){
            	return states[r] == states[l] + d;
            }else{
            	//所属が異なる場合には代表の所属を統一し、代表の位置を変更する
            	belongs[rb] = lb;
            	states[rb] = states[l] + d - states[r];
            	return true;
            }
        }
    }
	

Measured memory_bytes: 92208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int gcd(int n1, int n2){
  if(n1 % n2 == 0) return n2;
  else return gcd(n2, n1 % n2);
}

int main() {
  int k;
  cin >> k;
  int ans = 0;
  for(int a = 1; a <= k; ++a){
    for(int b = 1; b <= k; ++b){
      for(int c = 1; c <= k; ++c){
        ans += gcd(a, gcd(b,c));
      }
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 3576
N = gets.chomp.to_i
a = N.times.map { |_i| gets.chomp.split(" ").map(&:to_i) }

101.times do |x|
  101.times do |y|
    i, j, k = a.find { |_i, _j, k| k != 0 }
    # print("i:#{i}, j:#{j}, k:#{k}")
    h = (i - x).abs + (j - y).abs + k
    next if h < 1

    isall = a.all? do |x_pos, y_pos, height|
      [h - (x_pos - x).abs - (y_pos - y).abs, 0].max == height
    end
    if isall
      puts [x, y, h].join(' ')
      exit
    end
  end
end

Measured memory_bytes: 3836
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int M = scan.nextInt();
			int []A = new int[M];
			int []B= new int[M];
			for(int i = 0;i<M;i++) {
				A[i] = scan.nextInt();
				B[i] = scan.nextInt();
			}
			
			GM[]map= new GM[N+1];
			for(int i = 1;i<=N;i++) {//1~N
				map[i] = new GM(i);
			}
			
			Map<Integer,ArrayList<Integer>>D= new TreeMap<Integer,ArrayList<Integer>>();
			for(int i = 1;i<=N;i++) {
				ArrayList<Integer> ed = new ArrayList<Integer>();
				D.put(i, ed);
			}
			
			
			
			for(int i = 0;i<M;i++) {
				D.get(A[i]).add(B[i]);
				D.get(B[i]).add(A[i]);
			}
			
			Deque<GM> stack = new ArrayDeque<GM>();
			stack.addFirst(map[1]);
			map[1].search = true;
			
			while(!stack.isEmpty()) {
				GM p = stack.removeLast();
				ArrayList<Integer> sk = D.get(p.num);
				for(Integer t:sk){				
					if(map[t].search==false) {
						stack.addFirst(map[t]);
						map[t].search = true;
						map[t].saisyou = p.num;
					}
				}
			}
			
			
			for(int i = 2;i<=N;i++) {
				if(map[i].saisyou==0) {
					System.out.println("No");
					System.exit(0);
				}
			}
			
			System.out.println("Yes");
			
			for(int i = 2;i<=N;i++) {
				System.out.println(map[i].saisyou);
			}
			
			
			
			
			
			
			
			
			
			
			
			
		}
		
		
	}
	
	static class Edge{//向かう先の点to,と辺の重みwe。
		int to;  
		Edge(int T){
			to = T;	
		}
	}
	
	static class GM{
		boolean search = false;
		int saisyou = 0;
		int num;
		GM(int n){	
			num = n;
		}
	}
		
	
	
	
	
	
	
		

}


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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int r, s, p;

int score(char c){
    int po;
    if(c == 'r') po = p;
    else if(c == 's') po = r;
    else po = s;

    return po;
}

int main(void){

    int n, k;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    vector<string> str(k);

    roop(i, n) str[i%k] += t[i];
    
    int ans = 0;
    roop(i, k){
        bool last = false;
        ans += score(str[i][0]);
        for(int j = 1; str[i][j] != '\0';j++){
            if(str[i][j-1] == str[i][j] && last == false) last = true;
            else {
                ans += score(str[i][j]);
                last = false;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

INF = float('inf')
dp = [INF] * (N+10)
dp[0] = 0

coin6 = [6**n for n in range(1,10) if 6**n <= N]
coin9 = [9**n for n in range(1,10) if 9**n <= N]

for i in range(N+1):
    dp[i] = min(dp[i], dp[i-1]+1)
    for j in coin6:
        if i-j >= 0:
            dp[i]=min(dp[i],dp[i-j]+1)
    for j in coin9:
        if i+j >= 0:
            dp[i]=min(dp[i],dp[i-j]+1)
print(dp[N])

Measured memory_bytes: 45264
#include<bits/stdc++.h>
#define pb push_back
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void ram5564()
{
    int n;
    cin>>n;
    map<string,int>mpp;
    int mx=-1;
    string s[n];
    rep(i,0,n)
    {cin>>s[i];mpp[s[i]]++;}
    for(auto x:mpp)
    {
    	mx=max(x.ss,mx);
    }
    vector<string>v;
    for(auto x:mpp)
    {
    	if(x.ss==mx)
    	{
    		v.pb(x.ff);
    	}
    }
    sort(v.begin(),v.end());
    for(auto x:v)
    {
    	cout<<x<<endl;

    }

}

signed main()
{
		noob
		
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 27120
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
a = list(myinput())

# b = []
c = []
for i in range(n):
    # b.append(i+a[i])
    if i<a[i]:
        pass
    else:
        c.append(i-a[i])
# print(b)
# print(c)

c.sort()
# print(c)

ans = 0
for i in range(n):
    m = i + a[i]
    ans += mycount(c,m)
print(ans)

Measured memory_bytes: 101084
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto NK = readln.split.to!(int[]);
	auto N = NK[0], K = NK[1];
	
	bool[] flag;
	flag.length = N;
	
	foreach (i; 0 .. K) {
	    readln;
	    auto A = readln.split.to!(int[]);
	    foreach (a; A) { flag[a-1] = true; }
	}
	
	int ans;
	foreach (x; flag) {
	    if (!x) ans++;
	}
	writeln(ans);
}



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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end(), greater<int>());
  long long sum = 0;
  for (int i = 0; i < N-1; i++) {
    sum += A.at((i+1)/2);
  }
  cout << sum << endl;
}

Measured memory_bytes: 4024