akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

struct speciality
{
	int l; int r;
};
int const MAX = 600005;
long long tree[MAX * 2];
speciality s[MAX];
int n_;

void init(int n) {
	n_ = 1;
	while (n_ <= n) {
		n_ <<= 1;
	}
	for (int i = 1; i <= n_; i++) {
		tree[i] = 0;
	}
}

void query_o(int a, int b, int k, int l, int r, long long x) {
	if (b <= l || r <= a) {
		return;
	}
	else if (a <= l && r <= b) {
		tree[k] += x;
	}
	else {
		query_o(a, b, k * 2, l, (l + r) / 2, x);
		query_o(a, b, k * 2 + 1, (l + r) / 2, r, x);
	}
}

void query(int a, int b, long long x) {
	return query_o(a, b, 1, 0, n_, x);
}

long long get(int p) {
	int t = n_ + p;
	long long ans = tree[t];
	while (t > 1) {
		t /= 2;
		ans += tree[t];
	}
	return ans;
}

bool order_s(speciality x, speciality y) {
	return x.r - x.l < y.r - y.l;
}

int len(speciality x) {
	return x.r - x.l + 1;
}

int main() {
	int n, m;
	cin >> m >> n;
	init(n);
	for (int i = 1; i <= m; i++) {
		int ll, rr;
		cin >> ll >> rr;
		s[i] = { ll,rr };
	}
	sort(s + 1, s + m + 1, order_s);
	s[m + 1] = { 0,1000000 };
	int station = 0;
	for (int i = 1; i <= n; i++) {
		while (len(s[station + 1]) < i) {
			station++;
			speciality now = s[station];
			query(now.l, now.r + 1, 1);
		}
		long long ans = m - station;
		for (int j = i; j <= n; j += i) {
			ans += get(j);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}


int A[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n;scanf("%d",&n);
	REP(i,3*n){
		scanf("%d",&A[i]);
	}
	sort(A,A+3*n);
	ll ans = 0;
	for(int i=n;i<3*n;i+=2) ans+=A[i];
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 1408
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
   
    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1,  x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1    
    print(result)

Measured memory_bytes: 7572
using System.IO;
using System.Linq;
using static System.Console;

    internal class Program
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()){AutoFlush = false};
            SetOut(sw);
            
            var value = ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();

            var gcd = Gcd(value[0], value[1]);
            WriteLine(gcd);

            Out.Flush();
        }

        public static int Gcd(int x, int y)
        {

            if (y > x) return Gcd(y, x);

            while (y!=0)
            {
                var r = x % y;
                x = y;
                y = r;
            }

            return x;
        }
    }


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s;
    cin >> s;
    ll n=s;
    ll d=2;
    ll yb=1000000000;
    ll xa=(s+yb-1)/yb;
    ll ya=xa*yb-s;
    ll xb=1;
    cout << xa << " " << ya << " " << xb << " " << yb << " 0 0" << "\n";

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

#define int long long

inline int fun(int b, int n)
{
    if (n < b)
        return n;
    else
        return (fun(b, n / b) + (n % b));
}

signed main()
{
    // Fast I/O
    std::cin.tie(0);
    std::cout.tie(0);
    std::ios_base::sync_with_stdio(false);

    int n, s;

    std::cin >> n >> s;

    if (n < s)
    {
        std::cout << -1 << '\n';
        return 0;
    }
    if (n == s)
    {
        std::cout << (n + 1);
        return 0;
    }

    int ans = n + 1;
    for (int b = 1; b * b <= n - s; ++b)
        if ((n - s) % b == 0)
        {
            if (fun(b + 1, n) == s)
                ans = std::min(ans, b + 1);
            int ib = (n - s) / b + 1;
            if (fun(ib, n) == s)
                ans = std::min(ans, ib);
        }
    if (ans == n + 1)
        ans = -1;
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
using System;

namespace HowManyDivisors
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int cnt = 0;

			//??\??????
			string[] abc = Console.ReadLine().Split(' ');

			//??´??° a
			int a = int.Parse (abc[0]);
			//??´??° b
			int b = int.Parse (abc[1]);
			//??´??° c
			int c = int.Parse (abc[2]);

			for(int i = a; i <= b; i++){

				//?????????0?????£??????
				if((c % i) == 0){
					cnt++;
				}
			}
			Console.WriteLine(cnt);
		}
	}
}

Measured memory_bytes: 19940
#include<iostream>
int main() {
	using namespace std;
	int len;
	cin >> len;
	int* arr = new int[len];
	for (int i = 0; i < len; i++)
		cin >> arr[i];
	int step = 0;
	for (int i = 0; i < len; i++) {
		for (int j = len - 1; j > i; j--) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j], arr[j - 1]);
				step++;
			}
		}
	}
	for (int i = 0; i < len; i++) {
		if (i)
			cout << " ";
		cout << arr[i];
	}
	cout << endl;
	cout << step<<endl;
	return 0;
}


Measured memory_bytes: 3088
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	Scanner sc = new Scanner(System.in);

    	int X = sc.nextInt();

    	while(IsPrime(X)==false) {
    		X ++;
    	}
    	System.out.println(X);


    }

    private static boolean IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        for (int i = 3; i < num; i+=2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int H, W;
  cin >> H >> W;

  vector<vb> R(H, vb(W));
  vector<vb> B(H, vb(W));

  rep(i, H) {
    string s;
    cin >> s;
    rep(j, W) if (s[j] == '#') {
      R[i][j] = B[i][j] = 1;
    }
  }

  rep(x, W) {
    R[0][x] = 1;
    B[H-1][x] = 1;
  }

  rep(y, 1, H-1) {
    rep(x, W) {
      if (x%2) R[y][x] = 1;
      else B[y][x] = 1;
    }
  }

  rep(y, H) {
    rep(x, W) cout << (R[y][x] ? '#' : '.');
    cout << endl;
  }

  cout << endl;

  rep(y, H) {
    rep(x, W) cout << (B[y][x] ? '#' : '.');
    cout << endl;
  }
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 896
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int n, x;
	while (cin >> n >> x) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];

		vector<int> b = a;
		ll ans = 8e18;
		for (int cnt = 0; cnt < n; cnt++) {
			for (int i = 0; i < n; i++) b[i] = min(b[i], a[(i - cnt + n) % n]);
			ll sum = 0;
			for (int i = 0; i < n; i++) sum += b[i];
			ans = min(ans, sum + cnt * 1LL * x);
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(){

	int a,b,c,d,e,x,y;
	cin >> a >> b >> c >> d >> e;

	x = min( a , b );
	x = min( x , c );

	y = min( d , e );

	cout << x+y-50 << endl;

	return 0;
}


Measured memory_bytes: 3092
N, M = map(int,input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
li = []
cnt = 0
for b, c in sorted(BC, key=lambda x:x[1], reverse=True):
  cnt += b
  for _ in range(b):
    li.append(c)
  if cnt >= N:
    break
for i in range(min(N,cnt)):
  if A[i] < li[i]:
    A[i] = li[i]
print(sum(A))

Measured memory_bytes: 33640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(ll i=0;i<n;i++)
#define bf(i,n)    for(ll i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < ll ,ll ,ll > > ;
// #define vector< ll ,ll > pv;
// vector< pair <ll,ll> > vect;


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

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

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

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

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

// ll n;cin>>n;ll a[n];for(ll i=0;i<n;i++)cin>>a[i];    
// for(ll i=0;i<n;i++)cout<<a[i];
// ll a,b;cin>>a>>b;   

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

// vector< tuple < ll ,ll ,ll > > tv;
// vector< ll ,ll > pv;


//----------------------------------------------------------------------------
const ll N=1e5+3;
ll a[N];
int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll tt=1;
   // cin>>tt;
	while(tt--)
	{
	  ll n;
	  cin>>n;
	
	  ll sum=0;
	  f(i,n)
	  {
	      ll tp;
	      cin>>tp;
	      sum+=tp;
	     // tp;
	      a[tp]++;
	  }
	  ll q;
	  cin>>q;
	  while(q--)
	  {
	      ll a1,b1;
	      cin>>a1>>b1;
	    
	     ll z= a[a1];
	      a[b1]+=a[a1];
	      a[a1]=0;
	   
	      sum+=((b1-a1)*z);
	      cout<<sum<<bn;
	  }
	  
	  
	}
	
	return 0;
}


Measured memory_bytes: 4420
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define GRAYCODE(i) ((i) ^ ((i) >> 1))

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



ll merge(VI &A, int lt, int mid, int rt){//[lt, mid[, [mid, rt[
    int nl = mid - lt;
    int nr = rt - mid;
    ll cnt = 0;
    VI L(nl+1), R(nr+1);
    REP(i, nl) L[i] = A[lt + i];
    REP(i, nr) R[i] = A[mid + i];
    L[nl] = R[nr] = 2 * INF;
    int i = 0, j = 0;
    FOR(k, lt, rt){
        if(L[i] <= R[j]) A[k] = L[i++];
        else{
            A[k] = R[j++];
            cnt += nl - i; //A[k]が割り込んだ数
        }
    }
    return cnt;
}

ll mergeSort(VI &A, int lt, int rt){
    if(lt+1 < rt){
        int mid = (lt + rt) / 2;
        ll v1 = mergeSort(A, lt, mid);
        ll v2 = mergeSort(A, mid, rt);
        ll v3 = merge(A, lt, mid, rt);
        return v1 + v2 + v3;
    }
    else return 0;
}
int main(){
    int n; cin >> n;
    VI S(n);
    REP(i, n) cin >> S[i];
    ll ans = mergeSort(S, 0, n);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4336
"use strict";
function main(input) {
    const line = input.split("\n");
    const N = parseInt(line[0]);
    const S = line[1];
    console.log(!(N % 2) ? S.slice(0, N / 2) == S.slice(N / 2) ? "Yes" : "No" : "No");
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29608
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define cin fin
#define cout fout
#endif
using namespace std;
ifstream fin("in.txt");
ofstream fout("out.txt");
long long  n,m;
const double pi=acos(-1);
int a[200005];
const int mod=1e9+7;
int main(){
	cin>>n>>m;
	long long ans=0;
	for(long long int i=m;i<=n+1;i++){
		ans=(ans+(2*n-i+1)*i/2-i*(i-1)/2+1)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
 
vector< ll> divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
 
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    rep(i,n){//i+1について〜
        if(i%2==0 && divisor(i+1).size()==8) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0; lli sum = 0ll;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a)
		cin >> i;
	for (int i = 1; i < n; ++i)
	{
		if (a[i] >= a[i - 1])
			continue;
		sum += (a[i - 1] - a[i]);
		a[i] = a[i - 1];
	}
	cout << sum << endl;
}

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

#define fi first
#define se second
typedef long long ll;

const int len = 1e5+5, inf = 1e9+5;
int l[len], r[len], sz[len];
priority_queue<ll> pq1;
priority_queue<ll, vector<ll>, greater<ll> > pq2;

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d %d", &l[i], &r[i]);
        sz[i] = r[i]-l[i];
    }

    pq1.push(-inf), pq2.push(+inf);
    ll k1 = 0, k2 = 0, ans = 0, opt;
    for (int i = 1; i <= n; i++){
        k1 -= sz[i], k2 += sz[i-1];
        ll a = pq1.top() + k1, b = pq2.top() + k2;

        if (l[i] < a){
            pq1.pop();
            pq2.push(a-k2);

            pq1.push(l[i]-k1);
            pq1.push(l[i]-k1);

            opt = pq2.top() + k2;
        }
        else if (b < l[i]){
            pq2.pop();
            pq1.push(b-k1);

            pq2.push(l[i]-k2);
            pq2.push(l[i]-k2);

            opt = pq1.top() + k1;
        }
        else{
            pq1.push(l[i]-k1);

            pq2.push(l[i]-k2);

            opt = pq1.top() + k1;
        }

        ans += abs(l[i] - opt);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
int a,b;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>a>>b;
	for(int i=1;i<=1000000;i++){
		if(i*8/100==a&&i*10/100==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
/* 
   AOJ 2424
   Kakezan
   2015/7/24
*/
/* 
!!!!!!!!!!!!!!!!!!!!!fuckin implementation about detect infinite loop!!!!!!!!!!!!!!!!!
 */
#include<stdio.h>
#define N_MAX 1000000
#define D_NUM 6

int powered_ten(int n)
{
  int i, powered = 1;
  for(i = 0; i < n; i++)
    {
      powered = powered * 10;
    }
  return powered;
}

int decompose(int num)
{
  int i, quotient = 0, remainder = 0, powered = 0, max = -1;

  for(i = 6; i >= 1; i--)
    {
      powered = powered_ten(i);
      quotient = num / powered;
      remainder = num % powered;
      if(max < quotient * remainder)
	{
	  max = quotient * remainder;
	}
    }
  return max;
}


int ans_f(int num)
{
  int decomposed_nums[D_NUM], max = 0, cnt = 0;
  while(1)
    {
      if(num / 10 == 0)
	{
	  break;
	}
      num = decompose(num);
      if(cnt > N_MAX)
	{
	  return -1;
	}
      cnt++;
    }
  return cnt;
}


int main(void)
{
  int n[100], q, i, ans;
  
  scanf("%d", &q);

  for(i = 0; i < q; i++)
    {
      scanf("%d", &n[i]);
      ans = ans_f(n[i]);
      printf("%d\n", ans);
    }

  return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;

const int MOD0 = 1e9 + 7;
const int MOD1 = 1e9 + 9;

ll INF = LLONG_MAX / 10;

ll pow_mod(ll x, ll n, int M) {
	ll ans = 1;
	for (; n; n>>=1) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
	}
	return ans;
}

int inv_mod(int x, int p) {
	return pow_mod(x, p - 2, p);
}

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int x = 250000; ll h0 = 0, h1 = 0;
	vector<int> X(N + 1); X[0] = x;
	vector<ll> H0(N + 1); H0[0] = h0;
	vector<ll> H1(N + 1); H1[0] = h1;
	rep(i, N) {
		char c = s[i];
		if (c == '+') h0 = (h0 + pow_mod(345678, x, MOD0)) % MOD0;
		if (c == '-') h0 = (h0 - pow_mod(345678, x, MOD0) + MOD0) % MOD0;
		if (c == '+') h1 = (h1 + pow_mod(345678, x, MOD1)) % MOD1;
		if (c == '-') h1 = (h1 - pow_mod(345678, x, MOD1) + MOD1) % MOD1;
		if (c == '>') x++;
		if (c == '<') x--;
		X[i + 1] = x, H0[i + 1] = h0, H1[i + 1] = h1;
	}
	map<ll_ll, int> mp;
	ll ans = 0;
	for (int i = N; i >= 0; i--) {
		int dx = X[i] - X[0];
		ll coef0, coef1;
		if (dx >= 0) coef0 = pow_mod(345678, dx, MOD0);
		else coef0 = inv_mod(pow_mod(345678, -dx, MOD0), MOD0);
		if (dx >= 0) coef1 = pow_mod(345678, dx, MOD1);
		else coef1 = inv_mod(pow_mod(345678, -dx, MOD1), MOD1);
		ll target0 = (H0[i] + H0[N] * coef0) % MOD0;
		ll target1 = (H1[i] + H1[N] * coef1) % MOD1;
		ans += mp[{target0, target1}];
		mp[{H0[i], H1[i]}]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 36612
import java.util.Scanner;

public class Main {
    public int sortNum = 0;

    public static void main(String[] args) {
        Main main = new Main();
        main.start();
    }

    public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    }
}


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

def g(n):
  return ((n**2)+n)//2

goukei = 0
half = N//2
for i in range(1,half+1):
  goukei += i*g(N//i)

add = list(range(half+1,N+1))
goukei += sum(add)
print(goukei)

Measured memory_bytes: 206868
# 077_a
C1=input()
C2=input()
# (1<=i and i<=2) and (1<=j and j<=3):

if C1==(C2[2]+C2[1]+C2[0])and C2==(C1[2]+C1[1]+C1[0]):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "RESORT"
#define pll pair<int, int>
#define fi first
#define se second
using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;
const int N = 1000005;
ll n, m, a[N], k, tong, t, d[N];
ll ans;
void dfs(int i, int j, ll tong)
{
    ans = max(ans, tong + d[(i-1) * m + j]);
    if(i > 1 && a[(i-2)*m+j] > a[(i-1)*m+j])
        dfs(i-1, j, tong + d[(i-1) * m + j]);
    if(j > 1 && a[(i-1)*m+j-1] > a[(i-1)*m+j])
        dfs(i, j-1, tong + d[(i-1) * m + j]);
    if(i < n && a[(i)*m+j] > a[(i-1)*m+j])
        dfs(i+1, j, tong + d[(i-1) * m + j]);
    if(j < m && a[(i-1)*m+j+1] > a[(i-1)*m+j])
        dfs(i, j+1, tong + d[(i-1) * m + j]);
}
inline void sol()
{
	cin >> n >> m;
	cout << m * n;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
	sol();
}










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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

string S;

int main()
{
    cin >> S;
    REP(i, S.length() - 8) {
        printf("%c", S[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

bool sosu(int num){
    if(num < 2){
        return false;
    }else if(num == 2){
        return true;
    }else if(num % 2 == 0){
        return false;
    }

    for(int i = 3; i <= sqrt(num); i+=2){
        if(num % i == 0){
            return false;
        }
    }

    return true;
}

int main(){
    int x;
    cin >> x;
    int y = 100000;
    for(int i = x; i < y; i++){
        if(sosu(i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << 100003 << endl;
    return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
    cin >> S;

    int ans = 0, count = 0;
    rep(i, S.size()){
        if(S[i] != 'A' && S[i] != 'G' && S[i] != 'C' && S[i] != 'T'){
            if(count != 0){
                ans = max(ans, count);
                count = 0;
            }
        }else{
            count++;
        }
    }

    cout << max(ans, count) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

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

	int a, b, x, y;
	cin >> a >> b >> x >> y;

	int rx = x - a;
	int ry = y - b;

	cout << x - (y - b) << " " << y + x - a << " " << a - y + b << " " << b - a + x << endl;

	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    scanf("%d%d", &a, &b);
    string u;
    cin >> u;
    if(u==s)
        a--;
    else
        b--;
    printf("%d %d\n", a, b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;
int main()
{
    int n, k, ans = 0; cin >> n >> k;
    for( int i = 1; i <= n; ++ i )
    {
        int t; cin >> t;
        if( t >= k ) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,X,T,a=1,b=0,c=0;
	scanf("%d %d %d",&N,&X,&T);
	while(1){
		c=X*a;
		b=T*a;
		a++;
		if(c>=N){
			break;
		}
	}
	printf("%d",b);
	return 0;
}


Measured memory_bytes: 1688
#include <stdio.h>
int main() {
    int data[5];
    int x,i, sum=0;
    for(i=0; i<5; i++){
        scanf("%d", &data[i]);
        if(data[i]<40){
            data[i]=40;
        }
        sum += data[i];
        x = sum/5;
    }
    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  ll ans = 0;
  int l = 0, r = 0, res = 0;
  while (r < n) {
    int x = res + a[r], y = res ^ a[r];
    if (x == y) {
      res += a[r++];
      ans += r - l;
    }
    else res -= a[l++];
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <iomanip>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i, v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL << 60;
const int INF = 1e9;
const long long MOD = 1000000007;
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;
}
typedef long long ll;
#define pint pair<int, int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

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

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(RALL(v));
    ll ans = 0;
    rep(i, n)
    {
        if (k == 0)
            ans += v[i];
        else
            k--;
    }
    cout << ans << endl;
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int cnt = 0;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        int day = 1;
        int c = 0;
        while( day <= d ) {
            day += a;
            ++c;

        }
        cnt += c;

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



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   string s;
   cin>>s;
   sort(s.begin(),s.end());
   
   string t;
   cin>>t;
   sort(t.begin(),t.end());
   reverse(t.begin(),t.end());
   
   if(s<t) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;
int N, S;
int main()
{
  while (cin >> N && N > 0){
    if (N<3 || N>100)
      exit (1);
    int sum = 0;
    int largest = 0;
    int smallest =1000;
    for (int i=0; i<N; ++i){
      cin >> S;
      if (S<0 || S>1000)
        exit (2);
      sum += S;
      if (largest < S)
        largest=S;
      if (smallest > S)
      smallest=S;
    }
    int average = 0;
    average = (sum - largest - smallest) / (N - 2);
    cout << average << endl;
  }
}

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

int Q;
const int N = 100100;
int l[N], r[N];
vector<int> prime(N, 1);
vector<int> a(N, 0);
vector<int> res(N + 1, 0);

int main()
{
  cin >> Q;
  for (int i = 0; i < Q; i++)
  {
    cin >> l[i] >> r[i];
  }

  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i < N; i++)
  {
    if (prime[i] == 0)
    {
      continue;
    }
    for (int j = i*2; j < N; j += i)
    {
      prime[j] = 0;
    }
  }

  for (int i = 0; i < N; i++)
  {
    if (prime[i] && prime[(i + 1) / 2])
    {
      a[i] = 1;
    }
  }

  for (int i = 0; i < N; i++)
  {
    res[i + 1] = res[i] + a[i];
  }

  for (int i = 0; i < Q; i++)
  {
    cout << res[r[i] + 1] - res[l[i]] << endl;
  }

  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, c, k;
	cin >> n >> c >> k;

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

	int t = a[0];
	int ans = 1;
	int c_ = 1;
	for (int i = 1; i < n; i++) {
		if (t + k >= a[i]) {
			if (c_ == c) {
				c_ = 1;
				t = a[i];
				ans++;
			} else {
				c_++;
			}
		} else {
			t = a[i];
			ans++;
			c_ = 1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
while True:
	nums = list(map(int, input().split(" ")))
	h = nums[0]
	w = nums[1]
	if h == 0 and w == 0:
		break

	for i in range(h):
		for j in range(w):
			if i == 0 or i == h-1 or j == 0 or j == w-1:
				print("#", end="")
			else:
				print(".", end="")
		print("")
	
	print("")


Measured memory_bytes: 7008
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            //与えられた複数行の英文に含まれる、各アルファベットの数を数えるプログラム

            string[] alp = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
            int[] count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            string str;
            //アルファベット26文字をalp[i]に格納
            //アルファベットそれぞれの個数をcount[j]に格納
            //count[j(n)]の値はalp[i(n)]に対応するものとする。
            while ((str = Console.ReadLine()) != null)
            {
                string input = str.Replace(" ", "").ToLower();          //読み込んだ文字列から空白を取り除き、すべて小文字に変換する
                                                                        //なぜ2段階に分ける必要があるのかわからない


                for (int i = 0; i < 26; i++)                        //alp[]配列と総当たりする。
                {
                    for (int j = 0; j < input.Length; j++)          //count[]配列の何番目に回数を1回加算するか
                    {
                        if (input[j].ToString() == alp[i])          //取得した文字がalp[]配列の文字と一致するとき
                        {
                            count[i]++;                             //アルファベットに対応するcount配列の値を1増やす
                        }
                    }
                }
            }
            for (int i = 0; i < 26; i++)
            {
                Console.WriteLine(alp[i] + " : " + count[i]);
            }
        }
    }
}


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

using namespace std;

template <typename T>
class seg {
	T t;
	using N = typename T::N;
	using F = typename T::F;
	vector<N> nt;
	vector<F> ft;
	void eval(int p, int l, int r) {
		if (ft[p] == t.IF)
			return;
		nt[p] = t.FN(ft[p], r - l, nt[p]);
		if (l + 1 < r) {
			t.FF(ft[p], ft[p + 1]);
			t.FF(ft[p], ft[p + (r - l & -2)]);
		}
		ft[p] = t.IF;
	}
	N init(N n, int p, int l, int r) {
		if (l + 1 == r)
			return nt[p] = n;
		int m = (l + r) / 2;
		return nt[p] = t.NN(init(n, p + 1, l, m), init(n, p + (r - l & -2), m, r));
	}
	N upd(int a, int b, F f, int p, int l, int r) {
		eval(p, l, r);
		if (b <= l || r <= a)
			return nt[p];
		if (a <= l && r <= b)
			return t.FN(ft[p] = f, r - l, nt[p]);
		int m = (l + r) / 2;
		return nt[p] = t.NN(upd(a, b, f, p + 1, l, m), upd(a, b, f, p + (r - l & -2), m, r));
	}
	N get(int a, int b, int p, int l, int r) {
		if (b <= l || r <= a)
			return t.IN;
		eval(p, l, r);
		if (a <= l && r <= b)
			return nt[p];
		int m = (l + r) / 2;
		return t.NN(get(a, b, p + 1, l, m), get(a, b, p + (r - l & -2), m, r));
	}
public:
	const int s;
	seg(int s) :s(s), nt(s * 2 - 1, t.IN), ft(s * 2 - 1, t.IF) {}
	seg(int s, N n) :seg(s) {
		init(n, 0, 0, s);
	}
	void upd(int a, int b, F f) {
		upd(a, b, f, 0, 0, s);
	}
	N get(int a, int b) {
		return get(a, b, 0, 0, s);
	}
};

struct Min {
	typedef int N, F;
	const N IN = 1e9;
	const F IF = 1e9;
	N NN(N m, N n) { return min(m, n); }
	N FN(F f, int, N n) { return min(f, n); }
	void FF(F f, F &g) { g = min(f, g); }
};
int b[222222];
pair<int, int> l[222222];
int main() {
	int n;
	cin >> n;
	int d = n;
	for (int i = 0; i < n; i++)
		scanf("%d", b + i), d -= b[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
		scanf("%d%d", &l[i].first, &l[i].second);
	sort(l, l + q);
	l[q].first = n + 1;
	seg<Min> s(n + 1);
	s.upd(0, 1, d);
	int p = 1;
	for (int i = 0;; i++) {
		for (; p < l[i].first; p++)
			s.upd(p, p + 1, s.get(p - 1, p) + b[p - 1] * 2 - 1);
		if (i == q) break;
		s.upd(l[i].second, l[i].second + 1, s.get(p - 1, l[i].second));
	}
	cout << s.get(n, n + 1) << endl;
	return 0;
}


Measured memory_bytes: 5760
from collections import deque
n, m = [int(x) for x in input().strip().split()]
graph = {}

for i in range(m):
    u, v = [int(x) for x in input().strip().split()]
    if u not in graph:
        graph[u] = []
    if v not in graph:
        graph[v] = []
    graph[u].append(v)
    graph[v].append(u)

dp =  [None for i in range(n+1)]

def bfs(node):
    q = deque([])
    q.append(node)
    dp[node] = node
    while len(q)!=0:
        curr = q.popleft()
        for node in graph[curr]:
            if dp[node] is None:
                dp[node] = curr
                q.append(node)


bfs(1)
# print(dp)
flag = True
for i in range(1,n+1):
    if dp[i] is None:
        flag = False
        break

if flag:
    print("Yes")
    for i in range(2,n+1):
        print(dp[i])
else:
    print("No")


Measured memory_bytes: 107396
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n>>x;
    
    
    
    
    cout<< (n*500>=x?"Yes":"No") <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N,A,B;

void solve(){
	
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N>>A>>B;
	int a[3] = {};
	rep(i, N) {
		int P;
		cin>>P;
		if(P<=A) a[0]++;
		else if(P<=B) a[1]++;
		else a[2]++;
	}
	cout<<min(a[0],min(a[1],a[2]))<<endl;
		solve();
	return 0;
}


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;
typedef vector<int> vi;
typedef vector<vi> wi;

int main(){
  int n;
  string ans="YES";
  cin >> n;
  vi a(200000);
  rep(i, n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  rep(i, n-1){
    if(a[i]==a[i+1]){
      ans="NO";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  int n,k;
  int d=0;
  cin >> n >>k;
    vector<int> v(n,1);
    vector<int> vec(10000);

  for (int i = 0; i < k; i++) {
      cin >> d;
  for (int j = 0; j < d; j++) {
      cin >> vec.at(j);
      v.at(vec.at(j)-1)=0;
  }
  }
  int value_to_remove = 0;
v.erase(std::remove(v.begin(), v.end(), value_to_remove), v.end());
cout << v.size() << endl;
} 

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define maxn 3010
using namespace std;
int x[maxn], y[maxn], f[maxn][maxn], cur[maxn][maxn], val[maxn];
ll inv;
int calc(int a, int k)
{
	int ans = 1;
	while (k)
	{
		if (k % 2) ans = (ll)ans * a % mod;
		a = (ll)a * a % mod;
		k /= 2;
	}
	return ans;
}
int get_cur(int i, int j, int x, int y)
{
	if (i == x && j == y || i == y && j == x) return (inv * f[i][j] + inv * f[j][i]) % mod;
	if (i == x || i == y) return (inv * f[x][j] + inv * f[y][j]) % mod;
	else return (inv * f[i][x] + inv * f[i][y]) % mod;
}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &val[i]);
	for (int i = 1; i <= m; i++)
		scanf("%d%d", &x[i], &y[i]);
	inv = calc(2, mod - 2);
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (i != j) f[i][j] = 1;
	for (int i = m; i >= 1; i--)
	{
		for (int j = 1; j <= n; j++)
		{
			if (j != x[i])
			{
				cur[x[i]][j] = get_cur(x[i], j, x[i], y[i]);
				cur[j][x[i]] = get_cur(j, x[i], x[i], y[i]);
			}
			if (j != y[i])
			{
				cur[y[i]][j] = get_cur(y[i], j, x[i], y[i]);
				cur[j][y[i]] = get_cur(j, y[i], x[i], y[i]);
			}
		}
		for (int j = 1; j <= n; j++)
		{
			if (j != x[i])
			{
				f[x[i]][j] = cur[x[i]][j];
				f[j][x[i]] = cur[j][x[i]];
			}
			if (j != y[i])
			{
				f[y[i]][j] = cur[y[i]][j];
				f[j][y[i]] = cur[j][y[i]];
			}
		}
	}
	int tot = calc(2, m), res = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
		{
			int tmp = f[i][j];
			if (val[i] == val[j]) continue;
			if (val[i] < val[j]) tmp = (mod + 1 - tmp) % mod;
			res = (res + (ll)tmp * tot) % mod;
		}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N;
    vi A, B;
    cin >> N;
    A.resize(N);
    B.resize(N);
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }
    int ans = 0;
    int tmp;
    REP(i, N)
    {
        tmp = A[i] - B[i];
        if (tmp > 0)
            ans += tmp;
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
n=int(input())
p=input().rstrip().split(' ')
S=0;
for i in range(1,len(p)-1):
    a=int(p[i])
    b=int(p[i-1])
    c=int(p[i+1])
    T=min(a,b,c)
    if T==a:
        continue;
    elif T==b:
        B=min(a,c)
        if B==a:
            S+=1;
            continue;
    elif T==c:
        B=min(a,b)
        if B==a:
            S+=1;
            continue;
print(S)


Measured memory_bytes: 3064