akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

static char* mTable[] = {
	"MAR",
	"MAC",
	"MAH",
	"MRC",
	"MRH",
	"MCH",
	"ARC",
	"ARH",
	"ACH",
	"RCH",
	NULL
};
int main(void)
{
	int n, i;
	int count[256] = { 0 };
//	int count0[5];
	unsigned long long patternNum = 0;
	char** ppTable;

	scanf("%d", &n);
	for (i = 0; i < n; ++i){
		char buffer[11];
		scanf("%s", buffer);
		++count[buffer[0]];
	}

	//for (int i = 0; "MARCH"[i] != '\0'; ++i){
	//	count0[i] = count["MARCH"[i]];
	//}

	for (ppTable = mTable; *ppTable != NULL; ++ppTable){
		unsigned long long currPtn = 1;
		for (i = 0; i < 3; ++i){
			char c = (*ppTable)[i];
			currPtn *= count[c];
		}
		patternNum += currPtn;
	}
	printf("%llu\n", patternNum);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
 
int main(){
	int a, i, b;
	unsigned long long int ans = 0;
	scanf("%d", &a);
	for(i = 0; i < a; i++){
		scanf("%d", &b);
		ans += b;
	}
	printf("%lld\n", ans / a);
	return 0;
}

Measured memory_bytes: 592
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    vi a(n), b;
    REP(i, n) cin >> a[i];
    sort(ALL(a), less<int>());
    //REP(i, n) cout << a[i];
    
    int prev = -1;
    REP(i, n-1) {
        if(a[i] == a[i+1]) { // 5>5
            prev = a[i];
            continue;
        } else if(a[i] == prev) { //5>7
            continue;
        }
        prev = a[i];
        b.push_back(a[i]);
    }
    if(a[n-1] != prev) b.push_back(a[n-1]);
    
    auto result = unique(a.begin(), a.end());
    // 不要になった要素を削除
    a.erase(result, a.end());
    
    vector<bool> table(1000001);
    for( int i = 0; i <= 1000001; i++ ) {
        table[ i ] = true;
    }
    vector<int> P;
    for( int i = 0; i < a.size(); i++ ) {
        int x = a[i];
        if( table[ x ] ) {
            for( int j = 2 * x; j <= 1000000; j += x ) table[ j ] = false;
            P.emplace_back( x );
        }
    }
    
    int ans = 0;
    REP(i, b.size()) {
        if(table[b[i]]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int dp[100005];

int main(){

    int n, q; cin >> n >> q;
    string s; cin >> s;
    s = "$" + s;
    for(int i = 1; i < n; i++){
        if(s[i] == 'A' and s[i+1] == 'C')
            dp[i]++;
        dp[i] += dp[i-1];
    }



    while(q--){
        int esq, dir; cin >> esq >> dir;
        cout << dp[dir-1]-dp[esq-1] << endl;
    }

	return 0;
}

Measured memory_bytes: 1404
n = int(input())
l = list("")
for i in range(n):
    a, b = map(int, input().split())
    l.append([a, b])
l.sort(key = lambda x: x[1])
sum = 0
for i in range(n):
    sum += l[i][0]
    if sum > l[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 38028
#include<stdio.h>
int a[200005],b[200005],c[200005]={0},d[200005]={0};
int main()
{
	int n,m,i,k=0,j,t=0,o=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]==1)
			c[b[i]]++;
		if(b[i]==n)
			d[a[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		if(c[i]==1&&d[i]==1)
		{
			printf("POSSIBLE\n");
			return 0;
		}
		
	}
		printf("IMPOSSIBLE\n");
		return 0;
		
}

Measured memory_bytes: 3328
N=int(input())
numca=0
numbc=0
numba=0
ans=0
for i in range(N):
    s=input()
    for j in range(len(s)):
        if j==0 and s[j]=="B":
            numbc+=1
        elif j==len(s)-1 and s[j]=="A":
            numca+=1
        elif j!=len(s)-1 and s[j]=="A" and s[j+1]=="B":
            ans+=1
    if s[0]=="B" and s[-1]=="A":
        numbc-=1
        numca-=1
        numba+=1
if numba==0:
    print(ans+min(numbc,numca))
    quit()
ans+=numba-1
if numbc==0 and numca==0:
    print(ans)
    quit()
if numbc==0 or numca==0:
    print(ans+1)
    quit()
ans+=min(numbc+1,numca+1)
print(ans)


Measured memory_bytes: 53464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int a, b;	cin >> a >> b;	
  	rep(i,3){
      if((i+1) != a && (i+1) != b)
      cout << (i+1) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
ll lucas(int n){
  ll a=2,b=1,c;
  if (n==1) {
    return 2;
    }
  else if (n==2) {
    return 1;
  }
  else{
    rep(i,n-2){
      c=b;
      b=a+b;
      a=c;
  }
  return b;
 }
}
int main(){
  ll n,ans;
  cin>>n;
  ans=lucas(n+1);
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int n;
set<string>q;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		q.insert(s);
	}
	cout<<q.size()<<endl;
	return 0;
}

Measured memory_bytes: 19216
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  int sum=0;
  rep(i,4){
    cin>>n;
    sum+=n;
  }
  cout<<sum/60<<endl;
  cout<<sum%60<<endl;
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
int a,az,b,bz,c,cz;
scanf("%d %d %d",&a,&b,&c);
az=a;
bz=b;
cz=c;
if(a>b)
{
b=a;
a=bz;
bz=b;
az=a;
}
if(a>c)
{
c=a;
a=cz;
cz=c;
az=a;
}
if(b>c)
{
c=b;
b=cz;
cz=c;
bz=b;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll a,b; cin >> a >> b;
    if (a+b < 10) cout << a+b << endl;
    else cout << "error" << endl;
}

Measured memory_bytes: 256
#サンプルが罠ってパターンもあるんだぜ


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

N = int(input())
primes = get_sieve_of_eratosthenes(5000)
ans=[]

inde=0
while len(ans)<N:
    if primes[inde]%5 == 1:
        ans.append(primes[inde])
    inde+=1

print(" ".join(list(map(str,ans))))


Measured memory_bytes: 73516
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a, b;
	int ans = 0;
	cin >> a >> b;
	if (a.size() > b.size()){ ans = 1;  }
	if (a.size() < b.size()){ ans=2; }
	if (a.size()==b.size()){
		for (int i = 0; i < a.size(); i++){
			if (a[i]>b[i]){ ans=1; break; }
			if (a[i] < b[i]) {ans=2; break; }
		}
}
	if (ans == 0){ cout << "EQUAL" << endl; }
    if (ans == 1){ cout << "GREATER" << endl; }
    if (ans ==2){ cout << "LESS" << endl; }
	return 0;
}

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

cnt = 0
for _ in range(100):
    flag = 0
    for i in range(N):
        if A[i] != 0:
            A[i] -= 1
            if flag == 0:
                cnt += 1
                flag = 1
        else:
            flag = 0
            
print(cnt)

Measured memory_bytes: 3060
import math
k = input()
a, b = input().split()
k = int(k)
a = int(a)
b = int(b)
a_k = math.ceil(a / k)
b_k = int(b / k)
if (b_k - a_k) >= 0:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9200
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    ans = 0
    for i in range(l, r+1):
        if i % d == 0:
            ans += 1
    print(ans)
    return





l, r, d = RA()
solve()


Measured memory_bytes: 65008
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100002,M=998244353;
#define mid ((l+r)>>1)
#define For(i,x,y) for(register int i=(int)(x);i<=(int)(y);i++)
#define Rep(i,x,y) for(register int i=(int)(x);i>=(int)(y);i--)
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
int mn[N<<2],n,m,i,x,ans,j,tag[N<<2];
struct node{
	int l,r,c;
	bool operator<(node a)const{return l<a.l;}
}e[N<<2];
void doit(int t,int v){mn[t]=min(mn[t],v),tag[t]=min(tag[t],v);}//??
void down(int t){
	if (tag[t]<1e16){
		doit(t<<1,tag[t]),doit(t<<1|1,tag[t]);
		tag[t]=1e18;
	}
}
void update(int t,int l,int r,int x,int y,int v){
	if (x>y) return;
	if (x<=l && r<=y){
		doit(t,v);
		return;
	}
	down(t);
	if (x<=mid) update(t<<1,l,mid,x,y,v);
	if (mid<y) update(t<<1|1,mid+1,r,x,y,v);
	mn[t]=min(mn[t<<1],mn[t<<1|1]);
}
int query(int t,int l,int r,int x){
	if (l==r) return mn[t];
	down(t);
	if (x<=mid) return query(t<<1,l,mid,x);
	return query(t<<1|1,mid+1,r,x);
}
signed main(){
	scanf("%lld%lld",&n,&m);
	for (i=1;i<=m;i++) scanf("%lld%lld%lld",&e[i].l,&e[i].r,&e[i].c);
	sort(e+1,e+m+1);
	memset(mn,63,sizeof(mn));
	memset(tag,63,sizeof(tag));
	update(1,1,n,1,1,0);
	for (i=j=1;i<=n;i++){
		x=query(1,1,n,i);
		for (;j<=m && e[j].l==i;j++) update(1,1,n,i,e[j].r,x+e[j].c);
//		cout<<x<<endl;
	}
	ans=query(1,1,n,n);
	printf("%lld",ans>1e16?-1:ans);
}

Measured memory_bytes: 11776
from math import gcd
n = int(input())
A = list(map(int, input().split()))
min_A = min(A)
max_A = max(A)

def is_pairwise():
    arr = [0] * (max_A + 1)
    for a in A:
        arr[a] += 1
    max_counter = 0
    for num in range(2, max_A + 1):
        counter = 0
        for i in range(1, 10**6 + 1):
            try:
                counter += arr[num * i]
            except:
                break
        max_counter = max(max_counter, counter)
    if max_counter == 1:
        return True
    else:
        return False

if min_A == 1 and max_A == 1:
    print("pairwise coprime")
elif min_A == 1 and max_A != 1:
    A = [num for num in A if num != 1]
    if is_pairwise():
        print("pairwise coprime")
    else:
        print("setwise coprime")
else:
    if is_pairwise():
        print("pairwise coprime")
    else:
        g = A[0]
        for a in A:
            g = gcd(a, g)
        if g == 1:
            print("setwise coprime")
        else:
            print("not coprime")

Measured memory_bytes: 214040
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for (int i = 0; i < 500; i++) {
        if (i % 2 == 0) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << '\n';
                return 0;
            }
        }
        else {
            a -= d;
            if (a <= 0) {
                cout << "No" << '\n';
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2666;
int n,a[N],len;bool vis[N];ll w[15][15];
bool isgg(int x){
	if(vis[x])return 1;
	rep(i,1,len)if(vis[a[i]+x])return 1;
	return 0;
}

int dot[N];
void getans(int dep, int n, int S, ll cur, ll &m){
	if(dep>n){
		umax(m,cur);
		return;
	}
	rep(i,1,n)if(!(S>>i-1&1)){
		dot[dep]=i;
		getans(dep+1,n,S|(1<<i-1),cur+w[dot[dep-1]][i],m);
	}
}
map<ll,int>Map;
void spj(int dep, int S, ll cur){
	if(dep>n){
		Map[cur]++;assert(Map[cur]<=2);
		return;
	}
	rep(i,1,n)if(!(S>>i-1&1)){
		dot[dep]=i;
		spj(dep+1,S|(1<<i-1),cur+w[dot[dep-1]][i]);
	}
}
int main() {
	n=10;int mx=1;
	while(len<n-1){
		while(isgg(mx))mx++;
		a[++len]=mx;vis[mx]=1;
		rep(i,1,len-1)assert(!vis[a[i]+a[len]]),vis[a[i]+a[len]]=1;
	}
//	rep(i,1,len)printf("%d ",a[i]);puts("");
	read(n);
	rep(i,2,n){
		ll m=0;getans(1,i-1,0,0,m);
		rep(j,1,i-1)w[j][i]=w[i][j]=(m+1)*a[j];
	}
	rep(i,1,n){
		rep(j,1,n)printf("%lld ",w[i][j]);puts("");
	}
//	spj(1,0,0);
	return 0;
}


Measured memory_bytes: 256
n, m =list(map(int, input().split()))
xs = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
xs.sort()
if n == 1:
    print(abs(xs[0]-xs[-1]))
    exit()
a = [abs(xs[i] - xs[i+1]) for i in range(m-1)]
a.sort()
print(sum(a[:-n+1]))

Measured memory_bytes: 13968
N, M = map(int, input().split())
A = []
for i in range(N):
    row = list(map(str,input().split()))
    A.append(list(row[0]))
B = []
for i in range(M):
    row = list(map(str,input().split()))
    B.append(list(row[0]))

for i in range(N-M+1):
    for j in range(N-M+1):
        sub_A = [a[j:j+M] for a in A[i:M+i]]
        if sub_A == B:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

typedef long long ll;
typedef pair<ll,ll> P;

struct edge{ll to, cost;};

vector<vector<edge>> tree;
ll V;

void dijkstra(ll s, vector<int>& d){
	priority_queue<P,vector<P>,greater<P>> q;
	
	d.resize(V+1, INF);
	// cout<<"s = "<<s<<" d.size() "<<d.size()<<endl;
	d[s] = 0;
	q.push(P(0,s));
	
	// cout<<d[0]<<endl;
	
	while(!q.empty()){
		P p = q.top();q.pop();
		ll v = p.second;
		
		// cout<<"v = "<<v<<" d = "<<d[v]<<endl;
		
		if(d[v] < p.first) continue;
		
		for(edge e : tree[v]){
			
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}	
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, Q, K;
	// vector<vector<int>> tree;
	vector<int> d;
	cin>>N;
	
	V = N;
	
	tree.resize(N+2);
	
	for(int i = 1; i < N; i++){
		int a, b, c;
		edge e, e2;
		
		cin>>a>>b>>c;
		
		e.to = b, e.cost = c;
		e2.to = a, e2.cost = c;
		
		tree[a].push_back(e);
		tree[b].push_back(e2);
	}
	
	cin>>Q>>K;
	
	dijkstra(K, d);
	
	// cout<<"d size "<<d.size()<<endl;
	
	for(int i = 0; i < Q; i++){
		int x, y;
		cin>>x>>y;
		
		// cout<<d[x] <<" + "<<d[y]<<endl;
		cout<<d[x] + d[y]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 11120
import numpy as np
a, b, h, m = map(int, input().split())
h_a = ((h % 12) + m / 60)*360 / 12
m_b = ((m % 60)*360/60)%360
angle = min(np.abs(h_a - m_b), 360 - np.abs(h_a - m_b))
print(np.sqrt(a**2 + b**2 - 2*a*b*np.cos(np.radians(angle))))

Measured memory_bytes: 27232
# coding=utf-8

n, m = map(int, input().split())

s = [ list(str(input())) for _ in range(n) ]
add = [[1, 0],[-1, 0],[0, 1],[0, -1]]
ans = 'Yes'
for i in range(n):
    for j in range(m):
        if s[i][j] == '.': continue
        mid = False
        for k in range(4):
            ii = i + add[k][0]
            jj = j + add[k][1]
            if ii >= 0 and jj < m and ii < n and jj >= 0:
                if s[ii][jj] == '#': mid = True
        if not mid: ans = 'No';break
print(ans)


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

int main(){
	int a, b, c;
	int countFive = 0;
	int countSeven = 0;
	cin >> a >> b >> c;
	if (a == 5) countFive++;
	if (a == 7) countSeven++;
	if (b == 5) countFive++;
	if (b== 7) countSeven++;
	if (c == 5) countFive++;
	if (c == 7) countSeven++;
	if (countFive == 2 && countSeven == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC052 C - Factors of Factorial
// 2020.06.13

ll MOD = 1e9+7;

map<ll, ll> PrimeFac(ll n){
  map<ll, ll> mp;
  ll cnt = 0;
  while(n%2 == 0){
    n /= 2;
    cnt++;
  }
  if(cnt != 0) mp[2] = cnt;
  for(ll i = 3; i*i <= n; i += 2){
    cnt = 0;
    while(n%i == 0){
      n /= i;
      cnt++;
    }
    if(cnt != 0) mp[i] = cnt;
  }
  if(n != 1) mp[n] = 1;
  return mp;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  map<ll, ll> res;
  for(ll i = 2; i <= N; i++){
    map<ll, ll> tmp;
    tmp = PrimeFac(i);
    for(auto j : tmp){
      res[j.first] += j.second;
      res[j.first] %= MOD;
    }
  }
  ll ans = 1;
  for(auto i : res){
    ans = (ans*(i.second+1))%MOD;
  }
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct RollingHash {
  static const ll base1 = 1007, base2 = 2009;
  static const ll mod1 = 1000000007, mod2 = 1000000009;
  vector<ll> hash1, hash2, power1, power2;

  // construct
  RollingHash(const string &S) {
    ll n = (ll)S.size();
    hash1.assign(n + 1, 0);
    hash2.assign(n + 1, 0);
    power1.assign(n + 1, 1);
    power2.assign(n + 1, 1);
    for (ll i = 0; i < n; ++i) {
      hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      power1[i + 1] = (power1[i] * base1) % mod1;
      power2[i + 1] = (power2[i] * base2) % mod2;
    }
  }

  // get hash of S[left:right]
  inline P get(ll l, ll r) const {
    long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
    if (res1 < 0) res1 += mod1;
    long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
    if (res2 < 0) res2 += mod2;
    return {res1, res2};
  }

  // get lcp of S[a:] and T[b:]
  inline int getLCP(int a, int b) const {
    int len = min((int)hash1.size() - a, (int)hash1.size() - b);
    int low = 0, high = len;
    while (high - low > 1) {
      int mid = (low + high) >> 1;
      if (get(a, a + mid) != get(b, b + mid))
        high = mid;
      else
        low = mid;
    }
    return low;
  }
};

int main() {
  int N;
  string str;

  cin >> N >> str;

  RollingHash rh(str);

  auto check = [&](ll d) -> bool {
    map<P, ll> mp;
    for (int i = 0; i + d <= N; i++) {
      auto p = rh.get(i, i + d);
      if (mp.count(p)) {
        if (i - mp[p] >= d) return true;
      } else {
        mp[p] = i;
      }
    }
    return false;
  };

  ll left = 0, right = N / 2 + 1;
  while (right - left > 1) {
    ll mid = (right + left) >> 1;
    if (check(mid))
      left = mid;
    else
      right = mid;
  }

  cout << left << endl;

  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T, typename E>
struct SkewHeap{
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using C = function<bool(T,T)>;
  G g;
  H h;
  C c;
  T INF;
  E ei;
  SkewHeap(G g,H h,C c,T INF,E ei):g(g),h(h),c(c),INF(INF),ei(ei){}

  struct Node{
    Node *l,*r;
    T val;
    E add;
    Node(T val,E add):val(val),add(add){l=r=nullptr;}
  };

  void eval(Node *a){
    if(a==nullptr) return;
    if(a->add==ei) return;
    if(a->l) a->l->add=h(a->l->add,a->add);
    if(a->r) a->r->add=h(a->r->add,a->add);
    a->val=g(a->val,a->add);
    a->add=ei;
  }

  T top(Node *a){
    return a!=nullptr?g(a->val,a->add):INF;
  }

  T snd(Node *a){
    eval(a);
    return a!=nullptr?min(top(a->l),top(a->r)):INF;
  }

  Node* add(Node *a,E d){
    if(a!=nullptr) a->add=h(a->add,d);
    return a;
  }

  Node* push(T v){
    return new Node(v,ei);
  }

  Node* meld(Node *a,Node *b){
    if(a==nullptr) return b;
    if(b==nullptr) return a;
    if(c(top(a),top(b))) swap(a,b);
    eval(a);
    a->r=meld(a->r,b);
    swap(a->l,a->r);
    return a;
  }

  Node* pop(Node* a){
    eval(a);
    auto res=meld(a->l,a->r);
    delete a;
    return res;
  }

};

//BEGIN CUT HERE
template<typename T>
T optimalbinarytree(vector<T> ws){
  const T INF = numeric_limits<T>::max()/2;
  using Heap=SkewHeap<T,T>;

  auto g=[](T a,T b){return a+b;};
  auto h=[](T a,T b){return a+b;};
  auto c=[](T a,T b){return a>b;};
  Heap heap(g,h,c,INF,0);

  int n=ws.size();
  vector<typename Heap::Node* > hs(n-1,nullptr);
  vector<int> ls(n),rs(n);
  vector<T> cs(n-1);

  using P = pair<T, int>;
  priority_queue<P,vector<P>,greater<P> > pq;
  for(int i=0;i<n-1;i++){
    ls[i]=i-1;
    rs[i]=i+1;
    cs[i]=ws[i]+ws[i+1];
    pq.emplace(cs[i],i);
  }

  T res=0;
  for(int k=0;k<n-1;k++){
    T c;
    int i;
    do{
      tie(c,i)=pq.top();pq.pop();
    }while(rs[i]<0||cs[i]!=c);

    bool ml=false,mr=false;
    if(ws[i]+heap.top(hs[i])==c){
      hs[i]=heap.pop(hs[i]);
      ml=true;
    }else if(ws[i]+ws[rs[i]]==c){
      ml=mr=true;
    }else if(heap.top(hs[i])+heap.snd(hs[i])==c){
      hs[i]=heap.pop(heap.pop(hs[i]));
    }else{
      hs[i]=heap.pop(hs[i]);
      mr=true;
    }

    res+=c;
    hs[i]=heap.meld(hs[i],heap.push(c));

    if(ml) ws[i]=INF;
    if(mr) ws[rs[i]]=INF;

    if(ml&&i>0){
      int j=ls[i];
      hs[j]=heap.meld(hs[j],hs[i]);
      rs[j]=rs[i];
      rs[i]=-1;
      ls[rs[j]]=j;
      i=j;
    }

    if(mr&&rs[i]+1<n){
      int j=rs[i];
      hs[i]=heap.meld(hs[i],hs[j]);
      rs[i]=rs[j];
      rs[j]=-1;
      ls[rs[i]]=i;
    }

    cs[i]=min({ws[i]+ws[rs[i]],INF,
               min(ws[i],ws[rs[i]])+heap.top(hs[i]),
               heap.top(hs[i])+heap.snd(hs[i])});
    pq.emplace(cs[i],i);
  }
  return res;
}
//END CUT HERE


//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using ll = long long;
  int n;
  cin>>n;
  vector<ll> ws(n);
  for(int i=0;i<n;i++) cin>>ws[i];
  cout<<optimalbinarytree(ws)<<endl;
  return 0;
}

/*
  verified on 2018/02/16
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2415
*/



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

int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  int cnt = 0;
  long long mn = 1LL << 60;
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    if (a[i] < 0) cnt += 1;
    mn = min(mn, abs(a[i]));
    sum += abs(a[i]);
  }
  if (cnt % 2 == 0)
    cout << sum << endl;
  else
    cout << sum - mn * 2 << endl;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define  ll  long long
#define rep(k, n)  for(int i=k; i<n;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
using namespace std;

int main(){
    ll ans=0;
    int n;
    cin >> n;
    rep(1,n+1){
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int ds[10];

int main(void) {
  int a, b;
  cin >> a >> b;
  bool ok = b <= (a+1) / 2;
  puts(ok ? "YES" : "NO");
  return 0;
}


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

int main(){
  int n,count=0,flag=0;
  cin >> n;
  vector<long long> data(n);
  
  for(int i=0; i<n; i++){
    cin >> data.at(i);
    if(data.at(i) < 0){
      data.at(i) *= -1;
      count++;
    }else if(data.at(i) == 0){
      flag=1;
    }
  }
  
  sort(data.begin(), data.end());
  
  long long sum =0;
  for(int i=0; i<n; i++){
    sum += data.at(i);
  }
  
  if((count%2 == 0 )|| (flag==1)){
    cout << sum << endl;
  }else if(count%2 == 1){
    sum -= data.at(0);
    sum -= data.at(0);
    cout << sum << endl;
  }
}

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

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

#define fr first
#define sc second

int main(){
	static int n,k;
	static int a[200010];
	scanf("%d%d",&n,&k);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	
	static int cnt[200010] = {};
	for(int i = 0 ; i < n ; i ++){
		cnt[a[i]] ++;
	}
	static vector<int> vec;
	for(int i = 1 ; i <= n ; i ++){
		vec.push_back(cnt[i]);
	}
	sort(vec.begin(),vec.end());
	
	int ret = 0;
	for(int i = 0 ; i < n-k ; i ++){
		ret += vec[i];
	}
	cout << ret << endl;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll H, W, ans=0, tmp=0;
vector<string> S;
vector<vector<ll>> color;

void bfs(ll h, ll w, ll cl) {
    ll ys[2]={0};
    queue<pair<ll,ll>> Q;
    Q.push(make_pair(h, w));
    color[h][w]=cl;
    while(!Q.empty()) {
        pair<ll,ll> p = Q.front();
        Q.pop();
        if(S[p.first][p.second]=='#') ys[0]++;
        else ys[1]++;
        if(S[p.first][p.second]!=S[p.first-1][p.second]&&S[p.first-1][p.second]!='e'&&color[p.first-1][p.second]!=cl) {
            Q.push(make_pair(p.first-1, p.second));
            color[p.first-1][p.second] = cl;
        }
        if(S[p.first][p.second]!=S[p.first+1][p.second]&&S[p.first+1][p.second]!='e'&&color[p.first+1][p.second]!=cl) {
            Q.push(make_pair(p.first+1, p.second));
            color[p.first+1][p.second] = cl;
        }
        if(S[p.first][p.second]!=S[p.first][p.second-1]&&S[p.first][p.second-1]!='e'&&color[p.first][p.second-1]!=cl) {
            Q.push(make_pair(p.first, p.second-1));
            color[p.first][p.second-1] = cl;
        }
        if(S[p.first][p.second]!=S[p.first][p.second+1]&&S[p.first][p.second+1]!='e'&&color[p.first][p.second+1]!=cl) {
            Q.push(make_pair(p.first, p.second+1));
            color[p.first][p.second+1] = cl;
        }
    }
    ans += ys[0]*ys[1];
}

signed main(){
    cin >> H >> W;
    S.resize(H+2);
    color.resize(H+2);
    for(int i=0;i<H+2;i++) {
        color[i].resize(W+2);
        for(int j=0;j<W+2;j++) {
            color[i][j] = 0;
        }
    }
    string Semp;
    for(int i=0;i<W+2;i++) {
        Semp += "e";
    }
    S[0] = Semp;
    S[H+1] = Semp;
    for(int i=1;i<=H;i++) {
        string stin;
        cin >> stin;
        stin = "e" + stin + "e";
        S[i] = stin;
    }
    ll cl = 1;
    for(int i=1;i<=H;i++) {
        for(int j=1;j<=W;j++) {
            if(color[i][j]==0) {
                bfs(i,j,cl);
                cl++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int swi(char Q){
  switch(Q){
    case 'a':return 1;
    case 'b':return 2;
    case 'c':return 3;
    case 'd':return 4;
    case 'e':return 5;
    case 'f':return 6;
    case 'g':return 7;
    case 'h':return 8;
    case 'i':return 9;
    case 'j':return 10;
    case 'k':return 11;
    case 'l':return 12;
    case 'm':return 13;
    case 'n':return 14;
    case 'o':return 15;
    case 'p':return 16;
    case 'q':return 17;
    case 'r':return 18;
    case 's':return 19;
    case 't':return 20;
    case 'u':return 21;
    case 'v':return 22;
    case 'w':return 23;
    case 'x':return 24;
    case 'y':return 25;
    case 'z':return 26;
  }
}
 
 
char SWI(int x){
  switch(x){
    case 1:return 'a';
    case 2:return 'b';
    case 3:return 'c';
    case 4:return 'd';
    case 5:return 'e';
    case 6:return 'f';
    case 7:return 'g';
    case 8:return 'h';
    case 9:return 'i';
    case 10:return 'j';
    case 11:return 'k';
    case 12:return 'l';
    case 13:return 'm';
    case 14:return 'n';
    case 15:return 'o';
    case 16:return 'p';
    case 17:return 'q';
    case 18:return 'r';
    case 19:return 's';
    case 20:return 't';
    case 21:return 'u';
    case 22:return 'v';
    case 23:return 'w';
    case 24:return 'x';
    case 25:return 'y';
    case 26:return 'z';
  }
}
 
int main(){
  string S; cin >> S;
  vector<int> MY(26,0);
  int k=S.size();
  for(int i=0;i<k;i++){
    MY[swi(S[i])-1]+=i+1;
  }
  if(k!=26){
    for(int i=0;i<26;i++){
      if(MY[i]==0){
        S+=SWI(i+1);
        cout << S << endl;
        return 0;
      }
    }
  }
  int now=0;
  int MAX=0;
  int MIN=27;
  for(int i=25;i>0;i--){
    if(MAX>swi(S[i])){
      for(int j=25;j>i;j--){
        if(MIN>swi(S[j]) && swi(S[j])>swi(S[i])){
          MIN=swi(S[j]);
        }
      }
      S=S.substr(0,i)+SWI(MIN);
      cout << S << endl;
      return 0;
    }
    MAX=swi(S[i]);
  }
  if(S[0]=='z'){
    cout << -1 << endl;
    return 0;
  }
  cout << SWI(swi(S[0])+1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
double eps = 1e-5;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    if(s.size() <= n) cout << s;
    else {
        for (int i = 0; i < n; i++) cout << s[i];
        cout << "..."; 
    }
}

Measured memory_bytes: 3064
n = int(input())
red = [list(map(int, input().split())) for _ in range(n)]
blue = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0])

def beFriend(red, blue):
    if red[0] < blue[0] and red[1] < blue[1]:
        return 1
    else:
        return 0

res = 0

for b in blue:
    for r in sorted([sr for sr in red if sr[0] < b[0]], key=lambda x:x[1], reverse = True):
        if beFriend(r, b):
            res += 1
            red.pop(red.index(r))
            break

print(res)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void change(char *str){
    for(int i=0; str[i]!='\0'; i++){
        str[i]=tolower(str[i]);
    }
}
int main(void){
    
    char text[10000];
    char key[10000];
    char eofstr[]={"END_OF_TEXT"};
    int ans = 0;
    
    scanf("%s",key);
    change(key);
    while(1){
        scanf("%s",text);
        if(strcmp(text,eofstr)==0){
            break;
        }
        change(text);
        if(strcmp(text,key)==0){
            ans++;
        }
    }
    
    printf("%d\n",ans);
    return 0;
    
}



Measured memory_bytes: 1952
#include <stdio.h>

int main(void)
{
  int n, x;
  int min = 1000;
  int m[150];
  int ans;

  scanf("%d %d", &n, &x);

  for (int i=0; i < n; i++) {
    scanf("%d", &m[i]);
    if (min > m[i]) {
      min = m[i];
    }
  }

  for (int i=0; i < n; i++) {
    x -= m[i];
  }

  ans = (x/min) + n;

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

  return 0;
}


Measured memory_bytes: 128
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, Y;
    scan(N, Y);

    long y = Y / 1000;
    foreach (i; 0 .. N + 1)
        foreach (j; 0 .. N - i + 1)
        {
            long k = N - i - j;
            if (0 <= k && 10 * i + 5 * j + k == y)
            {
                writefln("%d %d %d", i, j, k);
                return;
            }
        }
    writeln("-1 -1 -1");
}


Measured memory_bytes: 380
// Problem : A - Calc
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int a;
		cin>>a;
		cout<<(a+a*a+a*a*a);		
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  while (count < s.size()) {
    if (s[count] == s[count + 1]) {
      s.erase(count, 1);
    } else {
      count++;
    }
  }
  cout << s.size() << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int l[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    long ans = 0;
    sort(l, l + n);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += i - (lower_bound(l, l + i, l[j] - l[i] + 1) - l);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	char mozi[1200],count;

	gets(mozi);

	for(count=0;mozi[count]!='\0';count++){
		if(mozi[count]>=97&&mozi[count]<=122){
			mozi[count] -= 32;
			printf("%c",mozi[count]);
		}
		else if(mozi[count]>=65&&mozi[count]<=90){
			mozi[count] += 32;
			printf("%c",mozi[count]);
		}
		else{
			printf("%c",mozi[count]);
		}
	}
	printf("\n");

	

	return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int U[100050];

void init(int n) {
  for (int i = 0; i < n; ++i) {
    U[i] = i;
  }
}

int find(int x) {
  return U[x] == x ? x : U[x] = find(U[x]);
}

void uni(int x, int y) {
  U[find(x)] = find(y);
}

vector<int> A[100050];

int main() {
  int N = in();
  int M = in();
  for (int i = 0; i < N; ++i) {
    int K = in();
    for (int j = 0; j < K; ++j) {
      int L = in() - 1;
      A[L].push_back(i);
    }
  }

  init(N);
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j + 1 < A[i].size(); ++j) {
      uni(A[i][j], A[i][j + 1]);
    }
  }

  bool ok = true;
  for (int i = 0; i < N; ++i) {
    ok &= find(i) == find(0);
  }

  puts(ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 5372
#if 0
date +%Y.%m.%d

题解先咕着。
        ▁▃▄▄▄▃▃▃▃▄▶
      ▗▇▀▔    ▔▔▔▔
     ▄▛   ▃▅━━■▄▂
    ▟▊   ▐▘     ▀▙
   ▟▜▌   ▐▖   ▋  ▐▍
  ▟▘ ▜   ▝▀▇▆●▘  ▐▌
▗▟▘   ▜▃       ▁▅▛
▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔   CopyRight :)
      ▔▔▔▔▔▔
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
} read;

const int maxn = 505;
int val[maxn][maxn];
int dis[maxn][maxn];

void update (int x, int y, int d) {
	d += val[x][y];
	if (d >= dis[x][y]) return;
	dis[x][y] = d;
	update(x - 1, y, d);
	update(x + 1, y, d);
	update(x, y - 1, d);
	update(x, y + 1, d);
}

int main () {
	int n = read;

	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++) {
			val[i][j] = 1;
			dis[i][j] = std::min({i, j, n - i + 1, n - j + 1});
		}

	int ans = 0;
	for (int i = 1; i <= n * n; i ++) {
		int p = read;
		int x = (p - 1) / n + 1, y = (p - 1) % n + 1;
		val[x][y] = 0;
		update(x, y, dis[x][y] - 1);
		ans += dis[x][y];
	}

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


Measured memory_bytes: 22600
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string n_ary_convert(long n, long ary){
    if(n == 0) return "0";
    string ans = "";
    while(n != 0){
        if(n < 0){
            long temp = -n % ary;
            ans += to_string(temp);
            n = n / ary;
            if(temp == 0) continue;
            if(ary < 0) n++;
            else n--; 
        }
        else{
            ans += to_string(n % ary);
            n /= ary;
        }
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int main(){
    int N;
    cin >> N;
    cout << n_ary_convert(N, -2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry;
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  int cnt = n;
  UnionFind tree(n);
  int x, y, z;
  REP(i, m) {
    cin >> x >> y >> z;
    if (cnt != 0 && !tree.same(x - 1, y - 1)) {
      cnt--;
      tree.unite(x - 1, y - 1);
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

// using
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long long ull;

// assert
template <typename T>
void assert_between(T val, T min, T max)
{
    assert(min <= val && val <= max);
}

// math
// 最大公約数(Gratest Common Divisor)を求める.
template <typename T>
T gcd(T a, T b)
{
    assert(a > 0 && b > 0);
    T num1 = max(a, b);
    T num2 = min(a, b);
    T mod = num1 % num2;
    return (mod == 0) ? num2 : gcd(num2, mod);
}

// 最小公倍数(Least Common Multiple)を求める.
template <typename T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}

// 奇数の場合: 全ての要素がkで割り切れる必要がある.
int solve_odd(const int n, const int k)
{
    int num = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % k == 0) num++;
    }
    
    return pow(num, 3);
}

// 偶数の場合: 全ての要素がkで割り切れるか､余りがk/2となる必要がある.
int solve_even(const int n, const int k)
{
    int num = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % k == k / 2) num++;
    }

    return pow(num, 3) + solve_odd(n, k);
}

int main ()
{
    int n, k;
    scanf("%d %d", &n, &k);
    assert_between<int>(n, 1, pow(10, 5));
    assert_between<int>(k, 1, n);

    vector<int> P = vector<int>(n, 0);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &P[i]);
        assert(P[i] <= pow(10, 8));
    }

    int dist = INT_MAX;
    for (int i = 0; i + k - 1 < n; i++)
    {
        int p1 = P[i];
        int p2 = P[i + k - 1];

        // 最小距離を更新する(p1で折り返す or p2で折り返すのいずれか).
        dist = min(dist, abs(p1 - p2) + abs(p1));
        dist = min(dist, abs(p1 - p2) + abs(p2));
    }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    int N; cin >> N;
    for (int i = 0; i < 50000; i++)
    {
        if(floor(double(i)*1.08) == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int X, K, D; cin >> X >> K >> D;

  if (X >= 0) {
    int n = max(1LL, X / D);
    n = min(n, K);
    X -= D * n;
    K -= n;
  } else {
    int n = max(1LL, -X / D);
    n = min(n, K);
    X += D * n;
    K -= n;
  }

  int n = K/2;
  K -= 2 * n;

  while (K > 0) {
    if (X >= 0) {
      int n = max(1LL, X / D);
      n = min(n, K);
      X -= D * n;
      K -= n;
    } else {
      int n = max(1LL, -X / D);
      n = min(n, K);
      X += D * n;
      K -= n;
    }
  }
  cout << abs(X) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <set>
using namespace std;
int main()
{
 int i,n;
 set<int> s;
 cin >> n;
 int a[n];
 for(i=0;i<n;i++)
 {
  cin >> a[i];
  s.insert(a[i]);
 }
 if(s.size()<n)
 cout << "NO";
 else
 cout << "YES";
 return 0;
}

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

N = int(input())

a = int(N/1000)
x = N % 1000
b = int(x/100)
x = x % 100
c = int(x/10)
x = x % 10
d = x

if(a == b and b == c):
    print('Yes')
elif(b == c and c == d):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589

signed main() {
    quickie 
    int n, m ;
    cin >> n >> m ;
    int a[n+1],b[n+1] ;
    rep(i, 1, n+1) cin >> a[i] ;
    memset(b, -1, sizeof(b)) ;
    rep(i, 0, m) {
        int x, y ;
        cin >> x >> y ;
        if(a[x] > a[y]) {
            b[y] = 0 ;
            if(b[x] == -1) b[x] = 1 ;
        }
        else if(a[y] > a[x]) {
            b[x] = 0 ;
            if(b[y] == -1) b[y] = 1 ;
        }
        else {
            b[x] = 0, b[y] = 0 ;
        }
    }
    int cnt = 0;
    rep(i, 1, n+1) {
        if(b[i] == 1 || b[i] == -1) cnt++ ;
    }
    cout << cnt << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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

Measured memory_bytes: 5084