akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s;cin>>s;
    if(s.substr(0,4)>="2019" && s.substr(5,2)>="05"){
        cout<<"TBD";
        return 0;
    }
    else cout<<"Heisei";
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int xy[1001][1001];
char str1[1001];
char str2[1001];
int main(){
  int q;
  int i;
  int j,k;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s%s",str1,str2);
    for(j=1;j<=(int)strlen(str1);j++){
      for(k=1;k<=(int)strlen(str2);k++){
	if(str1[j-1]==str2[k-1]){
	  xy[j][k] = xy[j-1][k-1] + 1;
	}
	else{
	  xy[j][k] = xy[j-1][k] > xy[j][k-1] ? xy[j-1][k] : xy[j][k-1];
	}
      }
    }
    printf("%d\n",xy[strlen(str1)][strlen(str2)]);
    /*
    for(j=0;j<1001;j++)
      for(k=0;k<1001;k++) xy[j][k]=0;
    */
  }
  
  return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll 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))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110


signed main()
{
    string S;
    cin >> S;
    int a_pos = -1, z_pos = -1;
    REP(i, S.length()) {
        if(S[i] == 'A') {
            a_pos = i;
            break;
        }
    }
    for(int i = S.length()-1; i >= 0; --i) {
        if(S[i] == 'Z') {
            z_pos = i;
            break;
        }
    }
    printf("%lld\n", z_pos - a_pos + 1);

    return 0;
}


Measured memory_bytes: 640
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
ll a[N], b[N];

int main() {
  int n; ll k; scanf("%d %lld", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%lld", a+i);
  sort(a, a+n);
  int m = 0;
  for (int i = 0; i < n; i++)
    if (a[i] > 0)
      b[m++] = a[i];
  int z = 0;
  for (int i = 0; i < n-m; i++) {
    if (a[i] == 0)
      z++;
    a[i] *= -1;
  }
  reverse(a, a+n-m);
  ll lo = -1e18, hi = 1e18;
  while (lo <= hi) {
    ll cnt = 0;
    ll mi = (lo+hi) / 2;
    mi++;
    for (int i = 0; i < n-m; i++) {
      if (a[i] == 0 && mi <= 0)
        cnt += n-m-i-1 + m;
      else if (a[i] != 0)
        cnt += n-m - (lower_bound(a+i+1, a+n-m, (max(0ll, mi)+a[i]-1) / a[i]) - a);
    }
    for (int i = 0; i < m; i++) {
      cnt += m - (lower_bound(b+i+1, b+m, (max(0ll, mi)+b[i]-1) / b[i]) - b);
      if (mi < 0) {
        cnt += upper_bound(a, a+n-m, (-mi) / b[i]) - a - z;
      }
    }
    mi--;
    // cerr << mi << " " << cnt << endl;
    if (cnt < (n*1ll*(n-1)) / 2 - k + 1)
      hi = mi - 1;
    else
      lo = mi + 1;
  }
  printf("%lld\n", lo);
  return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    if (2 * n >= m) {
        cout << m / 2 << endl;
        return 0;
    }
    ll res = n;
    m -= 2 * n;
    res += m / 4;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e6+9;
string s;
int dp[sz][2];

int solve(int idx,int c){
	if(idx==s.size()) return c;
	int &ret=dp[idx][c];
	if(~ret) return ret;
	int val=s[idx]-'0'+c;
	ret=1e9;
	if(val<10) ret=min(ret,solve(idx+1,0)+val);
	ret=min(ret,solve(idx+1,1)+10-val);
	return ret;
}

int main(){
	cin>>s;
	reverse(all(s));
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,0);
	return 0;
}


Measured memory_bytes: 63876
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

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

int main() {
    int N;
    string s, t;
    cin >> N;
    cin >> s >> t;

    for (int j = 0; j < N; ++j) {
        string u = s + t.substr(N-j, j);
        if (u.substr(0, N) == s && u.substr(j, N) == t) {
            cout << N+j << endl;
            return 0;
        }
    }
    cout << 2*N << endl;

    return 0;
}


Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    map<string, int> m;
    vector<string> v = {"AC", "WA", "TLE", "RE"};
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        ++m[s];
    }
    for(string s : v){
        cout << s << " x " << m[s] << endl;
    }
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,i,ans=0;
    cin>>n;
    int arr[n+1];
    for(i=1;i<=n;i++)
        cin>>arr[i];
    for(i=1;i<=n;i++){
        if(i%2!=0 && arr[i]%2!=0)
            ans++;
    }
    cout<<ans;
}



Measured memory_bytes: 3612
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    unordered_set<int> st;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(st.count(a)){
            st.erase(a);
        }else{
            st.insert(a);
        }
    }
    cout << st.size() << '\n';
    return 0;
}


Measured memory_bytes: 4128
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] str = reader.readLine().split(" ");
		int A = Integer.parseInt(str[0]);
		int B = Integer.parseInt(str[1]);
		if (1 <= A  && A <= 9 && 1 <= B  && B <= 9) {
			System.out.println(A * B);
		}
		else {
			System.out.println("-1");
		}
	}
}

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

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

typedef long long ll;

const ll MOD = 1000000007;

ll solve(const vector<ll>& x) {
  int n = x.size();
  ll res = 0LL;
  REP(i,n) {
    ll tmp = (2 * i - n + 1) * x[i];
    while(tmp < 0) tmp += MOD;
    tmp %= MOD;
    res = (res + tmp) % MOD;
  }
  return res;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> x(n), y(m);
  REP(i,n) cin >> x[i];
  REP(i,m) cin >> y[i];

  ll res = solve(x) * solve(y) % MOD;
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define ld                 long double
#define ff                 first
#define ss                 second
#define P                 pair<int,int>
#define pb                 push_back
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
const int N = 3005;//change it when needed
int n;
double dp[N];
void solve() {
    cin >> n;
    memset(dp, 0.0, sizeof(dp));
    dp[0] = 1;
    // dp[i][j]   getting I heads for j coins......2 cases to deal ..
    // if it is a head or it   dp[i][j]=p[head]*dp[i-1][j-1]...we can get I-1 heads from j-1
    // it is a tail      dp[i][j]=p_tail*dp[i][j-1];
    for (int i = 1; i <= n; i++) {
        double head;
        cin >> head;
        for (int j = i; j > 0; j--) {
            dp[j] = head * dp[j - 1] + (1 - head) * dp[j];
        }
    }
    double ans = 0.0;
    ans = dp[n / 2 + 1];
    cout << fixed << setprecision(12) << ans << endl;
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t; cin >> t; while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,a,b=map(int,input().split())
    if n==2:
        print('Borys')
    else:
        print('Alice' if abs(a-b)%2==0 else 'Borys')
    
resolve()

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

int main() {
    string s; cin >> s;
    bool flg = true;
    
    if (s[0] != 'A') flg = false;
    
    size_t c = s.find('C');
    if (c < 2 or s.size()-2 < c) flg = false;
    else if (s.find('C', c+1) != string::npos) flg = false;
    else s.erase(c, 1);
    
    for (int i = 1; i < s.size(); i++) {
        if (s[i] < 'a' or 'z' < s[i]) {
            flg = false;
            break;
        }
    }
    
    cout << (flg ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
N,W = map(int,input().split())
 
import numpy as np
dp = np.full(10 ** 5 + 1, W + 1, dtype = int)
dp[0] = 0

for i in range(N):
  w, v = map(int, input().split())
  np.minimum(dp[:-v] + w, dp[v:], out = dp[v:])

for i in range(len(dp) - 1, -1, -1):
    if dp[i] <= W:
        print(i)
        break

Measured memory_bytes: 28268
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	bool f = false;
	for (int x = a; x <= a*b; x += a)if (x%b == c)f = true;
	cout << (f ? "YES" : "NO") << endl;
	return 0;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )



int main(int argc, const char* argv[]) {
	ll n, k;
	cin >> n >> k;

	double ret = 0.0;

	ll a = 0; // 分子
	ll b = 0; // 分母 = 2 ^ b
	rep(i, n) {
		ll e = 0;
		ll f = i + 1;
		while(f < k) {
			f *= 2;
			++e;
		}
		a = a * (1 << e) + (1 << b);
		b += e;

		while(a % 2 == 0 && b > 0) {
			a /= 2;
			--b;
		}
	}

	ret = (double)a / (double)(1 << b) / (double)n;

	cout << fixed << setprecision(11) << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
	int n;
	list<int> L;
	cin >> n;

	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		if (n % 2 == 1) {
			if (i % 2 == 0) L.push_front(a[i]);
			else L.push_back(a[i]);
		} else {
			if (i % 2 == 0) L.push_back(a[i]);
			else L.push_front(a[i]);
		}
	}

	for_each(L.cbegin(), L.cend(), [](int x){
		cout << x << " ";
	});

	cout << endl;
    return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b, t, ans = 0;
    cin >> a >> b >> t;
    ans = (int)(t / a) * b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy

N, K = map(int,input().split()) 
P = [list(map(int, input().split())) for i in range(2 * K)]
flatten = lambda x: [z for y in x for z in (flatten(y) if hasattr(y, '__iter__') else (y,))]

print(N - len(set(flatten(P[1::2]))))

Measured memory_bytes: 27132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n; 
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
    a[i] *= 2;
  }
  ll key = a[n-1];
  rep(i, n-1) {
    ll adder = a[i];
    if (!(i&1)) adder *= -1;
    key += adder;
  }
  key /= 2;
  vi ans(n);
  ans[n-1] = key;
  for (int i=n-2; i>=0; i--) {
    ans[i] = a[i] - ans[i+1];
  }
  rep(i,n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 2432
s=input()
while len(s)>0:
  #初めがdreamの場合
  if s[:5]=="dream" and (len(s)==5 or s[5]=="d" or s[5:8]=="era"):
    s=s[5:]
  elif s[:7]=="dreamer" and (len(s)==7 or s[7]=="d" or s[7]=="e"):
    #初めがdreamerの場合
    s=s[7:]
  elif s[:5]=="erase" and (len(s)==5 or s[5]=="d" or s[5]=="e"):
    #初めがeraseの場合
    s=s[5:]
  elif s[:6]=="eraser" and (len(s)==6 or s[6]=="d" or s[6]=="e"):
    s=s[6:]
  else:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 3188
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "YES":"NO"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>s) {
		VI c(3);
		REP(i, s.size()) c[s[i]-'a']++;
		sort(ALL(c));
		ll ans=c[2]-c[0]<=1;
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int x; cin >> x;
	int a, b;
	bool d = false;
	rep(i, 150) {
		for (int j = -150; j < 150; j++) {
			if (pow(i, 5) - pow(j, 5) == x) {
				a = i;
				b = j;
				d = true;
				break;
			}
		}
		if (d) break;
	}

	dunk(a);
	dunk(b);
	return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ull qpow(ull a, ull b, ull c)
{
    ull ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a % c;
        a = a * a % c;
        b >>= 1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
// C - Otoshidama

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N, Y;
	cin >> N >> Y;

	int x = -1, y = -1, z = -1;
	for (int i=0; i <= N; i++) {
		for (int j=0; i + j <= N; j++) {
			int k = N - i - j;
			if (k >= 0 && i * 10000 + j * 5000 + k * 1000 == Y) {
				x = i;
				y = j;
				z = k;
			}
		}
	}

	cout << x << " " << y << " " << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	long long N,  K;
	cin >> N >> K;
	map<int, int> mp;
	map<int, int> visitedTown;
	int nowTown = 1;
	visitedTown[1] = 1;
	for (int i = 1; i <= N; ++i) {
		cin >> mp[i];
	}
	for (long long i = 1 + 1; i <= K + 1; ++i) {
		nowTown = mp[nowTown];
		if (visitedTown[nowTown] != 0) {
			//cout << "visited at " << nowTown << " " << visitedTown[nowTown] << " " << i << endl;
			long long n = i - visitedTown[nowTown];
			//cout << K << " " << i << " " << n << endl;
			K = (K - i) % n + 1;
			for (long long i = 0; i < K; ++i) {
				nowTown = mp[nowTown];
			}
			break;
		}
		else {
			visitedTown[nowTown] = i;
		}
	}

	cout << nowTown << endl;

	return 0;
}



Measured memory_bytes: 20500
n = int(input())
lst = list(map(int, input().split()))
lst.reverse()

for i in range(n-1):
    if lst[i]+1 == lst[i+1]:
        lst[i+1] -= 1
    elif lst[i]+1 < lst[i+1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;


template<typename T>
class Value{
	T value;

	public:
	class boolean{
		bool b;
		public:
			boolean() { }
			boolean(bool b) : b(b) { }

			void operator = (const bool b){
				this->b = b;
			}

			bool get(){ return b; }
			void outyn(){ cout << (b ? "Yes" : "No") << endl; }
	};

	Value() { }
	Value(T value) : value(value) { }

	Value<T> add(Value<T> a){ return Value<T>(value + a.get()); }
	Value<T> sub(Value<T> a){ return Value<T>(value - a.get()); }
	Value<T> pro(Value<T> a){ return Value<T>(value * a.get()); }
	Value<T> div(Value<T> a){ return Value<T>(value / a.get()); }
	Value<T> mod(Value<T> a){ return Value<T>(value % a.get()); }
	boolean eq(Value<T> a){ return value == a.get(); }
	boolean seq(Value<T> a){
		assert(typeid(a.get()) == typeid(string));
		std::set<char> x, y;
		for(auto i : value) x.emplace(i);
		for(auto i : a.get()) y.emplace(i);
		return x == y;
	}
	boolean gt(Value<T> a){ return value > a.get(); }
	boolean gtq(Value<T> a){ return value >= a.get(); }
	boolean lt(Value<T> a){ return value < a.get(); }
	boolean ltq(Value<T> a){ return value <= a.get(); }


	T get(){ return value; }
	void set(T v){ value = v; }

	void out(){ cout << value << endl; };
};

template<typename T>
Value<T> max(Value<T> a, Value<T> b){
	return a.get() < b.get() ? b : a;
}
template<typename T>
Value<T> min(Value<T> a, Value<T> b){
	return a.get() < b.get() ? a : b;
}

/* output */
template<typename T>
ostream& operator << (ostream& os, Value<T> t){
	os << t.get();
	return os;
}
void yn(bool b){
	cout << (b ? "Yes" : "No") << endl;
}
template<typename T> void out(Value<T> a){
	cout << a << endl;
}
template<typename T> void out(vector<T> a, bool space = true){
	rep(i,a.size()){
		cout << a[i] << (i + 1 == a.size() ? "\n" : (space ? " " : ""));
	}
}
template<typename T> void out(vector<vector<Value<T>>>& v){
	rep(i,v.size()){
		out(v[i]);
	}
}

/* 多重vector */
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

/* input */
template<typename T>
istream& operator >> (istream& is, Value<T>& t){
	T res;
	is >> res;
	t.set(res);
	return is;
}

template<typename T> T in(){
	T res;
	cin >> res;
	return res;
}
template<typename T> vector<T> in(int n){
	vector<T> res(n);
	rep(i,n) res[i] = in<T>();
	return res;
}
template<typename T> vector<vector<T>> in(int h, int w){
	vector<vector<T>> res(h);
	rep(i,h) res[i] = in<T>(w);
	return res;
}





template<class C>
void solve(){
	vector<Value<typename C::T>> a = in<Value<typename C::T>>(C::Number());
	Value<string> v("abc");
	v.seq(a[0]).outyn();
}

struct type{
	using T = string;
	static constexpr int Number(){ return 1; }
};

int main(){
	solve<type>();
}


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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

ll n;

void solve(ll n)
{
    string ans;
    while (n > 0ll)
    {
        n--;
        ans = char('a' + n%26) + ans;
        n /= 26;
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    solve(n);
    return 0;
}

Measured memory_bytes: 3616
/*
                  ,     \    /      ,
                 / \    )\__/(     / \
                /   \  (_\  /_)   /   \
           ____/_____\__\@  @/___/_____\____
          |             |\../|              |
          |              \VV/               |
          |        ------___-------         |
          |__________Chuta Dragon___________|
           |    /\ /      \\       \ /\    |
           |  /   V        ))       V   \  |
           |/     `       //        '     \|
           `              V                '
        */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

int main()
{
    fastread();


    ll n;

    cin>>n;

    if(n)cout<<0<<endl;
    else cout<<1<<endl;





}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

main()
{
    int n,m,x; cin>>x>>m;
    vector<int> a(m);
    for(;m--;)
    {
        int a; cin>>a;
        x-=a;
    }
    if(x<0) cout << -1 << "\n";
    else cout << x << "\n";
}

Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
using namespace std;
const int mod = 1000000007;
const int N = 100005;
int a[110],b[110];
int main(){
	int n,m,p,t;
	cin>>n;
	int sum = 0;
	for (int i = 1;i <= n; ++i){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	cin >> m;
	int ans;
	while (m--){
		cin>>p>>t;
		ans = sum - a[p] + t;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
#define MAX(a,b) ((a)>(b))?(a):(b)
using namespace std;


int main() {
	int n,p,q,r,max=-1,w;
	int i,j;
	int c;
	int *sum;
	set<int> under;
	set<int> over;
	bool flag=false;
	scanf("%d%d",&n,&q);
	sum=(int *)malloc(sizeof(int)*n);
	scanf("%d",&w);
	max=sum[0]=w;
	for(i=1; i<n; ++i) {
		scanf("%d",&w);
		max=MAX(w,max);
		sum[i]=sum[i-1]+w;
	}
	if(q==1) {
		printf("%d\n",sum[n-1]);
		return 0;
	}
	p=max;
	while(1) {
		i=0;
		for(c=0; c<q-1; ++c) {
			for(j=0; i+j<n; ++j) {
				if(i==0) {
					if(sum[j]>p) {
						i=j;
						j=0;
						break;
					}
				} else {
					if(sum[i+j]-sum[i-1]>p) {
						i+=j;
						j=0;
						break;
					}
				}
			}
			if(i+j==n-1 && c<q-2) {
				if(p==max || flag) {
					printf("%d\n",p);
					return 0;
				}
				over.insert(p);
				if(flag) {
					++p;
				} else if(!under.empty()) {
					p=((*over.begin())+(*(--under.end())))/2;
				} else {
					p=(max+p)/2;
				}
			}
		}
		r=sum[n-1]-sum[i-1];
		if(r==p) {
			printf("%d\n",p);
			return 0;
		} else if (!flag) {
			if(r<p) {
				over.insert(p);
				if(!under.empty()) {
					p=((*(over.begin()))+(*(--under.end())))/2;
				} else {
					p=r+(p-r)/4;
				}
			} else if(r>p) {
				if((!over.empty() && !under.empty() && (*(over.begin()))-(*(--under.end()))<=10) || r-p<=10 ) {
					flag=true;
					under.insert(p);
					++p;
				} else {
					under.insert(p);
					if(!over.empty()) {
						p=((*(over.begin()))+(*(--under.end())))/2;
					} else {
						p=p+(r-p)/2;
					}
				}
			}
		} else {
			if(r>p) {
				++p;
			} else {
				printf("%d\n",p);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  Graph G;
  ll N, K;
  cin >> N >> K;
  vector<ll> flag(N, -1);
  vector<ll> Town(N);
  REP(i, N) {
    cin >> Town.at(i);
    Town.at(i)--;
  }
  ll BEGIN = 0, END = 0, START = 0;
  ll next = Town.at(0);
  bool check = false;
  ll i = 0;
  while (!check) {
    i++;
    if (flag.at(next) == -1) {
      flag.at(next) = i;
      next = Town.at(next);
    } else {
      BEGIN = flag.at(next);
      END = i;
      START = next;
      check = true;
    }
  }
  ll Ans = 0;
  if (K < BEGIN) {
    REP(i, K) Ans = Town.at(Ans);
  } else {
    ll MOD = (K - BEGIN) % (END - BEGIN);
    Ans = START;
    REP(x, MOD) Ans = Town.at(Ans);
  }
  //  cout << BEGIN << " " << END << " " << START << endl;
  cout << Ans + 1 << endl;
}

Measured memory_bytes: 6368
N,M=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(M)]

ab.sort(key=lambda x:x[1])
cnt=0
dis=-1
for i in range(M):
  if dis<ab[i][0]:
    cnt+=1
    dis=ab[i][1]-1
print(cnt)

Measured memory_bytes: 29084
#include <stdio.h>
int main(void)
{
  long int N,K;
  scanf("%ld%ld",&N,&K);
  if(N % K < (K - N % K))
    printf("%ld\n", N % K); 
  else
    printf("%ld\n", K - N % K);
  
  return 0;
}


Measured memory_bytes: 1724
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    std::vector<int> x(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    std::vector<int> times(N - K + 1);
    for (size_t i = 0; i < times.size(); i++)
    {
        int s = x[i];
        int e = x[i + K - 1];
        if (s < 0 && e > 0)
        {
            times[i] = e - s + min(-s, e);
        }
        else if(s < 0) {
            times[i] = -s;
        }
        else {
            times[i] = e;
        }
    }

    long min = times[0];
    for(size_t i = 1; i < times.size(); i++) {
        if(times[i] < min) {
            min = times[i];
        }
    }

    cout << min << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int buf[n];
  for (int i = 0; i < n; i++) {
    cin >> buf[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    cout << buf[i];
    if (i != 0) cout << ' ';
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3120
import sys
from itertools import permutations

def main():
    input = sys.stdin.readline
    N = int(input())
    pos = []
    for _ in range(N):
        x, y = map(int, input().split())
        pos.append((x, y))
    
    dists = []
    for root in permutations(range(N), N):
        d = 0
        for i in range(N-1):
            a = root[i]
            b = root[i+1]
            Xd = pos[a][0] - pos[b][0]
            Yd = pos[a][1] - pos[b][1]

            d += (Xd**2 + Yd**2)**0.5
        
        dists.append(d)
    
    return sum(dists) / len(dists)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 4400
import math
num = input()

num_list = num.split()
min_time = int(num_list[2]) * 60 + int(num_list[3])
hour_arg = min_time * 0.5
min_arg = int(num_list[3]) * 6

arg = abs(hour_arg - min_arg)
if arg == 0:
  answer = 0
if arg > 180:
  arg = 360 - arg
answer = pow(int(num_list[0]), 2) + pow(int(num_list[1]), 2) - (int(num_list[0]) * int(num_list[1]) * 2 * math.cos(math.radians(arg)))

print("{}".format(math.sqrt(answer)))

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

int main(){
    int h,n;
    cin >> h >> n;
    int suma=0;
    rep(i,n){
        int a;
        cin >> a;
        suma += a;
    }
    
    if(suma >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP_SIZE 10
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int main(){
    ll n; cin >> n;
    ll a[n];

    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    ll gcd;
    ll s,t,u;
    s = a[1];
    t = a[0];
    u = s%t;
    while(u!=0){
        s = t;
        t = u;
        u = s%t;
    }
    gcd = t;
    for(ll i = 1; i < n-1; i++){
        ll x,y,tmp;
        x = a[i+1];
        y = gcd;
        ll r = x%y;
        while(r != 0){
            x = y;
            y = r;
            r = x%y;
        }
        gcd = y;
    }
    cout << gcd << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    int ONA = -1;
    int ONB = -1;
    int count = 0;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    for( int i = 0; i <= 100; i++){
        if( a <= i && i < b){
            ONA = 1;
        }else{
            ONA = -1;
        }
        if( c <= i && i < d){
            ONB = 1;
        }else{
            ONB = -1;
        }
        if( ONA == 1 && ONB == 1){
            count++;
        }
    }

    printf("%d",count);

    return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

ll N,E,T;
ll dp1 [100001];
ll dp2 [100001];
const ll INF = 1e17;

int main()
{
	scanf("%lld%lld%lld",&N,&E,&T);
	vector<ll> X(N + 1);
	for(int i = 1;i <= N;i++){
		scanf("%lld",&X [i]);
	}

	fill_n(dp1,N + 1,INF);
	fill_n(dp2,N + 1,INF);
	dp1 [0] = 0;

	int j = 1;
	for(int i = 1;i <= N;i++){
		while(j < i && (X [i] - X [j]) * 2 > T) j++;
		chmin(dp1 [i],dp1 [j - 1] + T);
		chmin(dp1 [i],dp2 [j - 1] + X [i] * 2);
		chmin(dp2 [i],min(dp2 [i - 1],dp1 [i - 1] - X [i] * 2));
	}

	printf("%lld\n",dp1 [N] + E);

	return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    }
    else if (A == C) {
        cout << B << endl;
    }
    else {
        cout << A << endl;
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args){

			Scanner sc = new Scanner(System.in);
			// 整数の入力
			// スペース区切りの整数の入力
			int D = sc.nextInt();
			int N = sc.nextInt();
			
			if(N==100){
				N=101;
			}
			
			long kazu = 100;
			
			double warikire = (long) Math.pow(kazu, D);
//			System.out.println(warikire);
			long ans = (long) (warikire * N);

			// 出力
			System.out.println(ans);
			return ;
		}
}


Measured memory_bytes: 22868
ab = input().split()
A, B = int(ab[0]), int(ab[1])

out = None
if A == B:
    out = None
elif A % 2 != B % 2:
    out = "IMPOSSIBLE"
else:
    K = (A+B) // 2
    if abs(A-K) == abs(B-K):
        out = K
    else:
        out = "IMPOSSIBLE"

print(out)

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

#define ll long long
#define fr first
#define se second

using namespace std;

const long long N = 1e9;


int res;
vector< ll > v;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );
    ll n, m;
    cin >> n >> m;
    ll a[m];
    for ( int i=0; i<m; i++ )
        cin >> a[i];
    sort( a, a + m );
    ll ru = a[m - 1] - a[0];
    for ( int i=0; i<m - 1; i++ ){
        v.push_back( a[i] + ( n - a[i + 1] ) );
    }
    sort( v.begin(), v.end() );
    cout << min( ru, v[0] );
}


Measured memory_bytes: 3956
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();


        
        out.println((3*n+m)/2);
        out.flush();
    }
    



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
	int a,b; 
	P(int a, int b) {
	  this.a=a;
	  this.b=b;
	}
	public int compareTo(P p){			
	  return -b+p.b;
	}
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21204
N = int(input())
ans = 0
if N <= 356:
  print(0)
else:
  L = ['3','5','7']
  for i in range(len(str(N))-1):
    for j in range(len(L)):
      L.append(L[j]+'3')     #L[j]に"3"を加えた数をLに追加
      L.append(L[j]+'5')
      L.append(L[j]+'7')
  K=list(set(L))
  for i in range(len(K)):
    if K[i].count('3') > 0:
      if K[i].count('5') > 0:
        if K[i].count('7') > 0:
          if int(K[i]) <= N:
            ans += 1
  print(ans)

Measured memory_bytes: 18848
import sys
from collections import Counter

M = 10 ** 9 + 7

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()

    c = Counter(a)
    expected = Counter()
    if n % 2 == 0:
        for i in range(1, n, 2):
            expected[i] = 2
    else:
        expected[0] = 1
        for i in range(2, n, 2):
            expected[i] = 2

    if c == expected:
        return pow(2, n // 2, M)
    return 0


def main():
    res = solve()
    print(res)


main()


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> l.at(i);
  }
  int ans = 0;
  sort(l.begin(), l.end());
  for(i = 0; i < k; i++)
  {
    ans += l.at(n-1-i);
  }
  cout << ans << endl;
}

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep1(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    int maxi = 0;
    int mini = N;
    rep(i, N)
    {
        cin >> a[i];
        maxi = max(maxi, a[i]);
        mini = min(mini, a[i]);
    }
    if (maxi - mini >= 2) {
        cout << "No" << endl;
        return 0;
    } else if (maxi == mini) {
        if (maxi == N - 1) {
            cout << "Yes" << endl;
            return 0;
        }
        if (maxi <= N / 2) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    sort(a.begin(), a.end());
    int mini_num = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == mini) {
            mini_num++;
        }
    }
    const int maxi_num = N - mini_num;
    const int b = a[0] + 1 - mini_num;
    if (b >= 1 and 2 * b <= maxi_num) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


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

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

	if (s == "SUN")cout << '7' << endl;
	if (s == "MON")cout << '6' << endl;
	if (s == "TUE")cout << '5' << endl;
	if (s == "WED")cout << '4' << endl;
	if (s == "THU")cout << '3' << endl;
	if (s == "FRI")cout << '2' << endl;
	if (s == "SAT")cout << '1' << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
const int N = 5005;
const int mod = 1e9 + 7;
int n, head[N], tot, siz[N];
ll g[N], f[N][N], tmp[N];
struct node{int to, nex;}a[N << 1];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void add(int x, int y) {a[++ tot].to = y; a[tot].nex = head[x]; head[x] = tot;}
void dfs(int x, int fa)
{
	f[x][1] = 1; siz[x] = 1;
	for(int k = head[x]; k; k = a[k].nex)
	{
		int y = a[k].to; if(y == fa) continue;
		dfs(y, x);
		for(int i = 0; i <= siz[x] + siz[y]; i ++) tmp[i] = 0;
		for(int i = 1; i <= siz[x]; i ++)
			for(int j = 0; j <= siz[y]; j ++)
				tmp[i + j] = (tmp[i + j] + f[x][i] * f[y][j] % mod) % mod;
		for(int i = 1; i <= siz[x] + siz[y]; i ++) f[x][i] = tmp[i];
		siz[x] += siz[y];
	}
	for(int j = 2; j <= siz[x]; j += 2) f[x][0] = (f[x][0] - f[x][j] * g[j] % mod + mod) % mod;
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); g[0] = 1;
	for(int i = 1, x, y; i <= n - 1; i ++) {x = read(); y = read(); add(x, y); add(y, x);}
	for(int i = 2; i <= n; i += 2) g[i] = g[i - 2] * (i - 1) % mod;
	dfs(1, 0); printf("%lld\n", mod - f[1][0]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 194944
//============================================================================
// Name        : a.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	string s;cin>>s;
	int ans;
	if(s=="SUN"){
		ans=7;
	}else if(s=="MON"){
		ans=6;
	}else if(s=="TUE"){
		ans=5;
	}else if(s=="WED"){
		ans=4;
	}else if(s=="THU"){
		ans=3;
	}else if(s=="FRI"){
		ans=2;
	}else if(s=="SAT"){
		ans=1;
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
    int a=0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            a++;
        }
    }

    cout << 700+100*a << endl;

    return 0;
}


Measured memory_bytes: 256
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
if (a1 - b1 >= 0) == (a2 - b2 >= 0):
    print(0)
    exit()

d1 = (a1 - b1) * t1
d2 = (a2 - b2) * t2
d1, d2 = abs(d1), abs(d2)

if d1 > d2:
    print(0)
    exit()
if d1 == d2:
    print('infinity')
    exit()

cnt = 0
D = d2 - d1
cnt += (d1 // D) * 2
if d1 % D != 0:
    cnt += 1

print(cnt)


Measured memory_bytes: 38384