akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v% MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp& operator += (const Fp& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr Fp& operator -= (const Fp& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr Fp& operator *= (const Fp& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp& operator /= (const Fp& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const Fp& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Fp& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main() {

	int n; cin >> n;
	mint tmp10 = 1;
	mint tmp9 = 1;
	mint tmp8 = 1;
	while (n--) {
		tmp10 *= 10;
		tmp9 *= 9;
		tmp8 *= 8;
	}
	mint ans = tmp10 + tmp8 - tmp9 - tmp9;
	cout << ans << endl;
}

Measured memory_bytes: 3608
#define MOD 1000000007;
#define input ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll long long

#include <bits/stdc++.h>

using namespace std;
const int N = 3e5 + 5;
set<int> st[N+1];
int main() {

    int x;
    cin>>x;
    int i=0;
    ll y=0;
   while(y+i<x)
       y+=i,i++;
   cout<<i;

}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
char s[maxn];
int n;
vector<int> v;
int a[maxn];
typedef long long ll;
ll sum;

void solve() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	s[n + 1] = '<';
	s[0] = '>';
	for (int i = 0; i <= n; ++i) {
		if (s[i] == '>' && s[i + 1] == '<') {
			a[i] = 1;
			v.push_back(i);
		}
	}
	for (auto id : v) {
		for (int i = id - 1; ~i; --i) {
			if (s[i + 1] == '>') {
				a[i] = max(a[i], a[i + 1] + 1);
			}
			else {break;}
		}
		for (int i = id + 1; i <= n; ++i) {
			if (s[i] == '<') {
				a[i] = max(a[i], a[i - 1] + 1);
			}
			else {break;}
		}
	}
	for (int i = 0; i <= n; ++i) {
		sum += a[i] - 1;
		//fprintf(stderr, "%d ", a[i] - 1);
	}
	printf("%lld\n", sum);
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
long long n, a[700001], b[700001], c[700001], ts=0, ans=-1e18;
multiset <long long> t;
int main() {
	cin >> n;
	for(int i=0;i<n*3;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		t.insert(a[i]);
		ts+=a[i];
		if(i!=0)b[i]=b[i-1];
		b[i]+=a[i];
	}
	for(int i=n;i<2*n;i++){
		if(a[i]>*t.begin()){
			ts+=(a[i]-*t.begin());
			t.erase(t.begin());
			t.insert(a[i]);
		}
		b[i]=ts;
	}
	t.clear();
	ts=0;
	for(int i=3*n-1;i>=2*n;i--){
		t.insert(-a[i]);
		ts+=a[i];
		if(i!=3*n-1)c[i]=c[i+1];
		c[i]+=a[i];
	}
	for(int i=2*n-1;i>=0;i--){
		if(-a[i]>*t.begin()){
			ts+=(a[i]+*t.begin());
			t.erase(t.begin());
			t.insert(-a[i]);
		}
		c[i]=ts;
	}
	for(int i=n-1;i<2*n;i++){
		//cout << b[i] << " " << c[i];
		ans=max(ans,b[i]-c[i+1]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using ull = unsigned long long;
using namespace std;

int main()
{
    ull Q, H, S, D, N;
    ull ans;

    cin >> Q >> H >> S >> D >> N;

    ans = (N/2)*min(min(Q*8, H*4), min(S*2, D)) + (N%2)*min(min(Q*4, H*2),S);

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

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

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<int>a(n);
  vector<int>b(m);
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];
  

  //b[m]までの累積和をいったん取る
  ll t =0;
  rep(i,m)t +=b[i];

  
  int j = m;
  int ans =0;
  rep(i,n+1){ //i++されていく(Aの本がふえていく。0スタート。)
    while(j>0 && t>k){
      j--;
      t -=b[j]; //tがkより小さくなるまで，j(mスタート)をディクリメントしながらtからb[j]を引く
    }
    if(t > k) break;//これはjが0になったとき用
    ans = max(ans, i+j);
    if(i == n) break; //i= n+1になると範囲外でめんどくさい
    t += a[i]; //iが0冊からのスタートなので，ここでa[i]を足せばいい。(0冊のときは先にi+jしていい)
    
  }
  cout << ans <<endl;
  return 0;
  
  
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a[200010],n,i,saidai=0,c=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        if(saidai<a[i])
        {
            saidai=a[i];
        }
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==saidai)
        {
            c++;
        }
    }
    if(c>=2)
    {
        for(i=0;i<n;i++)
        {
            {
                cout << saidai << endl;
            }
        }
        return 0;
    }
    for(i=0;i<n;i++)
    {
        if(a[i]!=saidai)
        {
            cout << saidai << endl;
        }
        else
        {
            sort(a,a+n,greater<int>());
            cout << a[1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4380
#include <iostream>

using namespace std;

int s[13];


int main()
{
    s[4] = 1;
    s[6] = 1;
    s[9] = 1;
    s[11] = 1;
    s[0] = 1e6;
    s[2] = 2;

    int x,y;
    cin >> x >> y;
    if(s[x] == s[y]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }



int main() {
	int A, B;
	cin >> A >> B;
	out((A + B) % 24);
	return 0;
}



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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////
ll a,b,c;

int main(){
    cin>>a>>b>>c;
    ll d = max(a,max(b,c));
    ll sum = a+b+c;
    ll ans=0;

    if((3*d-sum)%2==0){
        cout<<(3*d-sum)/2<<endl;
    }else{
        ans+=1;
        d++;
        sum+=2;
        cout<<(3*d-sum)/2+ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
import math  # noqa: F401
from collections import deque  # noqa: F401
from typing import Deque, Dict, List, Optional, Tuple, Union  # noqa: F401


def main(N: int, A: List[int]):
    print(sum([a % 2 == 1 for a in A[::2]]))


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    main(N, A)


Measured memory_bytes: 10216
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#define N 123456
using namespace std;
int n,a[N],maxn;
map<int,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
        mp[a[i]]++;
    }
    for(int i=0;i<n;i++)
		maxn = max(maxn,mp[a[i]]+mp[a[i]-1]+mp[a[i]+1]);
	printf("%d\n",maxn);
    return 0;
}

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

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 long long INF = 1LL<<60;

string s, t;

int dp[3100][3100] = {0};

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

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }

    string ans = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) --i; //(i-1, j) -> (i, j)
        else if (dp[i][j] == dp[i][j-1]) --j; //(i, j-1) -> (i, j)
        else {
            ans = s[i-1] + ans; // (i-1, j-1) -> (i, j)
            --i, --j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 37120
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            var K = Sarray()[0];
            if (S.Distinct().Count() == 1)
            {
                WriteLine(S.Length * K / 2);
                return;
            }
            var ans = 0L;
            var ini = 0L;
            for (var i = 0; i < S.Length; ++i)
            {
                if (S[i] != S[0])
                {
                    ini = i;
                    break;
                }
            }
            if (K == 1)
                ini = 0;
            ans += count(S.Substring((int)ini) + S.Substring(0, (int)ini));
            if (K == 1)
            {
                WriteLine(ans);
                return;
            }
            ans *= K - 1;
            ans += count(S.Substring(0, (int)ini));
            ans += count(S.Substring((int)ini));
            WriteLine(ans);
            //Out.Flush();
        }
        static long count(string S)
        {
            var cnt = 1L;
            var ans = 0L;
            for (var i = 0; i < S.Length - 1; ++i)
            {
                if (S[(int)i] == S[(int)i + 1])
                    ++cnt;
                else
                {
                    ans += cnt / 2;
                    cnt = 1;
                }
            }
            ans += cnt / 2;
            return ans;
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
int main(){
    int m, f, r;
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1) break;

        if(m == -1 || f == -1)printf("F\n");
        else{
            if(m+f > 79)printf("A\n");
            else if(m+f > 64) printf("B\n");
            else if(m+f > 49) printf("C\n");
            else if(m+f > 29) {
                if(r>49)printf("C\n");
                else printf("D\n");
            }else printf("F\n");
        }
    }
return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int i;
    int a,b;
    int k;
    while(scanf("%d%d%d",&a,&b,&k)!=EOF)
    {
        if(k<1 || k>100)
            break;
        if(2*k>b-a+1)
        {
            for(i=a;i<=b;i++)
            {
                printf("%d\n",i);
            }
        }
        else
        {
            for(i=a;i<=a+k-1;i++)
            {
                printf("%d\n",i);
            }
            for(i=b-k+1;i<=b;i++)
            {
                printf("%d\n",i);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

char a[2000][2000];
char b[2000][2000];
void solve() {
	int n, m; cin >> n >> m;
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	rep(i, n) {
		rep(j, m) {
			cin >> b[i][j];
			if (a[i][j] != b[i][j])ans++;
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}




Measured memory_bytes: 11028
n = int(input())
p = list(map(int, input().split()))

cnt=0
#配列の最初と最後は無視する
for i in range(1, n-1):
    p_list = [p[i-1], p[i], p[i+1]]
    if not min(p_list) ==  p_list[1] and not max(p_list) == p_list[1]:
        cnt+=1

print (cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#define MAX_N (22)

int n, q;
int A[MAX_N];

bool solve( int i, int m );

int main()
{
    scanf("%d", &n);

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

    scanf("%d", &q);
    
    for ( int i = 0; i < q; i++ ) {
	int m;
	scanf("%d", &m);
	if ( solve( 0, m ) ) {
	    printf("yes\n");
	}
	else {
	    printf("no\n");
	}
    }

    return 0;
}


bool solve( int i, int m )
{
    if ( i == n ) {
	return ( m == 0 );
    }
    else {
	if ( solve( i + 1, m ) ) return true;
	if ( solve( i + 1, m - A[i] ) ) return true;
    }
    
    return false;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<int> G[1000005];

int len[1000005];

int dfs(int x){
    if(len[x] == -1){
        len[0] = -1;
        return -1;
    }
    if(len[x] > 0){
        ;
    }else if(G[x].size() == 0){
        len[x] = 1;
    }else{
        if(len[x] == -2){
            len[x] = -1;
            return len[x];
        }
        len[x] = -2;
        rep(i,G[x].size()){
            int tmp = dfs(G[x][i]);
            if(tmp == -1){
                len[x] = -1;
                len[0] = -1;
                return -1;
            }
            len[x] = max(len[x], tmp + 1);
            
        }
    }
    return len[x];
}

void solve(){
    rep(i,1000001){
        if(len[i] == 0){
            int tmp = dfs(i);
            if(tmp == -1){
                len[0] = -1;
                break;
            }
        }else if(G[i].size() > 0){
            int loop_flag = 0;
            rep(j,G[i].size()){
                if(len[G[i][j]] >= len[i]){
                    loop_flag = 1;
                    break;
                }
            }
            if(loop_flag == 1){
                len[0] = -1;
                break;
            }
        }
        if(len[i] == -1){
            len[0] = -1;
            break;
        }
    }
}

int main() {
    int n;
    cin >> n;
    int a[n-1];
    srep(i,1,n+1){
        rep(j,n-1){
            cin >> a[j];
        }
        rep(j,n-2){
            int from, to;
            if(i<a[j]){
                from = i * 1000 + a[j];
            }else{
                from = i + a[j] * 1000;
            }
            if(i<a[j+1]){
                to = i * 1000 + a[j+1];
            }else{
                to = i + a[j+1] * 1000;
            }
            G[from].push_back(to);
        }
    }

    solve();
    if(len[0] == -1){
        cout << len[0] << endl;
    }else{
        int ans = 0;
        rep(i,1000001){
            ans = max(ans,len[i]);
        }
        cout << ans << endl;
    }

    return 0;
}
 
 


Measured memory_bytes: 43264
/*  ex4_2
    potter0723sw  */

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

int main(void) {
    double lengtha,lengthb,hour,minute,radian,mid,ans;
    scanf("%lf %lf %lf %lf", &lengtha, &lengthb, &hour, &minute);
    radian = fabs(5.5 * minute - 30 * hour) * M_PI / 180;//5.5は6-0.5で長針の1分6度の動きから短針の1分0.5度の動きの差をとったもの
    mid = pow(lengtha,2)+ pow(lengthb,2) - 2*lengtha*lengthb * cos(radian);//余弦定理
    ans = sqrt(mid);//平方根をとって答え
    printf("%13.10lf\n", ans);//誤差を減らすために小数点以下第10位まで出力
    return 0;
}


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

int main(){
  string S ;
  cin >> S ;
  int count =0 ;
  int s = S.size();
  for(int i =0 ; i<s;i++){
    if(S[i]!=S[s-1-i]) count++;
  }
  
  cout << count/2 << endl;
  
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long takahashi = 1;
		long aoki = 1;
		for(int i = 0; i < n; i++) {
			int t = sc.nextInt();
			int a = sc.nextInt();
			if((takahashi - 1)/t > (aoki - 1)/a) {
				takahashi = ((takahashi - 1)/t + 1)*t;
				aoki = ((takahashi - 1)/t + 1)*a;
			} else {
				takahashi = ((aoki - 1)/a + 1)*t;
				aoki = ((aoki - 1)/a + 1)*a;
			}
		}
		System.out.println(takahashi + aoki);
	}
}

Measured memory_bytes: 13436
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
int p[200002];

int find(int x){
	if(x != p[x]){
		p[x] = find(p[x]);
    	}
    	return p[x];
    }
     
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	p[x]=y;
	return ;
}
int main(){
	int n,m,k,l,x;
	cin >> n >> m;
	for(int i=0;i<200002;i++){
		p[i]=i;
	}
	for(int i=1;i<=n;i++){
		cin >> k;
		for(int j=0;j<k;j++){
			cin >> l;
			union_set(i,l+100000);
		}
	}
	x = find(1);
	for(int i=2;i<=n;i++){
		if(find(i)!=x){
			cout << "NO" <<endl;
			return 0;
		}
	}
	cout << "YES" <<endl;
	return 0;
}

Measured memory_bytes: 1792
<?php
  
$n = trim(fgets(STDIN));

$s = floor(sqrt($n));
$m = $n;
for($i=1; $i<=$s; $i++){
  if ($n%$i == 0){
    $c = max(strlen($i),strlen($n/$i));
    if ($m > $c){
      $m = $c;
    }   
  }
}

echo $m;
?>

Measured memory_bytes: 4728
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    long sum_a;
    foreach (i; 0 .. a.length)
    {
        sum_a += a[i];
    }
    // writeln(sum_a);
    // writeln(cast(double) sum_a / a.length);
    auto tmp = cast(double) sum_a / a.length;
    auto ans = new double[](a.length);
    foreach (i; 0 .. a.length)
    {
        // writeln(abs(a[i] - tmp));
        ans[i] = abs(a[i] - tmp);
    }
    // writeln(ans);
    long ansans;
    auto min_x = double.max;
    foreach (i; 0 .. ans.length)
    {
        if (min_x > ans[i])
        {
            min_x = ans[i];
            ansans = i;
        }
    }
    writeln(ansans);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll x;
    cin>>x;
    ll ans = 1;
    for(ll i=2;i<=1000;i++){
        ll j = 2; 
        while(pow(i,j)<=x){
            ans = max(ans,(ll)pow(i,j));
            //cout<<ans<<endl;
            j++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        for (int i=1;i<s.length();i++){
            String s1 = s.substring(0,i);
            String s2 = s.substring(i);
            int ret= 0;
            boolean[] b1 = new boolean[26];
            boolean[] b2 = new boolean[26];
            for (int j=0;j<s1.length();j++){
                b1[s1.charAt(j)-'a']=true;
            }
            for (int j=0;j<s2.length();j++){
                b2[s2.charAt(j)-'a']=true;
            }
            for (int j=0;j<26;j++){
                if (b1[j]&&b2[j])ret++;
            }
            ans = Math.max(ans,ret);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35684
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int A[][] = new int[n][m];
		int B[] = new int[m];
		int C[] = new int[n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				A[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < m; i++){
			B[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++){
			int work = 0;
			for(int j = 0; j < m; j++){
				work += A[i][j] * B[j];
			}
			C[i] = work;
		}
		
		for(int i = 0; i < n; i++){
			System.out.println(C[i]);
		}
	}
}

Measured memory_bytes: 40432
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N (1<<19)
#define INF 100000000
#define MOD 1000000007
#define MO2 1000000009
#define BAS 1009
#define BA2 1007
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n, t;
int m[1000], l[1000], k[1000];
bool saw[1000];
bool ok[1000][1001];
int cnt[1001];

void solve(){
    rep(i,n) cin >> m[i] >> l[i] >> k[i];
    memset(ok,0,sizeof(ok));
    rep(i,n){
        for(int j = 0; j <= t;){
            for(int u = 0; u <= l[i]; u++){
                ok[i][j] = true;
                j++;
            }
            j += k[i]-1;
        }
    }
    /*
    int ss = 0, ee = n, mid;
    while(ee-ss > 1){
    */
    int mid;
    for(mid = 1; mid <= n; mid++){
        memset(saw,0,sizeof(saw));
        //mid = (ee+ss)/2;
        //cout << "mid" << mid << endl;
        memset(cnt,0,sizeof(cnt));
        cnt[0] = mid;
        for(int u = 0; u <= t; u++){
            if(u != 0) cnt[u] += cnt[u-1];
            rep(i,n){
                if(cnt[u] == 0) break;
                if(saw[i]) continue;
                if(ok[i][u] && u+m[i] <= t){
                    saw[i] = true;
                    cnt[u+m[i]]++;
                    cnt[u]--;
                }
            }
        }
        bool yes = true;
        rep(i,n) if(saw[i] == false) yes = false;
        //if(yes) ee = mid;
        //else ss = mid;
        if(yes) break;
    }
    //cout << ee << endl;
    cout << mid << endl;
}

int main(){
    while(cin >> n >> t){
        if(n == 0 && t == 0) break;
        solve();
    }
}

Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int to, cost; edge(int t, int c) :to(t), cost(c){} };

int main()
{
	//while (cin >> n)
	stringstream ss;
	//ss << "result" << i + 1 << ".txt";
	//FILE* fp_out = freopen(ss.str().c_str(), "w", stdout);

	int h, w, n;
	while (cin >> h >> w >> n && h)
	{
		vector<vector<char>> stage(h, vector<char>(w));
		vector<P> cheese(n + 1);
		rep(i, h) rep(j, w)
		{
			char c; cin >> c;
			stage[i][j] = c;
			if (c == 'S') cheese[0] = P(i, j);
			if (1 <= c - '0' && c - '0' <= 9) cheese[c - '0'] = P(i, j);
		}

		int ans = 0;
		vector<int> dr = { -1, 0, 1, 0 };
		vector<int> dc = { 0, 1, 0, -1 };
		rep(i, n)
		{
			P from = cheese[i], to = cheese[i + 1];
			typedef pair<P, int> PI;
			queue<PI> que;
			vector<vector<bool>> visited(h, vector<bool>(w));
			que.emplace(from, 0);
			while (!que.empty())
			{
				PI pi = que.front(); que.pop();
				P p = pi.first; int len = pi.second;

				if (p == to)
				{
					ans += len;
					break;
				}

				rep(k, 4)
				{
					int nr = dr[k] + p.first, nc = dc[k] + p.second;
					if (nr < 0 || nr >= h || nc < 0 || nc >= w ||
						stage[nr][nc] == 'X' || visited[nr][nc]) continue;

					visited[nr][nc] = true;
					que.emplace(P(nr, nc), len + 1);
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2340
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N, A[212345];
ll sum[212345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &A[i]);

	map<ll, int> m;

	sum[0] = A[0];
	m[0]++;
	ll count = 0;
	rep(i, N) {
		if (i) sum[i] = sum[i - 1] + A[i];
		else sum[i] = A[i];
		count += m[sum[i]];
		m[sum[i]]++;
	}

	printf("%lld\n", count);

	return 0;
}


Measured memory_bytes: 15104
A, B, C = map(int, input().split())
if sum((A, B, C)) % 2 == max(A, B, C) % 2:
  print((max(A, B, C) * 3 - sum((A, B, C))) // 2)
else:
  print(((max(A, B, C) + 1) * 3 - sum((A, B, C))) // 2)


Measured memory_bytes: 3060
R = []
n = int(input())
for i in range(n):
    R.append(int(input()))
maxv = -20000000000
minv = R[0]

for i in range(1, n):
    if R[i] - minv > maxv:
        maxv = R[i] - minv
    if R[i] < minv:
        minv = R[i]

print(maxv)


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

using namespace std; 



  

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



Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T, class F>
T LowerBound(T i0, T i1, F f) {
    while (i0 < i1) {
        T i = (i0 + i1);
        if (i >= 0) {
            i /= 2;
        } else {
            i--;
            i /= 2;
        }
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    int n;
    cin >> n;

    ll k;
    cin >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int p[3] = {};
    for (int i = 0; i < n; i++) {
        if (a[i] < 0) p[0]++;
        if (a[i] <= 0) p[1]++;
    }

    auto x = LowerBound<ll>(-(1LL << 60), 1LL << 60, [&](auto x) {
        ll s = 0;
        int j;
        if (x < 0) {
            j = n - 1;
            for (int i = p[0] - 1; i >= 0; i--) {
                while (j >= 0 && (ll)a[i] * a[j] <= x) j--;
                s += (n - 1) - j;
            }
        } else {
            j = 0;
            for (int i = p[0] - 1; i >= 0; i--) {
                while (j < n && (ll)a[i] * a[j] > x) j++;
                s += n - j;
            }
        }
        for (int i = p[0]; i < p[1]; i++) {
            if (x >= 0) s += n;
        }
        if (x >= 0) {
            j = n - 1;
            for (int i = p[1]; i < n; i++) {
                while (j >= 0 && (ll)a[i] * a[j] > x) j--;
                s += j + 1;
            }
        } else {
            j = 0;
            for (int i = p[1]; i < n; i++) {
                while (j < n && (ll)a[i] * a[j] <= x) j++;
                s += j;
            }
        }
        for (int i = 0; i < n; i++) {
            if ((ll)a[i] * a[i] <= x) s--;
        }
        //cout << x << ' ' << s << endl;
        return s / 2 >= k;
    });

    cout << x << endl;

    //x以下のペアがk個以上存在する最小の

    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

has_zero = False
cnt = 0
for a in A:
    if a < 0:
        cnt += 1
    elif a == 0:
        has_zero = True

A2 = [abs(a) for a in A]
if has_zero or cnt % 2 == 0:
    print(sum(A2))
else:
    print(sum(A2) - min(A2) * 2)


Measured memory_bytes: 14496
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

const int N = 100;
const int INF = 1000000;

int n;
vector<int> adj[N+1];	// 0 is for NIL.
int pair_u[N+1], pair_v[N+1], dist[N+1];

bool bfs() {
	for (int u = 0; u <= n; u++) dist[u] = INF;
	queue<int> q;
	for (int u = 1; u <= n; u++) {
		if (pair_u[u] == 0) {
			dist[u] = 0;
			q.push(u);
		}
	}

	while (!q.empty()) {
		int u = q.front();
		q.pop();

		if (dist[u] < dist[0]) {
			for (auto v : adj[u]) {
				if (dist[pair_v[v]] == INF) {
					dist[pair_v[v]] = dist[u] + 1;
					q.push(pair_v[v]);
				}
			}
		}
	}

	return dist[0] != INF;
}

bool dfs(int u) {
	if (u == 0) return true;

	for (int v : adj[u]) {
		if (dist[pair_v[v]] == dist[u] + 1) {
			if (dfs(pair_v[v])) {
				pair_u[u] = v;
				pair_v[v] = u;
				return true;
			}
		}
	}

	// no augmenting path beginning with u.
	dist[u] = INF;
	return false;
}

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

	cin >> n;
	vector<pair<int, int>> red(n), blue(n);
	for (int i = 0; i < n; i++) cin >> red[i].first >> red[i].second;
	for (int i = 0; i < n; i++) cin >> blue[i].first >> blue[i].second;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (red[i].first < blue[j].first && red[i].second < blue[j].second)
				adj[i+1].push_back(j+1);
		}
	}

	int ans = 0;
	while (bfs()) {
		for (int u = 1; u <= n; u++) {
			if (pair_u[u] == 0 && dfs(u)) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N = input()

ab = []
for _ in range(N):
    a, b = map(int, raw_input().split())
    ab.append([a, b])
ab.sort(key=lambda p:p[1], reverse=True)

cd = []
for _ in range(N):
    c, d = map(int, raw_input().split())
    cd.append([c, d])
cd.sort(key=lambda p:p[0])

res = 0
used = {}
for (c, d) in cd:
    for (a, b) in ab:
        if a < c and b < d and (a, b) not in used:
            used[(a, b)] = True
            res += 1
            break
print res


Measured memory_bytes: 2692
#include<stdio.h>
#include<stdlib.h>
typedef struct 
{
  char mark;
  int number;
}card;

void bubblesort(card*,int);
void selectionsort(card*,card*,int);

int main(){
  int n,i,j,t;
   card detail[36],detail2[36];
  char a;
  

  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    {
    scanf(" %c%c",&detail[i].mark,&a);
    detail[i].number = atoi(&a);
  }

  for(i=0; i<n; i++)
  detail2[i]=detail[i];
  bubblesort(detail,n);
  selectionsort(detail,detail2,n);
  return 0;
}
  

void bubblesort(card a[],int n){
  int i,j;
  card tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j].number<a[j-1].number){
	tmp=a[j];  //swap
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }

  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a[i].mark,a[i].number);
  }

  printf("\n");
  printf("Stable\n");   //bubblesortは安定 
}


void  selectionsort(card a[],card a2[],int n){
  int i,j,minj,count=0;
  card tmp;
  for(i=0; i<=n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a2[j].number<a2[minj].number){
	minj=j;
      }
    }
    tmp=a2[i]; //swap
    a2[i]=a2[minj];
    a2[minj]=tmp;
}
  for(i=0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d",a2[i].mark,a2[i].number);
  }
  printf("\n");

  
  for(i=0;i<n;i++){
    if(a[i].mark != a2[i].mark || a[i].number != a2[i].number){
      printf("Not stable\n");
      count=1;
      break;
    } }

  
  if(count != 1) printf("Stable\n");
  
}

 



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define N 1000
#define oo 0x3fffffff
#define fr(i,n) for(i=0;i<n;i++)

using namespace std;

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

int a[2][N],t[N][N];
int n;

int main(void){
    int i,j,x,y;
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(i=1;i<=2;i++)for(j=1;j<=n;j++)scanf("%d",&x),t[i][j]=max(t[i-1][j],t[i][j-1])+x;
    printf("%d",t[2][n]);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[1000000];
	int n,i,a,flg,J,O,I,j;
	scanf("%s",&s);
	n=strlen(s);
	flg=0; J=0; O=0; I=0; a=0;
	for(i=0;i<n;){
		if(s[i]=='J'){
			for(j=i;j<n;j++){
				if(s[j]=='J'){
				    J++;
				}
				else break;
			}
			i=j;
		}
		if(s[i]=='O'){
			for(j=i;j<n;j++){
				if(s[j]=='O'){
				    O++;
				}
				else break;
			}
			i=j;
		}
		if(s[i]=='I'){
			for(j=i;j<n;j++){
				if(s[j]=='I'){
				    I++;
				}
				else break;
			}
			i=j;
		}
		if(J>=O&&O<=I&&a<O){
			a=O; J=0; O=0; I=0;
		}
		else {
		    J=0; O=0; I=0;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 3652
def main():
	H, W = map(int, input().split())
	STAGE = [input() for _ in range(H)]

	dp = [[0] * W for _ in range(H)]
	dp[0][0] = 1

	MOD = 10 ** 9 + 7

	for y in range(H):
		for x in range(W):
			if y + 1 < H and STAGE[y + 1][x] == ".":
				dp[y + 1][x] += dp[y][x] % MOD
			if x + 1 < W and STAGE[y][x + 1] == ".":
				dp[y][x + 1] += dp[y][x] % MOD

	print(dp[-1][-1] % MOD)

main()


Measured memory_bytes: 53104
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  long long H, N;
  cin >> H >> N;
  vector<long long> A(N);
  for(int i= 0; i<N; i++)
    cin >> A[i];

  long long sum=0;
  for(int i=0; i<N; i++)
    {
      sum += A[i];
    }
 
   if(sum>=H)
     cout << "Yes" << endl;
   else
     cout << "No" << endl;
  

  return 0;
}



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

int main()
{
    int n;
    while(cin >> n){
        int a = n%39;
        if(a==0)
            a=39;
        if(a < 10)
            cout << "3C0" << a << endl;
        else
            cout << "3C" << a << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Map.Entry;
import java.util.*;

import org.w3c.dom.css.Counter;


public class Main {
    public static void main(final String[] args){
        final Scanner s = new Scanner(System.in);
        String one = s.next();
        String two = s.next();
        String twoOne =two.substring(0,two.length() -1);
        if(one.equals(twoOne)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#define reint register int
#define coint const int

using namespace std;

int main(void) {
    int k, x;
    scanf("%d%d", &k, &x);
    for (reint i = x - k + 1; i <= x + k - 1; ++i)
        printf("%d%c", i, " \n"[i == x + k - 1]);
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        //List<int> list = new List<int>();

        string v = Console.ReadLine();
        //string[] vs = v.Split(' ');

        string a = "abcdefghijklmnopqrstuvwxyz";
        string b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        string value = string.Empty;
        for (int i = 0; i < v.Length; i++) {
            string c = v.Substring(i, 1);
            int idx = a.IndexOf(c);
            if (idx >= 0) {
                value += b.Substring(idx, 1);
            }
            else {
                value += c;
            }
        }

        Console.WriteLine(value);

        return 0;
    }
}



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

using namespace std;

int main(void){
    long long A,B,N;
    cin>>A>>B>>N;
    long long result;
    if(N<B) result=floor(A*N/B);
    else {
        if(N%B!=0) result=A-1;
        else result=floor(A*(N-1)/B)-A*floor((N-1)/B);
    }
    cout<<result<<endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    set<ll> start;
    vector<ll> goal;
    for(i = 0;i < m;++i){
        ll a,b;
        cin >> a >> b;
        if(a > b){
            swap(a,b);
        }
        if(a == 1){
            start.insert(b-1);
        }else if(b == n){
            goal.push_back(a-1);
        }
    }
    for(i = 0;i < goal.size();++i){
        if(start.find(goal.at(i)) != start.end()){
            cout << "POSSIBLE" << endl;
            return 0;
        }else{
            continue;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 5748
# 41m AC
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
if n % 2 != 0:
    print(0)
    exit()
ans = 0
i = 10
while i <= n:
    ans += n // i
    i *= 5
print(ans)


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

int main() {
    int N,n1,n2,n3,n4;
    cin >> N;
    n4=N%10;
    n3=(N%100)/10;
    n2=(N%1000)/100;
    n1=(N%10000)/1000;
    /*cout << n1 << n2 << n3 << n4 << endl;*/
    if((n1==n2&&n2==n3) || (n2==n3&&n3==n4))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int Init(bool (*visited)[401], int w, int h)
{
	int i, j;

	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			visited[i][j] = false;
		}
	}
	return 1;
}

int Input(char (*s)[401], int& w, int& h, int (*score)[401])
{
	cin >> h >> w;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> s[i][j];
			score[i][j] = (s[i][j] == '#') ? 1 : 0;
		}
	}

	return 1;
}


int Process(int (*score)[401], bool (*visited)[401], int w, int h, long long &result)
{
	int i, j ,k;
	int curr_x, curr_y;
	int next_x, next_y;
	int move[4][2] = { { 1, 0 },{ 0, 1 },{ -1,0 },{ 0,-1 } };
	vector<int> logging;
	queue<pair<int, int>> q;
	
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (!visited[i][j])
			{
				q.push(pair<int, int>(i, j));
				visited[i][j] = true;

				while (!q.empty())
				{
					curr_y = q.front().first;
					curr_x = q.front().second;
					q.pop();
					logging.push_back(score[curr_y][curr_x]);
					
					
					for (k = 0; k < 4; k++)
					{
						next_y = curr_y + move[k][0];
						next_x = curr_x + move[k][1];

						if (0 <= next_x && next_x < w && 0 <= next_y && next_y < h && !visited[next_y][next_x]
							&& (score[curr_y][curr_x] + score[next_y][next_x] == 1))
						{
							q.push(pair<int, int>(next_y, next_x));
							visited[next_y][next_x] = true;
						}
					}
				}

				result += (count(logging.begin(), logging.end(), 1) * count(logging.begin(), logging.end(), 0));
				logging.clear();
			}
		}
	}
	
	return 1;
}

int main()
{
	int h, w;
	long long result = 0;
	
	char s[401][401];
	int score[401][401];
	bool visited[401][401] = { false, };
	
	Input(s, w, h, score);
	Init(visited, w, h);

	Process(score, visited, w, h, result);
	
	cout << result << endl;

	return 0;
}

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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> A(n+1);

    for(int i = 1; i < n+1; i++){
        std::cin >> A[i];
    }
    for(int i = 1; i < n+1; i++){
        std::cout << "node " << i << ": key = " << A[i] << ", ";
        if(i != 1){
            std::cout << "parent key = " << A[i / 2] << ", "; 
        }
        if(2*i < n+1){
        std::cout << "left key = " << A[2*i] << ", ";
        }
        if(2*i+1 < n+1){
        std::cout << "right key = " << A[2*i+1] << ", ";
        }
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[20];
map<P,ll>M[20][20];
ll rec(int L,int R,int lv,int rv){
	if(L > R) return 0;
	if(M[L][R].find(mp(lv,rv)) != M[L][R].end()) return M[L][R][mp(lv,rv)];
	M[L][R][mp(lv,rv)] = 1e18;
	for(int i=L;i<=R;i++){
		M[L][R][mp(lv,rv)] = min(M[L][R][mp(lv,rv)],a[i]*(lv+rv)+rec(L,i-1,lv,lv+rv)+rec(i+1,R,lv+rv,rv));
	}
	return M[L][R][mp(lv,rv)];
}
int main(){
	cin >> n;
	repn(i,n) cin >> a[i];
	cout << a[1]+a[n]+rec(2,n-1,1,1) << endl;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    int b;
    cin >> a >> b;
    if(a==b)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a%500 == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a<500 && a > b)
    {
        cout << "No" << endl;
        return 0;
    }
    for(int i=0; i<10000; i++)
    {
        a = a-500;
        if(a < 500)
        {
            break;
        }
    }
    if(a <= b)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if(a >= b)
    {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>//sort
#include <vector>
#include <string>
#include <map>//pair
#define rep(i, n) for(long long i = 0; i < n; i++)

using namespace std;

int main(){
  int N;
  bool flag1 = true, flag2 = true;
  //vector<int> A; 
  int A[2000000];
  cin >> N;
  rep(i, N)cin >> A[i];
  sort(A, A + N);
  rep(i, N - 1){
    if(A[i] == A[i + 1]){
      cout << "NO" << endl;
      return 0;
    }
  } 
  cout << "YES" << endl;
  //rep(i, N){
  //  int sum = 0;
  //  rep(j, 1000000000){
  //    if(A[i] == j)sum++;
  //  }
  //  if(sum >= 2){
  //    cout << "NO" << endl;
  //    return 0;
  //  }
  //}
  //cout << "YES" << endl;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int D,N;
   cin>>D>>N;
   int ans=0;
   rep(i,N){
       ans+=pow(100,D);
   }
   if(N==100){
           ans+=pow(100,D);
       }
   cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll a, b, c;
    cin >> a >> b >> c;

    if (c - a - b > 0 && (4 * a * b) < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 40;
static const int MAX_X = 5;
static const int MAX_Y = 7;
static const int MAX_Z = 5;
static const int MOD = 1000000007;

int N, X, Y, Z;
ll memo[MAX_N][1 << (MAX_X + MAX_Y + MAX_Z - 1)];

int main(){
	cin >> N >> X >> Y >> Z;
	fill(memo[0], memo[N], 0);
	for(int i = 1; i <= 10; i++){
		memo[0][1 << (i - 1) & ((1 << (X + Y + Z - 1)) - 1)]++;
	}
	for(int i = 0; i < N - 1; i++){
		for(int j = 0; j < (1 << (X + Y + Z - 1)); j++){
			for(int k = 1; k <= 10; k++){
				if(memo[i][j] == 0) continue;
				int num = j;
				num = num << k;
				num |= (1 << (k - 1));
				if((num & (1 << (X + Y + Z - 1))) && (num & (1 << (Y + Z - 1))) && (num & (1 << (Z - 1)))) continue;
				num &= ((1 << (X + Y + Z - 1)) - 1);
				memo[i + 1][num] += memo[i][j];
				memo[i + 1][num] %= MOD;
			}
		}
	}
	ll cnt = 0;
	for(int i = 0; i < (1 << (X + Y + Z - 1)); i++){
		cnt += memo[N - 1][i];
		cnt %= MOD;
	}
	ll num = 1;
	for(int i = 1; i <= N; i++){
		num *= 10;
		num %= MOD;
	}
	cout << (num - cnt + MOD) % MOD << endl;
	return 0;
}


Measured memory_bytes: 20736