akhauriyash/Code-Regression huggingface dataset:
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[200100];
map<int,int> me;
int main()
{
	int n;lint out=0;
	cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,n){
		out+=me[i-a[i]];
		me[i+a[i]]++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 21412
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL modpow(LL a, LL b) {
  LL r = 1;
  while (b) {
    if (b % 2 == 1) r = r * a % kMod;
    a = a * a % kMod;
    b /= 2;
  }
  return r;
}

int main() {
  string S; cin >> S;
  int rc = 0, rq = 0;
  for (char c : S) {
    if      (c == 'C') ++rc;
    else if (c == '?') ++rq;
  }

  LL ans = 0, la = 0, lq = 0;
  for (int i = 0; i < S.size(); ++i) {
    char c = S[i];
    if (c == '?') rq--;

    if (c == 'A') {
      ++la;
    } else if (c == 'B' || c == '?') {
      LL l = (la * modpow(3, lq) + lq * modpow(3, lq-1)) % kMod;
      LL r = (rc * modpow(3, rq) + rq * modpow(3, rq-1)) % kMod;
      ans = (ans + l * r) % kMod;
    } else if (c == 'C') {
      --rc;
    }

    if (c == '?') lq++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
constexpr auto mod = 1000000007;
using namespace std;
int main() {

	vector<int> a(9);
	rep(i, 9) {
		cin >> a[i];
	}

	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, n) {
		cin >> b[i];
	}

	vector<int> c(9);
	rep(i, n) {
		rep(j, 9) {
			if (b[i] == a[j]) {
				c[j] = 1;
				break;
			}
		}
	}

	int f = 0;
	//yoko
	rep(i, 3) {
		if (c[3 * i] == 1 && c[(3 * i + 1)] == 1 && c[(3 * i + 2)] == 1) {
			f = 1;
			break;
		}
	}
	//tate
	if (f != 1) {


		rep(i, 3) {

			if (c[i] == 1 && c[i + 3] == 1 && c[i + 6] == 1) {
				f = 1;
				break;
			}
		}
	}

	//naname
	if (f != 1) {
		if (c[0] == 1 && c[4] == 1 && c[8] == 1) {
			f = 1;
		}
		if (c[2] == 1 && c[4] == 1 && c[6] == 1) {
			f = 1;
		}
	}

	if (f == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 384
nums = input().rstrip().split(" ")
n1 = int(nums[0])
n2 = int(nums[1])
n3 = int(nums[2])
if n1 == n2 and n2 == n3 and n1 == n3:
  print("No")
elif n1 != n2 and n2 != n3 and n1 != n3:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,x,y,z;
    cin>>x>>y>>z;
    if(x==y&&y==z)cout<<"No"<<endl;
    else if(x!=y&&y!=z&&x!=z)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}





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

int main()
{
	int n;
	cin>>n;
	int l;
	cin>>l;
	int a[n+1];
	int mini=0;
	int minn=100000;
	for(int i=1;i<=n;i++)
	{
		a[i]=l+i-1;
		if(fabs(a[i])<minn)
		{
		//	cout<<a[i]<<' '<<i<<endl;
			minn=fabs(a[i]);
			mini=i;
		 } 
	 } 
	 a[mini]=0;
	 int ans=0;
	 for(int i=1;i<=n;i++)
	 {
	 	ans+=a[i];
	 }
	 cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  int N;

  cin >> N;
  int x = INF;
  int ans = 0;
  
  REP(i, 0, N){
    int tmp;
    cin >> tmp;
    ans += tmp;
    if((tmp % 10 ) != 0){
      x = min(x, tmp);
    }
  }

  if(x == INF){
    cout << "0" << endl;
  } else if((ans % 10) == 0){
    cout << ans - x << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for(int i=1; i<=N; i++) {
    string s = to_string(i);
    if(s.size() % 2 == 1) {
      cnt++;
    }
  } 
  cout<<cnt<<endl;
}

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

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

int up(int K, int S) {
    int count = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int target = S - i - j;
            if (0 <= target && target <= K) count++;
        }
    }
    return count;
}

int main(){
    int K, S;
    cin >> K >> S;
    cout << up(K, S) << endl;
}

Measured memory_bytes: 256
N,M,R = [ int(it) for it in input().split() ]
ri = [ int(it) for it in input().split() ]
edge = [ [ int(it) for it in input().split() ]  for i in range(M) ]

li = [ [10000000]*N for i in range(N) ]
for a,b,c in edge:
  li[a-1][b-1]=c
  li[b-1][a-1]=c

for p in range(10000):
  Flag = True
  for i in range(N):
    for j in range(N):
      for k in range(N):
        li_ikj =  li[i][k]+li[k][j]
        if ( li[i][j] > li_ikj ):
          Flag = False
          li[i][j] = li_ikj
  if Flag:
    break

import itertools as ite
ms = 100000000000000000000000000000000000
for route in ite.permutations( ri ):
  s = 0
  for i in range( len(route)-1 ):
    s += li[route[i]-1][route[i+1]-1]
  ms = min(s,ms)
print ( ms ) 
  


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

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    ll N;
    cin >> N;
    a[i] = N - i - 1;
  }
  sort(a.begin(),a.end());
  int mid = (n-1) / 2;
  ll b = a[mid];
  ll ans = 0;
  for(int i = 0; i < n; i++) ans += abs(a[i]-b);
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 4808
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc161/tasks/abc161_d

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

void f(string s, vector<string>& ans, int maxLen)
{
    if(s.size() == 0)
    {
        abort();
    }
    ans.push_back(s);
    if((int)s.size() == maxLen)
    {
        return;
    }
    auto t = (*s.rbegin());
    if(t > '0')
    {
        auto na = s + (char)(t - 1);
        f(na, ans, maxLen);
    }
    f(s + t, ans, maxLen);
    if(t < '9')
    {
        auto na = s + (char)(t + 1);
        f(na, ans, maxLen);
    }
}

int main(int, const char**)
{
    int k;
    cin >> k;

    vector<string> ans;
    rep(i, 9)
    {
        auto a = string(1, '0' + i + 1);
        f(a, ans, 10);
    }

    sort(ans.begin(), ans.end(), [](const auto& a, const auto& b){
        if(a.size() == b.size())
        {
            return a < b;
        }
        return a.size() < b.size();
    });

    if(k <= (int)ans.size())
    {
        cout << ans[k - 1] << endl;
    }
    else
    {
        printf("over, ans.size = %zu, k = %d\n", ans.size(), k);
    }

    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)

struct edge{
    int to, cost;
};

using namespace std;

//ダイクストラで多用する型
typedef pair<long long, int> P;//(その頂点までの距離,頂点)として使う。

vector<edge> G[100000];//頂点iから出る辺の配列G[i]の配列。
long long dist[100000];//特定の頂点から各頂点への距離が格納される。
bool used[100000];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。

void dijkstra(int v){//vは始点。
    //以下のリンクでpriority_queueの使い方を参照
    //http://shirokurostone.hatenablog.com/entry/20110522/1306052844
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, v));
    while(!que.empty()){
        P top = que.top();
        que.pop();
        int u = top.second;
        long long d = top.first;
        //cout << u << ' ' << d << endl;
        if(used[u]) continue;
        dist[u] = d;
        used[u] = true;
        for(int i = 0; i < G[u].size(); i++){
            if(!used[G[u][i].to]){
                que.push(P(d+(long long)G[u][i].cost, G[u][i].to));
                //cout << G[u][i].to << ' ' <<  d+G[u][i].cost << endl;
            }
        }
    }
}

int main(){
  int n;
  cin >> n;
  int a,b,c;
  for(int i = 0; i < n-1; i++){
    cin>>a>>b>>c;
    a--;b--;
    G[a].push_back(edge{b, c});
    G[b].push_back(edge{a, c});
  }
  int q,k;
  cin>>q>>k;
  k--;
  dijkstra(k);
  int x,y;
  long long res;
  REP(i,q){
    cin>>x>>y;
    x--;y--;
    res = (long long)(dist[x]+dist[y]);
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
int modd(int a,int b)
{
  if(a>=b)
    return a-b;
  else
    return b-a;
}
int min(int a,int b)
{
  if(a>=b)
    return b;
  else
    return a;
}
long fun(int* ar,int n,int *lookup)
{
  if(n==0||n==1||n<0)
    return 0;
  if(lookup[n]!=-1)
    return lookup[n];
  int ans1=fun(ar+1,n-1,lookup)+modd(ar[1],ar[0]);
  int ans2=INT_MAX;
  if(n>2)
  {
    ans2=fun(ar+2,n-2,lookup)+modd(ar[2],ar[0]);
  }
  lookup[n]=min(ans1,ans2);
  return lookup[n];
}
int main()
{
  int n;
  cin>>n;
  int ar[n];
  for(int i=0;i<n;i++)
    cin>>ar[i];
  int lookup[n+1];
  for(int i=0;i<=n;i++)
    lookup[i]=-1;
  long ans=fun(ar,n,lookup);
  cout<<ans<<endl;
}

Measured memory_bytes: 5760
N = gets.to_i

def dfs(a, use, &block)
  return if a > N
  yield a if use == 0b111

  [3, 5, 7].each do |i|
    mask = 1 << ((i - 3) / 2)
    dfs(a * 10 + i, use | mask, &block)
  end
end

ans = 0
dfs(0,0) do |a|
  ans += 1
end
puts ans

Measured memory_bytes: 1916
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int N,K;
  scanf("%d%d",&N,&K);
  
  int ketasu = 0;
  for(int i=1; i<100; i++){
    if(N >= power(K,i)){
      ketasu++;
    }else{
      ketasu++;
      break;
    }
  }
  printf("%d",ketasu);
}

int power(int K, int i){
  int sum = 1;
  if(i == 0){
    return 1;
  }else{
    for(int j=1; j<=i; j++){
      sum *= K;
    }
  }
  return sum;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        if(a[i] % 2 && (i + 1) % 2) {
            ++ans;
        }
    }
    cout << ans << endl;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void read ( vi &v )
{
    for ( auto &i : v )
        cin >> i ;

    sort ( all ( v ) ) ;
}

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    vi a ( n ) , b ( n ) , c ( n ) ;

    read ( a ) ;
    read ( b ) ;
    read ( c ) ;

    ll ans = 0 ;

    for ( auto &val : b )
    {
        int opt_indx = -1 ;
        for ( int lo = 0 , hi = n - 1 ; lo <= hi ; )
        {
            int mid = lo + hi >> 1 ;

            if ( val > a[mid] )
                opt_indx = mid , lo = mid + 1 ;

            else hi = mid - 1 ;
        }

        if ( opt_indx == -1 ) C ;

        int len_a = opt_indx + 1 ;

        opt_indx = -1 ;

        for ( int lo = 0 , hi = n - 1 ; lo <= hi ; )
        {
            int mid = lo + hi >> 1 ;

            if ( val < c[mid] )
                opt_indx = mid , hi = mid - 1 ;

            else lo = mid + 1 ;
        }

        if ( opt_indx == -1 ) C ;

        int len_c = n - 1 - ( opt_indx ) + 1 ;

        ans += 1LL * len_a * len_c ;
    }

    cout << ans ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int a[100005],n,cnt,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	cnt=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i]!=a[i-1])
		{
			if(a[i-1]>cnt)
			{
				ans+=cnt;
			}
			else if(a[i-1]<cnt)
			{
				ans+=(cnt-a[i-1]);
			}
			cnt=1;
		}
		else
		{
			cnt++;
		}
	}
	if(a[n]>cnt)
	{
		ans+=cnt;
	}
	else if(a[n]<cnt)
	{
		ans+=(cnt-a[n]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;

class FermatCombination {
 public:
  vector<ll> factrial;
  vector<ll> inverse;
  ll MOD;

  FermatCombination(int size, ll mod) {
    this->factrial = vector<ll>(size + 1);
    this->inverse = vector<ll>(size + 1);
    this->MOD = mod;

    this->factrial[0] = 1;
    this->inverse[0] = 1;

    for (int i = 1; i <= size; i++) {
      factrial[i] = (factrial[i - 1] * i) % MOD;
      inverse[i] = pow(factrial[i], (int)MOD - 2) % MOD;
    }
  }

  ll combine(int n, int k) {
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
  }

  ll pow(ll x, int n) {
    ll ans = 1;
    while (n > 0) {
      if ((n & 1) == 1) {
        ans = ans * x % MOD;
      }
      x = x * x % MOD;
      n >>= 1;
    }
    return ans;
  }
};

int main() {
  ll n, a[2], k;
  cin >> n >> a[0] >> a[1] >> k;
  sort(a, a + 2);

  auto c = new FermatCombination(n, mod);

  ll r = 0;
  for (ll i = 0; i <= n && i * a[1] <= k; i++) {
    ll j = (k - i * a[1]) / a[0];
    if (j <= n && i * a[1] + j * a[0] == k) {
      r = (r + c->combine(n, i) * c->combine(n, j)) % mod;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvll            vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define wh(x)           int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
#define deb(x)          cout <<#x << " is "<<x<<endl;
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}


int main(){
  fio
  i_o();
  int a,b;
  cin>>a>>b;
  d1(a*b);
  return 0;
}


Measured memory_bytes: 3648
n,k = $stdin.gets.split.map(&:to_i)

result = 0
tmp = 1.0

(1..n).each do |i|
  j = 0
  while 2**j * i < k

    tmp = tmp / 2
    j += 1
  end
  result += tmp / n
  tmp = 1.0
end


puts result


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int> > matrix_a(n, std::vector<int>(m));
    std::vector<int> matrix_b(m);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> matrix_a.at(i).at(j);
        }
    }

    for (int i = 0; i < m; i++) {
        std::cin >> matrix_b.at(i);
    }


    for (int i = 0; i < n; i++) {
        int result = 0;
        for (int j = 0; j < m; j++) {
            result += matrix_a.at(i).at(j) * matrix_b.at(j);
        }
        std::cout << result << std::endl;
    }
}


Measured memory_bytes: 3156
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef long double ld;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define ui(n) ((unsigned int)(n))
#define LL(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define ld(n) ((long double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const LL LINF=4557430888798830399;
const ld eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

inline int Read()
{
	int x=0,w=0;char ch=0;while(!isdigit(ch)){w|=ch=='-';ch=getchar();}while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
inline void Write(int x){if(x<0)putchar('-'),x=-x;if(x>9)Write(x/10);putchar(x%10+'0');}
inline LL powmod(LL a,LL b){LL res=1;a%=MOD;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res%MOD;}
inline LL gcdll(LL a,LL b){return b?gcdll(b,a%b):a;}

const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={1,0,-1,0,-1,-1,1,1};
/************************************************************BEGIN************************************************************/
const int maxn=10000010;

LL n,cnt[maxn],ans;

int main()
{
	cin>>n;

	for(int i=1;i<=n;i++) for(int j=i;j<=n;j+=i) cnt[j]++;
	for(int i=1;i<=n;i++) ans+=1ll*i*cnt[i];

	cout<<ans;

	return 0;
}
/*************************************************************END**************************************************************/

Measured memory_bytes: 81688
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,b,aa[110000],cnt=0,a;
pair<int,string> p[220000];
string s,ss[220000];
char c;
signed main(){
    cin>>n;
    rep(i,sqrt(n)){
        if(n%(i+1)==0){
            cnt=i+1;
        }
    }
    cout<<cnt+n/cnt-2;
}

Measured memory_bytes: 5504
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# import itertools
# from operator import attrgetter, itemgetter
# import math

# from numba import jit

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = input()

    if "7" in n:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61900
import sys
fin = sys.stdin.readline


N = int(fin())
p_list = [float(elem) for elem in fin().split()]


dp = [0] * (N + 1)
dp[0] = 1
for i, p in enumerate(p_list, start=1):
    next_dp = [0] * (N + 1)
    next_dp[0] = dp[0] * (1 - p)
    for j in range(1, i):
        next_dp[j] = dp[j - 1] * p + dp[j] * (1 - p)
    next_dp[i] = dp[i - 1] * p
    dp = next_dp


print(sum(dp[N // 2 + 1:]))


Measured memory_bytes: 47836
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 100005;
#define mp(i, j) make_pair(i, j)
#define pii pair<int, int>
#define fir first
#define sec second
using namespace std;

int n, m, head[N], cnte, ans[N]; 
struct edge { int to, nxt; } e[N << 1]; 
priority_queue<pii, vector<pii >, greater<pii > > q; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

inline void adde(int u, int v) { e[++cnte] = (edge) { v, head[u] }, head[u] = cnte; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> (); 
	for(int u, v, i = 1; i < n; i++) u = read <int> (), v = read <int> (), adde(u, v), adde(v, u); 
	for(int i = 1; i <= n; i++) ans[i] = -1; 
	m = read <int> (); 
	for(int id, x, i = 1; i <= m; i++) id = read <int> (), x = read <int> (), ans[id] = x, q.push(mp(x, id)); 
	while(!q.empty())
	{
		int u = q.top().sec; q.pop(); 
		for(int v, i = head[u]; i; i = e[i].nxt)
		{
			v = e[i].to; 
			if(ans[v] != -1)
			{
				if(ans[v] != ans[u] - 1 && ans[v] != ans[u] + 1) { puts("No"); return 0; }
				else continue;
			}
			ans[v] = ans[u] + 1, q.push(mp(ans[v], v)); 
		}
	}
	puts("Yes");
	for(int i = 1; i <= n; i++) printf("%d\n", ans[i]); 
	return 0; 
}


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


int main(){
  int N,K,ans=0;
  int AL[26]={0};
  string P[10000];
  char pre;

  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>P[i];
    // cout<<P[i][0]-'A'<<endl;
    AL[P[i][0]-'A']++;
  }

  while(1){
    sort(AL,AL+26);
    if(AL[25-(K-1)]<=0)break;

    ans++;
    for(int i=0;i<K;i++){
      AL[25-i]--;
    }
  }

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double hd = h * 30 + m * 0.5, d;
    double md = m * 6;
    d = abs(hd - md) * acos(-1) / 180;
    cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2 * a * b * cos(d)) << endl;
}



Measured memory_bytes: 4168
#include<iostream>
#include<string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main(){
  string s;
  cin >> s;
  string ans;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '0'){
      ans.push_back('0');
    }
    else if(s.at(i) == '1'){
      ans.push_back('1');
    }
    else if(s.at(i) == 'B' && ans.size() == 0){
      continue;
    }
    else if(s.at(i) == 'B'){
      ans.pop_back();
    }
  }
  cout << ans << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int sum = 1;
  int count = 0;
  while (true) {
    if(sum >= b) {
      break;
    }
    sum += a-1;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    string s;
    cin >> s;
    if (s == "Sunny"){
        cout << "Cloudy";
    }
    else if(s == "Cloudy") {
        cout << "Rainy";
    }
    else {
        cout << "Sunny";
    }
}

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();
        int right, left;
        right = left = 0;
        ArrayList<Integer> w = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            w.add(num);
            right += num;
        }
        int min = 10000;
        left += w.get(0);
        right -= w.get(0);
        for (int i = 1; i < n; i++) {
            if (min > Math.abs(left - right)) {
                min = Math.abs(left - right);
            }
            left += w.get(i);
            right -= w.get(i);
        }

        System.out.println(min);
        return;
    }


}


Measured memory_bytes: 21460
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto a = readln.split.to!(int[]);
    a.sort();
    writeln(a[0] * a[1] / 2);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define disp(x) cout << #x << " : " << x << endl
using namespace std;
using ll = long long;

const int LEN = 405;
ll dp[LEN][LEN];
bool checked[LEN][LEN];

ll calc_cost(int l, int r, const ll a[]){
    if(checked[l][r]) return dp[l][r];
    checked[l][r] = true;
    if(l == r) return dp[l][r] = 0;
    ll sum = accumulate(a+l, a+r+1, 0LL);
    ll tmp = LLONG_MAX;
    loop(m, l, r) tmp = min<ll>(tmp, calc_cost(l, m, a) + calc_cost(m+1, r, a));

    return dp[l][r] = tmp + sum;
}

int main(){
    memset(dp, 0, sizeof(dp));
    memset(checked, 0, sizeof(checked));
    int n; cin >> n;
    ll a[n+1];
    rep(i, n) cin >> a[i];

    cout << calc_cost(0, n-1, a) << endl;

    return 0;
}

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

using namespace std;

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

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  x *= 2;
  y *= 2;
  int64_t sum = 0;

  if (a + b <= c * 2) {
    sum = (a * x + b * y) / 2;
  } else {
    if (x == y) {
      sum = c * x;
    } else if (x < y) {
      if (c * 2 < b) {
        sum = c * y;
      } else {
        sum = c * x + (b * (y - x) / 2);
      }
    } else {
      if (c * 2 < a) {
        sum = c * x;
      } else {
        sum = c * y + (a * (x - y) / 2);
      }
    }
  }
  cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  n=n%10;
  if(n==3)
    cout<<"bon"<<endl;
  else if(n==1||n==6||n==8||n==0)
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}

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

constexpr int64_t MOD = 1e9 + 7;

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 1;
    for (int64_t i = 1; i <= n; i++) (ans *= i) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
 int ans=700;
      string str=Console.ReadLine();
      for(int i=0;i<3;i++){
        if(str.Substring(i,1)=="o"){
          ans+=100;
        }
      }
      Console.WriteLine(ans);
}
  }

}


Measured memory_bytes: 25660
#include <vector>
#include <iostream>
using namespace std;
int n, m, r, s, a, b; vector<int> p[51], q[51];
int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		cin >> r; p[i].resize(r);
		for(int j = 0; j < r; j++) cin >> p[i][j], p[i][j]--;
	}
	cin >> s;
	for(int i = 0; i < s; i++) {
		cin >> a >> b; a--, b--;
		q[a].push_back(b);
		q[b].push_back(a);
	}
	int ret = 0;
	for(int i = 0; i < m; i++) {
		for(int j = 0; j < p[i].size(); j++) {
			bool flag = false;
			for(int k = 0; k < p[i].size(); k++) {
				if(j != k) {
					for(int l = 0; l < q[p[i][j]].size(); l++) {
						if(q[p[i][j]][l] == p[i][k]) flag = true;
					}
				}
			}
			if(flag) ret++;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define deb(x) cout<<#x<<" "<<x<<endl;
const ll INF = 1e9 + 7;
#define MEM(a,b) memset((a),(b),sizeof(a))

ll happy(ll days , ll act[][4] , ll last , ll cur_day , ll memo[][4])
{
	if(cur_day == days){
		if(last == 1) return max(act[days][2] , act[days][3]);
		else if(last == 2) return max(act[days][1] , act[days][3]);
		else return max(act[days][1] , act[days][2]); //last ==3
	}

	if(memo[cur_day][last] != -1) return memo[cur_day][last];

	ll ans = 0;
	for (ll i = 1; i <= 3; i++) {
		if(i != last) ans = max( ans , act[cur_day][i]+happy(days,act,i,cur_day+1,memo) );
	}

	return memo[cur_day][last] = ans;
}


int main()
{
	fastio;
	ll days;
	cin>>days;
	ll act[days+1][4] = {0};
	for (ll i = 1; i<= days ; i++) {
		cin>>act[i][1]>>act[i][2]>>act[i][3];
	}

	ll memo[days+1][4];
	MEM(memo,-1);
	if(days == 1){
		cout<< max(act[days][1] , max(act[days][2] , act[days][3]) );
	}
	else{
		ll ans = 0;
		for (ll i = 1; i <= 3; i++) {
			ans = max( ans , act[1][i]+happy(days,act,i,2,memo) );
		}

		std::cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 15872
#include<iostream>

using namespace std;

int main(){

    int a[3],c[3],d[3];
    int n;
    int b[100];

    for(int i=0; i<3;i++)cin >> a[i];
    for(int i=0; i<3;i++)cin >> c[i];
    for(int i=0; i<3;i++)cin >> d[i];

    cin >> n;

    for(int i=0; i<n;i++)cin >> b[i]; 

    for(int k=0;k<n;k++){
        for(int i=0;i<3;i++){
            if(b[k] == a[i])
                a[i] = 0;
            
            if(b[k] == c[i])
                c[i] = 0;

            if(b[k] == d[i])
                d[i] = 0;
        }
    }

    if(a[0] == 0 && c[0] == 0 && d[0] == 0) 
        cout << "Yes" << endl;
    else if(a[1] == 0 && c[1] == 0 && d[1] == 0) 
        cout << "Yes" << endl;  
    else if(a[2] == 0 && c[2] == 0 && d[2] == 0)
        cout << "Yes" << endl;
    else if(a[0] == 0 && a[1] == 0 && a[2] == 0) 
        cout << "Yes" << endl;
    else if(c[0] == 0 && c[1] == 0 && c[2] == 0) 
        cout << "Yes" << endl;
    else if(d[0] == 0 && d[1] == 0 && d[2] == 0)  
        cout << "Yes" << endl;    
    else if(a[0] == 0 && c[1] == 0 && d[2] == 0)  
        cout << "Yes" << endl;
    else if(a[2] == 0 && c[1] == 0 && d[0] == 0) 
        cout << "Yes" << endl;
    else 
        cout << "No" <<endl;
    


}

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

int main(){
    ll n, m, t;
    vector<ll> a, b, c;
    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> t;
        a.push_back(t);
    }
    cin >> m;
    for(ll i = 0; i < m; i++){
        cin >> t;
        b.push_back(t);
    }
    set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), back_inserter(c));
    for(auto i = c.begin(); i != c.end(); i++){
        cout << *i << endl;
    }
    return 0;
}



Measured memory_bytes: 10140
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
 
unordered_map<int, int> mp, mp2;
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    int d;
    cin >> d;
    mp[d]++;
  }
  int m;
  cin >> m;
  REP(i, m) {
    int t;
    cin >> t;
    mp2[t]++;
  }
 
  for(auto i: mp2) {
    if(mp[i.first] < i.second) {cout << "NO" << endl; return 0;}
  }
  cout << "YES" << endl;
 
  return 0;
}

Measured memory_bytes: 16712
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    double p;
    cin >> N >> K;
    vector<double> P;
    double ret = 0;
    for (auto i = 0; i < N; i ++) {
        cin >> p;
        double e = (p * (p+1)) / 2;
        P.push_back(e/p);
    }
    double sum = 0;
    for (auto i = 0; i < K; i ++) {
        sum += P[i];
    }
    double max = sum;
    for (auto i = K; i < N; i ++) {
        sum += P[i];
        sum -= P[i-K];
        max = std::max(max, sum);
    }
    printf("%lf\n", max);
    return 0;
}

Measured memory_bytes: 2420
t,*S=*$<;i=1;p~(S.map{d,p,q=0,0,i;(d-=1;p|=r=s=p&q^q;q=0;(q|=S[-t.bit_length].to_i 2;s^=t)while(t=s&-s)>0;0<q&r&&x)while 0<q;i*=2;d}.min rescue 0)

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

int main() {
  int a , b;
  cin >> a >> b;
  int p = a + b;
  int m = a - b;
  int k = a * b;
  
  cout << max(max(p, m), k) << endl;
  return 0;
}

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

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)

const int MAXN = 100 * 1000 + 10;
int a[MAXN];

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	for (int i = 0; i < n; i ++)
		cin >> a[i];
	sort(a, a + n);
	if (a[n - 1] - a[0] > 1)
		kill("No");

	int k = 0;
	while (k < n && a[k] == a[0])
		k ++;

	if (k == n)
	{
		cout << ((a[0] + 1 == n || a[0] <= n / 2) ? "Yes" : "No") << "\n";
		return 0;
	}

	int col = a[0] + 1;
	cout << ((col > k && col - k <= (n - k) / 2) ? "Yes" : "No") << "\n";

	return 0;
}






Measured memory_bytes: 1024
// Aizu Vol-0 0082: Flying Jenny
// 2017.8.4

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

char *gets(char *);
char buf[200], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int h[16] = { 4,1,4,1,2,1,2,1,4,1,4,1,2,1,2,1 };
int d[8] = { 41412121, 14121214, 41212141, 12121414, 21214141, 12141412, 21414121, 14141212 };
char *ans[8] = {
	"4 1 4 1 2 1 2 1", "1 4 1 2 1 2 1 4", "4 1 2 1 2 1 4 1", "1 2 1 2 1 4 1 4",
	"2 1 2 1 4 1 4 1", "1 2 1 4 1 4 1 2", "2 1 4 1 4 1 2 1", "1 4 1 4 1 2 1 2" };

int main()
{
	int i, j, c, id, max, m[8];
	int *hp, *hh;

	while (gets(p = buf) != NULL) {
		for (i = 0; i < 8; i++) m[i] = getInt();
		max = 0, id = 3;
		for (i = 0, hp = h; i < 8; i++, hp++) {
			for (j = 0, c = 0, hh = hp; j < 8; j++, hh++) {
				if (m[j] >= *hh) c += *hh;
				else c += m[j];
			}
			if (max < c) max = c, id = i;
			else if (max == c && d[id] > d[i]) id = i;
		}
		//		printf("max %d, id %d, C %d\n", max, id, d[id]);
		puts(ans[id]);
	}
	return 0;
}

Measured memory_bytes: 520
n = int(input())
a = list(map(int, input().split()))

a = [0] + a
b = [0] * (n+1)

for i in range(n, 0, -1):
    sum = 0
    for j in range(i, n+1, i):
        sum ^= b[j]
    b[i] = sum^a[i]


ans = list()
for i in range(n+1):
    if b[i]: ans.append(i)

print(len(ans))
if len(ans) != 0:
    print(*ans)


Measured memory_bytes: 71132
def isPrime(n):
    if n <= 1:
        return False 
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    i = 3
    while i * i <= n :
        if n % i == 0:
            return False 
        i += 1

    return True        
# end of isPrime

while True:
    n = input()
    if n == 0:break

    ans = 0
    for i in range(n + 1, n * 2 + 1):
        if isPrime(i):ans += 1

    print ans

Measured memory_bytes: 10292
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	unsigned long long int i;
	int n, p, cnt,fg;
	while (cin >> n) {
		i = 3;
		cnt = 1;
		fg = 0;	
		
		if ((int)log10(n) == 3) {
			cnt = 168;
			i = 1001;
		}
		else if ((int)log10(n) == 4) {
			cnt = 1229;
			i = 10001;
		}
		else if ((int)log10(n) == 5) {
			cnt = 9592;
			i = 100001;
		}

		if (200000 < n) {
			cnt = 17984;
			i = 200001;
		}
		if (300000 < n) {
			cnt = 25997;
			i = 300001;
		}
		if (400000<n) {
			cnt = 33860;
			i = 400001;
		}
		if (500000 < n) {
			cnt = 41538;
			i = 500001;
		}
		if (600000<n) {
			cnt = 49098;
			i =600001;
		}
		if (700000<n) {
			cnt = 56543;
			i = 700001;
		}
		if (800000<n) {
			cnt = 63951;
			i = 800001;
		}
		if (900000<n) {
			cnt = 71274;
			i = 900001;
		}



		for (; i <= n; i+=2) {
			for (int j = 3; j <= (int)sqrt(i); j += 2) {
				if (i%j == 0) {
					fg = 1;
					break;
				}
			}
			if (fg)
				fg = 0;
			else
				cnt++;
		}
		if (n == 1)
			cnt--;
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>

int main(void){
  char s[1000];
  int i,w;
  
  scanf("%s",s);
  scanf("%d",&w);

  i=0;
  while(1){
    if(i%w==0)
      printf("%c",s[i]);
    i++;
    if(s[i]=='\0')
      break;
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;

/**
 *  lcs(m,n) = 
 *  if x[m] == y[n] lcs[m-1,n-1]+1
 *  max(lcs[m-1,n],lcs[m,n-1])
 *
 */

string x, y;

const int N = 1000;

int c[N][N];

int lcs(int m, int n)
{
	if (m == -1 || n== -1) return 0;
	if (x[m] == y[n]) return lcs(m-1,n-1) + 1;
	int & cc = c[m][n];
	if (cc != -1) return cc;
	int xx = lcs(m-1,n);
	int yy = lcs(m,n-1);
	cc = xx > yy ? xx : yy;
	return cc;
}

int main()
{
	int n = 0;
	x.reserve(N);
	y.reserve(N);
	cin >> n; 
	for (int i=0;i<n;i++)
	{
		memset(c, -1, sizeof(c));
		cin >> x;
		cin >> y;
		cout << lcs(x.size()-1, y.size()-1) << endl;
		x.clear();
		y.clear();
	}
}

Measured memory_bytes: 7096
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{

ll a, b, k;
cin >> a >> b >> k;

ll ans = k-a;

 if (k <=a) {
 cout << a-k <<" " << b  << endl; 
}
else if (k <= a + b){
    cout << 0 << " " << b -ans << endl;
}
else  {

    cout << 0 << " " << 0 << endl;
}


return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long count(int n, vector<long long>& vct, int s) {
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        if (vct[i] * 2 >= s) {
            int l = i;
            int r = n - 1;
            while (l < r) {
                int mid = (l + r) / 2 + 1;
                if (vct[i] + vct[mid] >= s) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            cnt += 1 + 2 * (l - i);
        }
    }
    return cnt;
}

long long calculate(int n, long long m, vector<long long>& vct, vector<long long>& svct, int s) {
    long long cnt = 0;
    long long val = 0;
    for (int i = 0; i < n; i++) {
        if (vct[i] * 2 >= s) {
            int l = i;
            int r = n - 1;
            while (l < r) {
                int mid = (l + r) / 2 + 1;
                if (vct[i] + vct[mid] >= s) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            val += vct[i] * 2 + 2 * (svct[l + 1] - svct[i + 1] + vct[i] * (l - i));
            cnt += 1 + 2 * (l - i);
        }
    }
    val -= s * (cnt - m);
    return val;
}

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

    vector<long long> vct = vector<long long>(n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &vct[i]);
    }
    sort(vct.rbegin(), vct.rend());

    vector<long long> svct = vector<long long>(n + 1);
    for (int i = 0; i < n; i++) {
        svct[i + 1] = svct[i] + vct[i];
    }

    long long l = 1;
    long long r = 200000;
    while (l < r) {
        int mid = (l + r) / 2 + 1;
        long long cnt = count(n, vct, mid);
        if (cnt >= m) {
            l = mid;
        } else {
            r = mid - 1;
        }
    }

    long long res = calculate(n, m, vct, svct, l);
    printf("%lld\n", res);
}

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

from collections import Counter

N = int(input())
aList = list(map(int, input().split()))

countDict = Counter(aList)

maxC = 0

for i in range(0, 100001):
    
    maxCandidate = countDict[i]+countDict[i+1]+countDict[i+2]
    
    if maxCandidate > maxC:
        maxC = maxCandidate
        
print(maxC)

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

int main(void){
  int n,a,b;

  while(1){
    cin >> n;
    if(n==0)break;
    int Pa=0,Pb=0;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b)Pa+=a+b;
      else if(a<b)Pb+=a+b;
      else {Pa+=a; Pb+=b;}
    }
    cout << Pa <<" "<< Pb << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define min(a,b) a > b ? b : a

int main(void){
	int n, count = 0;
	scanf("%d",&n);
	while(n != 1){
		n = n % 3 == 0 ? n / 3 : n / 3 + 1;
		count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1024