akhauriyash/Code-Regression huggingface dataset:
//部分点, ab + ac = a(b + c)を利用してDP -> はしゃぎ度ごとに遷移するところを「はしゃぎ度の総和を使って遷移」にして、遷移をまとめるとAccept!
//なんかしょうもないミスをしていた
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define int long long
using namespace std;
 
const int mod = 1000000007;
int n, c;
int a[400];
int b[400];
int dp[401][401];
int sigma[401][401];	//sigma[i][j] = power(a[i], j) + power(a[i] + 1, j) + … + power(b[i], j)
int power[401][401];
 
//子供0～id-1に飴を分けた。残りrem個の飴がある。
//ここからの「配りきる方法それぞれに対する活発度の総和」を返す
int dfs(int id, int rem) {
	if (id == n) return (rem == 0);
	if (dp[id][rem] != -1) return dp[id][rem];
	
	int ret = 0;
	
	for (int j = 0; j <= rem; j++) {	//子供idにはj個の飴を配ってみる
		ret += sigma[id][j] * dfs(id + 1, rem - j);
		ret %= mod;
	}
	return (dp[id][rem] = ret);
}
 
signed main() {
	int i, j, k;
	
	cin >> n >> c;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) cin >> b[i];
	
	for (i = 0; i <= n; i++) for (j = 0; j <= c; j++) dp[i][j] = -1;
	
	for (i = 0; i <= 400; i++) {
		power[i][0] = 1;
		for (j = 1; j <= 400; j++) {
			power[i][j] = (power[i][j-1] * i) % mod;
		}
	}
	for (i = 0; i <= 400; i++) {
		for (j = 0; j <= 400; j++) {
			//power(a[i], j) + power(a[i] + 1, j) + … + power(b[i], j)を計算
			sigma[i][j] = 0;
			for (k = a[i]; k <= b[i]; k++) {
				sigma[i][j] += power[k][j];
				sigma[i][j] %= mod;
			}
		}
	}
	
	cout << dfs(0, c) << endl;
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int n,x,a[1000000];
bool vis[1000000];

int main()
{
	scanf("%d%d",&n,&x);
	if(x==1 || x==2*n-1)
		return puts("No"),0;
	puts("Yes");
	if(x!=2)
	{
		a[n-1]=x-1,vis[x-1]=1;
		a[n]=x,vis[x]=1;
		a[n+1]=x+1,vis[x+1]=1;
		a[n-2]=x-2,vis[x-2]=1;
	}
	else
	{
		a[n-1]=x+1,vis[x+1]=1;
		a[n]=x,vis[x]=1;
		a[n+1]=x-1,vis[x-1]=1;
		a[n+2]=x+2,vis[x+2]=1;
	}
	for(int i=1,ptr=1;i<=2*n-1;i++)
	{
		if(a[i])printf("%d\n",a[i]);
		else
		{
			while(vis[ptr])ptr++;
			printf("%d\n",ptr++);
		}
	}

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

  char a, b;
  cin >> a >> b;
  cout << (a == b ? 'H' : 'D') << endl;

  return 0;
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e6;
int n , a[maxn][3],dp[maxn][3];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)
    {
        for(int j = 0 ; j < 3 ; ++j)
        {
            cin >> a[i][j];
            for(int t = 0 ; t < 3 ; ++t)
            {
                if(t != j)dp[i][j] = max(dp[i-1][t],dp[i][j]);
            }
            dp[i][j] += a[i][j];
        }
    }
    cout << max(max(dp[n][0],dp[n][1]),dp[n][2]);
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
int sum[200010];
int A[200010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    
    rep(i, N) cin >> A[i];
    sort(A, A + N, greater<int>());
    fact();
    int ans = 0;
    int k = power(2, N*2 - 1);
    rep(i, N) {
        ans = (ans + A[i]) % mod;
    }
    rep(i, N) {
        ans = (ans + Mul(A[i], Div(i, 2))) % mod;
    }
    cout << ans * k % mod << endl;


    return 0;
}


Measured memory_bytes: 19328
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    ll a, b;
    cin >> a >> b;
    ll c = __gcd(a, b);

    ll ans = a * b / c;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;

class Main{
  public static void main(String args[]){
	  Scanner s = new Scanner(System.in);
	  int[] string = new int[2];
	  string[0] = s.nextInt();
	  string[1] = s.nextInt();
	  System.out.print(string[0] * string[1] + " ");
	  System.out.println((string[0] * 2) + (string[1] * 2));
	  s.close();
  }
}


Measured memory_bytes: 25956
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10 , inf = 2e9 + 10;
int n , Q , mn[N] , fa[N];
vector<pair<int,pii> > edge;
int F(int x) {return fa[x] == x ? x : fa[x] = F(fa[x]);}

int main() {
  scanf("%d%d",&n,&Q);
  rep(i,0,n) mn[i] = inf;
  rep(i,0,Q) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    edge.pb(mp(c,mp(a,b)));
    mn[a] = min(mn[a] , c + 1);
    mn[b] = min(mn[b] , c + 2);
  }
  rep(t,0,2) rep(i,0,n)
    mn[i] = min(mn[i] , mn[(i+n-1)%n] + 2);
  rep(i,0,n)
    edge.pb(mp(mn[i] , mp(i , (i+1)%n)));
  rep(i,0,n) fa[i] = i;
  sort(all(edge));
  ll ans = 0;
  for(auto e : edge) {
    int a = F(e.se.fi);
    int b = F(e.se.se);
    if(a != b) {
      fa[b] = a;
      ans += e.fi;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, stones;
    cin >> len >> stones;
    vector<bool> dp(stones + 1, false);
    vector<int> arr(len);
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    for(int i = 0; i <= stones; i++) {
        if(dp[i]) continue;
        for(int j = 0; j < len; j++)
            if(i + arr[j] <= stones && !dp[i + arr[j]])
                dp[i + arr[j]] = true;
    }
    if(dp[stones]) cout << "First";
    else cout << "Second";
}



Measured memory_bytes: 3608
while True:
    a,b,c=map(int,input().split())
    if a==-1 and b==-1 and c==-1:
        break
    else:
        x=a+b
        if a==-1 or b==-1:
            print("F")
        else:
            if x>=80:
                print("A")
            elif x<80 and x>=65:
                print("B")
            elif x<65 and x>=50:
                print("C")
            elif x<50 and x>=30:
                if c>=50:
                    print("C")
                else:
                    print("D")
            else:
                print("F")


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

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

    ll n;
    cin >> n;

    cout << n * (n-1) / 2 << endl;  
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll n;cin>>n;
  ll i,j;
  ll cnt=0;
  ll tmp=sqrt(n);
  if(tmp*tmp<n) tmp++;
  //cout<<tmp<<endl;
  for(i=1;i<tmp;i++){
    if(n%i==0){
      //cout<<i<<endl;
      ll x=n/i;
      if(x-i==1) continue;
      x--;
      //cout<<x<<endl;
      cnt+=x;
    }
  }
  if(n<3) cnt=0;
  cout<<cnt<<endl;
}


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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

typedef long long i64;
const int nmax = 1e5;

int main() {
    fin.sync_with_stdio(false); fin.tie(); fout.tie();

    int n, k, p1 = -1;
    fin >> n >> k;

    for (int i = 1; i <= n; ++ i) {
        int x; fin >> x;
        if (x == 1)
            p1 = i;
    }

    int ans = 1 << 30;
    for (int i = min(1, p1 - k + 1); i + k - 1 <= n; ++ i) {
        int a = (i - 1) / (k - 1);
        if ((i - 1) % (k - 1) != 0)
            ++ a;

        int b = (n - (i + k - 1)) / (k - 1);
        if ((n - (i + k - 1)) % (k - 1) != 0)
            ++ b;
        ans = min(ans, a + b + 1);
    }

    fout << ans << "\n";
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll a_max = 0;
    rep(i, n)
    {
        cin >> a[i];
        a_max = MAX(a_max, a[i]);
    }
    ll a_sec;
    ll a_half = a_max;
    rep(i, n)
    {
        if (a[i] == a_max)
            continue;
        if (abs(a_max / 2 - a[i]) < a_half)
        {
            a_half = abs(a_max / 2 - a[i]);
            a_sec = a[i];
        }
    }
    cout << a_max << " " << a_sec << endl;

    return 0;
}

Measured memory_bytes: 4024
from numpy import*
t,*h=open(0)
_,a,b=int32(t.split())
i,j=0,2**30
while~i+j:
 k=(j+i)//2;t=(b*k-int32(h))//(a-b)
 if-k>sum(t[t<0]):i=k
 else:j=k
print(j)

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

int main(){
    int N;
    cin >> N;
    
    int A[N];
    
    bool isAllEven = true;
    int ans = 0;
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    while(isAllEven){
        for(int i = 0; i < N; i++){
            if(A[i] % 2 == 0){
                isAllEven = true;
            }else{
                isAllEven = false;
                break;
            }
        }
        
        if(isAllEven){
            ans++;
        }
        
        for(int i = 0; i < N && isAllEven; i++){
            A[i] /= 2;
        }
    }
    
    cout << ans;
    
    
}

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

int main(){
  string s,ans="";
  int w;
  cin>>s >>w;
  
  for(int i=0;i<(int)s.size();i+=w){
    ans+=s[i];
  }
  
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
inline bool issamesign(long long a,long long b){
    return (a<0&&b<0)||(a>0&&b>0);
}
inline long long nextval(long long a){
    if(a>0)return -1;
    else if(a<0)return 1;
    else return 0;
}
int main(){
    int n;
    long long a,sum[2]={},cnt[2]={};
    scanf("%d%lld",&n,&a);
    if(a==0){
        sum[0]=1;
        sum[1]=-1;
        cnt[0]=1;
        cnt[1]=1;
    }else{
        sum[0]=a;
        sum[1]=nextval(a);
        cnt[0]=0;
        cnt[1]=std::abs(a-nextval(a));
    }
    for(int i=1;i<n;i++){
        scanf("%lld",&a);
        for(int j=0;j<2;j++){
            if(sum[j]+a==0){
                cnt[j]++;
                sum[j]=nextval(sum[j]);
            }else if(issamesign(sum[j],sum[j]+a)){
                cnt[j]+=std::abs(sum[j]+a-nextval(sum[j]+a));
                sum[j]=nextval(sum[j]+a);
            }else{
                sum[j]+=a;
            }
        }
    }
    printf("%lld",std::min(cnt[0],cnt[1]));
    return 0;
}

Measured memory_bytes: 128
#define _DEBUG 1

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

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

void solve(ll N, std::vector<ll> a) {
  ll s = 1;
  ll c = 0;
  ll result = 0;
  while (1) {
    ll s0 = s;
    s = a.at(s);   // update s
    a.at(s0) = -1; // invalidate previous value
    if (s == -1) {
      result = -1;
      break;
    }
    if (s == 2) {
      result = c + 1;
      break;
    }
    c++;
  }

  cout << result << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N + 1);
  for (int i = 1; i <= N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string str; cin >> str;

	set<char> s;
	rep(i, str.length()){
		s.insert(str[i]);
	}
	bool ans = str.length() == s.size();

	cout << (ans ? "yes" : "no") << endl;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()

  return -(-n//2)/n

# main()
print(main())


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

int main(){
  
  int64_t N,K;
  cin>>N>>K;
  
  vector<int64_t> p(N);
  for(int i=0;i<N;++i) cin>>p[i];

  vector<int64_t> S(N-K+1,0);
  for(int i=0;i<K;++i) S[0] += p[i];
  for(int i=1;i<=N-K;++i){
    S[i] = S[i-1]-p[i-1]+p[i+K-1];
  }

  sort(S.begin(),S.end());
  double ans;
  ans=(double)(S[N-K]+K)/2;

  cout<<fixed<<setprecision(7);
  cout<<ans<<endl;
}


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

int main(){
    typedef long long lint;

    int N;
    cin >> N;
double A[N]={0};
int i=0;
double inverse_sum=0;
for(i;i<N;i++){
    cin>>A[i];
    //cout<<1/A[i];
    inverse_sum+=1/A[i];
    
}
cout<<1/inverse_sum;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int c[3][3];
int i,j;
for(i=0;i<3;i++){
   for(j=0;j<3;j++){
       cin >>c[i][j];
   }
}
int p1,p2,p3,p4,p5,p6;
p1=c[0][1]-c[0][0];
p2=c[1][1]-c[1][0];
p3=c[2][1]-c[2][0];
p4=c[0][2]-c[0][0];
p5=c[1][2]-c[1][0];
p6=c[2][2]-c[2][0];
if(((p1==p2)&&(p2==p3))&&((p4==p5)&&(p5==p6))){
cout<<"Yes";
}else{
cout<<"No";
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAX 3010
string a,b;
int dp[MAX][MAX];
bool been[MAX][MAX];
ll lcs(int i, int j){
    if(i == 0 || j == 0) return 0;
    if(been[i][j]) return dp[i][j];
    been[i][j] = true;
    if(a[i-1] == b[j-1]) return dp[i][j] = 1+lcs(i-1,j-1);
    return dp[i][j] = max(lcs(i-1,j),lcs(i,j-1));
}
void print(int i,int j){
    vector<char> res;
    while(i > 0 && j > 0){
        if(a[i-1] == b[j-1]){
            res.push_back(a[i-1]);
            i--;
            j--;
        }else if(dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    for(int i = res.size()-1;i>=0;i--) cout << res[i];
    cout << '\n';
}
int main(){
    cin >> a >> b;
    memset(been,false,sizeof(been));
    memset(dp,0,sizeof(dp));
    lcs(a.size(),b.size());
    print(a.size(),b.size());
    return 0;
}

Measured memory_bytes: 44928
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

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

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll N, M;
	cin >> N >> M;
	if (N == 2 || M == 2)
		cout << 0 << endl;
	else if (N == 1 && M == 1)
		cout << 1 << endl;
	else if (min(N, M) == 1)
		cout << max(N, M) - 2 << endl;
	else
		cout << (N - 2) * (M - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
if N % 2 != 0:
    print('No')
else:
    for i in range(len(S)//2):
        if S[i] != S[i+len(S)//2]:
            print("No")
            break
        if i == len(S)//2 - 1:
            print("Yes")

Measured memory_bytes: 3316
#include <cstdio>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  int x, a, b;
  scanf("%d%d%d", &x, &a, &b);
  if(b <= a) {
    puts("delicious");
  } else if(b-a <= x) {
    puts("safe");
  } else {
    puts("dangerous");
  }
  return 0;
}


Measured memory_bytes: 128
import math

n = int(input())
lis = [list(map(int, input().split())) for _ in range(n)]

c = 2
for i in range(2,n+1):
  c = math.factorial(i-2)*2 + c * (i-2)

dis = 0
for i in range(n):
  for j in range(i+1,n):
    dis = dis + pow((pow((lis[i][0] - lis[j][0]),2) + pow((lis[i][1] - lis[j][1]),2)),0.5)

ans = dis * c / math.factorial(n)

print(ans)


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

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

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] cardPairNumbers = br.readLine().split(" ");
            int aliceCardPairNumber = Integer.parseInt(cardPairNumbers[0]);
            int bobCardPairNumber = Integer.parseInt(cardPairNumbers[1]);

            if (aliceCardPairNumber == bobCardPairNumber) {
                System.out.println("Draw");
            } else if (aliceCardPairNumber == 1) {
                System.out.println("Alice");
            } else if (bobCardPairNumber == 1) {
                System.out.println("Bob");
            } else if (aliceCardPairNumber > bobCardPairNumber) {
                System.out.println("Alice");
            } else if (bobCardPairNumber > aliceCardPairNumber) {
                System.out.println("Bob");
            }

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var arg = Console.ReadLine().Split(' ');
            var A = arg[0].ToDecimal();
            var B = arg[1].ToDecimal();
            for (int i = 0; i < 100000; i++)
            {
                if (A == (int)(i * 0.08)
                    && B == (int)(i * 0.1))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(-1);
        }
    }

    public static class Extentions
    {
        public static int ToInt(this object obj)
        {
            return int.Parse(obj.ToString());
        }

        public static decimal ToDecimal(this object obj)
        {
            return decimal.Parse(obj.ToString());
        }
    }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;
  constexpr auto ceil = [](auto a,auto b){return (a-1)/b+1;};
  cout<<ceil(n-1,m-1)<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
 
#define INF 1120000000
 
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  sort(all(vec));
 
  cout << accumulate(vec.rbegin(), vec.rbegin()+k, 0) << endl;
 
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    v0=sorted(Counter(v[::2]).items(), key=lambda x: x[1])
    v1=sorted(Counter(v[1::2]).items(), key=lambda x: x[1])
    
    #print(n, v0[-1], v1[-1])
    if v0[-1][0] != v1[-1][0]:
        print(n-v0[-1][1]-v1[-1][1])
    else:
        if len(v0) == 1 and len(v1) == 1:
            print(n//2)
        else:
            try:
                a = v0[-1][1] + v1[-2][1]
            except:
                a = 0
            try:
                b = v0[-2][1] + v1[-1][1]
            except:
                b = 0
            print(n - max(a, b))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 25108
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, int> P;
ll X[100000];
int W[100000];
ll ans[100000];
ll N, L, T;
int get_num(int k) {
	ll cnt = 0;
	for (int i = 0; i < N; i++) {
		if (W[k] == W[i]) continue;
		double t = 0;
		if (W[k] == 1) {
			if (X[i] > X[k]) t = (X[i] - X[k]) / 2.0;
			else t = (X[i] + L - X[k]) / 2.0;
		}
		else {
			if (X[i] > X[k]) t = (L - X[i] + X[k]) / 2.0;
			else t = (X[k] - X[i]) / 2.0;
		}
		if (T < t) continue;
		(cnt += (ll)((T - t) / (L / 2.0)) + 1) %= N;
	}
	ll ret = k;
	if (W[k] == 1) (ret += cnt) %= N;
	else (ret += N - cnt) %= N;
	return ret;
}
int main() {
	cin >> N >> L >> T;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> W[i];
	}
	vector<P> pos;
	for (int i = 0; i < N; i++) {
		if (W[i] == 1) pos.emplace_back((X[i] + T) % L, i);
		else pos.emplace_back((X[i] + (L - T % L)) % L, i);
	}
	sort(pos.begin(), pos.end());
	int idx = get_num(pos[0].second);
	ans[idx] = pos[0].first;
	for (int i = 1; i < N; i++) {
		(idx += 1) %= N;
		ans[idx] = pos[i].first;
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  vector<vector<int>> R(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    R.at(A).push_back(B);
    R.at(B).push_back(A);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool X = true;
    for (int j = 0; j < R.at(i).size(); j++) {
      if (H.at(i) <= H.at(R.at(i).at(j))) {
        X = false;
      }
    }
    if (X) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8812
s  = input()
sts=0
ff= int(s[:2])
ll = int(s[2:])
if ff==0  and (ll == 0 or 12<ll):
	sts=4
if ff==0  and 0<ll<13:
	sts=1
if 0<ff<13 and (ll == 0 or 12<ll):
	sts=2
if 0<ff<13 and 0<ll<13:
	sts=3
if 12<ff and (ll == 0 or 12<ll):
	sts=4
if 12<ff and 0<ll<13:
	sts=1
	
if sts == 1:
	print("YYMM")
if sts == 2:
	print("MMYY")
if sts == 3:
	print("AMBIGUOUS")
if sts == 4:
	print("NA")

Measured memory_bytes: 3064
import heapq as pq
n,E = map(int, input().split())
M = [[] for i in range(n)]
for i in range(E):
 s,t,w = map(int, input().split())
 M[s].append([t,w])
 M[t].append([s,w])

def prim():
 color = [0] * n
 d = [float("inf")] * n
 d[0] = 0
 H = []
 pq.heappush(H, [0, 0])
 while H:
  u2,u1 = pq.heappop(H)
  color[u1] = 1
  if d[u1] < u2: continue
  for v1, v2 in M[u1]:
   if color[v1] == 1: continue
   if d[v1] > v2:
    d[v1] = v2
    pq.heappush(H, [d[v1], v1])
 return sum(d)
 
print(prim())

Measured memory_bytes: 41440
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
pair<long,long>p[1<<18];
long MIN=1e9,MAX;
main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>p[i].first>>p[i].second;
		if(p[i].first>p[i].second)swap(p[i].first,p[i].second);
		MIN=min(MIN,p[i].first);
		MAX=max(MAX,p[i].second);
	}
	long maxr=0,minb=1e9;
	for(int i=0;i<n;i++)
	{
		maxr=max(maxr,p[i].first);
		minb=min(minb,p[i].second);
	}
	long ans1=(maxr-MIN)*(MAX-minb);
	sort(p,p+n);
	minb=p[0].first,maxr=p[n-1].first;
	long ans2=(MAX-MIN)*(maxr-minb);
	long minsecond=MAX+1;
	for(int i=0;i<n;i++)
	{
		minb=min(min(p[i].second,i==n-1?MAX+1:p[i+1].first),minsecond);
		minsecond=min(minsecond,p[i].second);
		maxr=max(maxr,p[i].second);
		ans2=min(ans2,(MAX-MIN)*(maxr-minb));
	}
	cout<<min(ans1,ans2)<<endl;
}

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

using namespace std;

int main(){

    int A, B, counter;

    cin >> A >> B;

    counter = A;
    for(int i = 1; i <= B; i++){
        counter++;
        if(counter == 24){
            counter = 0;
        }
    }

    cout << counter << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
struct Kruskal{
  
  struct edge{
    Int from,to;
    T cost;
    Int used;
    edge(){}
    edge(Int from,Int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<Int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int n):n(n){}

  void init(Int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(Int x,Int y){
    return find(x)==find(y);
  }

  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(Int u,Int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Kruskal<Int> ks(n);
  using P = pair<Int, Int>;

  const Int INF = 1e18;
  vector<P> ls(n,P(INF,-1)),rs(n,P(INF,-1)),dp(n);
  function<void(Int, Int)> dfs=
    [&](Int l,Int r)->void{
      if(l+1==r){
        dp[l]=P(a[l],l);
        return;
      }
      Int m=(l+r)>>1;      
      dfs(l,m);
      dfs(m,r);
      P x(INF,-1),y(INF,-1);
      for(Int i=l,j=m;i<m||j<r;){
        if(i==m){
          chmin(ls[dp[j++].second],x);
          continue;
        }
        if(j==r){
          chmin(rs[dp[i++].second],y);
          continue;
        }
        if(dp[i].first<=dp[j].first){
          Int k=dp[i++].second;
          chmin(rs[k],y);
          chmin(x,P(a[k]-k*d,k));
        }else{
          Int k=dp[j++].second;
          chmin(ls[k],x);
          chmin(y,P(a[k]+k*d,k));
        }
      }
      
      inplace_merge(dp.begin()+l,dp.begin()+m,dp.begin()+r);
    };  
  dfs(0,n);
  
  auto add_edge=
    [&](Int x,Int y){
      if(x<0||y<0) return;
      Int c=abs(x-y)*d+a[x]+a[y];
      ks.add_edge(x,y,c);
    };
  for(Int i=0;i<n;i++) add_edge(ls[i].second,i);
  for(Int i=0;i<n;i++) add_edge(i,rs[i].second);

  cout<<ks.build()<<endl;
  return 0;
}


Measured memory_bytes: 33756
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			int A = int.Parse(Console.ReadLine());
			int B = int.Parse(Console.ReadLine());
			int C = int.Parse(Console.ReadLine());
			int X = int.Parse(Console.ReadLine());

			int count = 0;

			for(int i=0; i <= A; ++i) {
				for(int j=0; j <= B; ++j) {
					for(int k=0; k <= C; ++k) {
						if(i * 500 + j*100 + k*50 == X) {
							++count;
						}
					}
				}
			}

			Console.WriteLine(count.ToString());
		}
	}
}


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

using namespace std;

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

  int ans = 1e9;
  for (int i = 0; i < N-K+1; ++i) {
    if (x[i+K-1] < 0) {
      // x[i], x[i+K-1]
      ans = min(ans, -x[i]);
    } else if (x[i] > 0) {
      ans = min(ans, x[i+K-1]);
    } else {
      int tmp = min(abs(x[i])+x[i+K-1]-x[i], x[i+K-1]+x[i+K-1]-x[i]);
      ans = min(ans, tmp);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 105;
int cnt, n;
#define B __int128
map <__int128, int> F[N];
__int128 S;
int solve(B x, int n) {
    if (F[n].count(x)) return F[n][x];
    int d = 1, res = 0;
    for (int l = 0; l < n; ++ l) {
        for (int s = 1; l + s * 2 - 1 < n; ++ s) {
            B y = (x >> l) & ((((B)1) << s) - 1);
            for (int c = 2; l + s * c - 1 < n; ++ c) {
                y &= (x >> (l + s * (c - 1)));
                res = (res + 1ll * solve(y, s) * solve(x >> (l + s * c), n - (l + s * c)) % MOD * d) % MOD;
            }
        }
        if ((x >> l) & 1) d = (d + d) % MOD;
    }
    res = (res + d) % MOD;
    return F[n][x] = res;
}
string st;
int main() {
    cin >> st;
    for (int i = 0; i < st.size(); ++ i)
        S |= ((B)(st[i] - '0')) << i;
    cout << solve(S, st.size()) << endl;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <ctype.h>
int main(){
    int c,cnt[256]={0};
    while((c=getchar())!=EOF){
        if(isupper(c)){
            c=tolower(c);
        }
        cnt[c]++;
    }
    for(c='a';c<='z';c++){
        printf("%c : %d\n",c,cnt[c]);
    }
    return 0;
}


Measured memory_bytes: 2108
BTC_TO_YEN = 380000.0

n = gets.chomp.to_i

amounts = []
units = []

n.times do
  amount, unit = gets.chomp.split
  amounts << amount.to_f
  units << unit
end

sum = 0
n.times do |i|
  if units[i] == 'JPY'
    sum += amounts[i]
  else
    sum += amounts[i] * BTC_TO_YEN
  end
end

puts sum


Measured memory_bytes: 1788
n = int(input())
x = str(input())
x = list(x.split())

s = 0

for i in range(len(x)):
    s += int(x[i])

    
p = round(s/n)

en = 0
for i in range(len(x)):
    en += (int(x[i])-p)**2

print(en)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	int ans = 0;
	rep(i, N - 2) {
		string s = S.substr(i, 3);
		if (s == "ABC")
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

fv=A[0]//2
fmod=A[0]

for i in range(1,N):
    sv=A[i]//2
    smod=A[i]

    x,y,gcd=egcd(fmod,smod)
    if sv%gcd!=fv%gcd:
        print(0)
        exit(0)
    fv=fv-fmod*x*(fv-sv)//gcd
    fmod=fmod*smod//gcd
    fv=(fv+fmod)%fmod

if M<fv:
    print(0)
    exit(0)

if fv==0:
    print((M-fv)//fmod)
else:
    print((M-fv)//fmod+1)

Measured memory_bytes: 84476
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		System.out.println(arr[n - 1] - arr[0]);
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//データ入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		call(n);
	}
	
	
	
	private static void call(int n){
		for (int i = 1; i <= n; i++){
			int x = i;
		
			if (x % 3 == 0){
				System.out.print(" " + i);
				continue;
			}
		
			while (x != 0){
				if (x % 10 == 3){
					System.out.print(" "  + i);	
					break;
				}else{
					x /= 10;
				}
			}
		}
		System.out.print("\n");
	}
	
}


Measured memory_bytes: 28572
import sys

def main():
    input = sys.stdin.readline

    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    bc = []
    for _ in range(m):
        bc.append(list(map(int,input().split())))

    a.sort()
    a = tuple(a)

    bc.sort(key=lambda x: x[1], reverse=True)

    num = 0
    ans = 0

    for i in range(m):
        b = bc[i][0]
        c = bc[i][1]
        for j in range(num,min(num+b,n)):
            if c > a[j]:
                ans += c
            else:
                ans += a[j]

        num += b
        if num >= n:
            break

    if num < n:
        print(ans + sum(a[num:]))
    else:
        print(ans)
if __name__ == '__main__':
    main()


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

int main() {
  int N, sum = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
template< int char_size >
struct TrieNode {
  int nxt[char_size];

  int exist;
  vector< int > accept;

  TrieNode() : exist(0) {
    memset(nxt, -1, sizeof(nxt));
  }
};

template< int char_size, int margin >
struct Trie {
  using Node = TrieNode< char_size >;

  vector< Node > nodes;
  int root;

  Trie() : root(0) {
    nodes.push_back(Node());
  }

  void update_direct(int node, int id) {
    nodes[node].accept.push_back(id);
  }

  void update_child(int node, int child, int id) {
    ++nodes[node].exist;
  }

  void add(const string &str, int str_index, int node_index, int id) {
    if(str_index == str.size()) {
      update_direct(node_index, id);
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].nxt[c] == -1) {
        nodes[node_index].nxt[c] = (int) nodes.size();
        nodes.push_back(Node());
      }
      add(str, str_index + 1, nodes[node_index].nxt[c], id);
      update_child(node_index, nodes[node_index].nxt[c], id);
    }
  }

  void add(const string &str, int id) {
    add(str, 0, 0, id);
  }

  void add(const string &str) {
    add(str, nodes[0].exist);
  }

  void query(const string &str, const function< void(int) > &f, int str_index, int node_index) {
    for(auto &idx : nodes[node_index].accept) f(idx);
    if(str_index == str.size()) {
      return;
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].nxt[c] == -1) return;
      query(str, f, str_index + 1, nodes[node_index].nxt[c]);
    }
  }

  void query(const string &str, const function< void(int) > &f) {
    query(str, f, 0, 0);
  }

  int count() const {
    return (nodes[0].exist);
  }

  int size() const {
    return ((int) nodes.size());
  }
};
int prx[114514],cp[100009][26][26];
signed main(){
	Trie< 26, 'a' > trie;
	int n;
	cin>>n;
	vector<string> s;
	for(int i=0;i<n;i++){
		string tmp;
		cin>>tmp;
		trie.add(tmp);
		s.pb(tmp);
	}
	for(int i=0;i<n;i++){
		auto count_pref = [&](int idx){ prx[i]++; };
		trie.query(s[i],count_pref);
		prx[i]--;
	}
	for(int i=0;i<n;i++){
		int cur = 0;
		for(int j=0;j<s[i].size();j++){
			for(int k=0;k<26;k++){
				if( k == s[i][j] - 'a' )continue;
				int nx = trie.nodes[cur].nxt[k];
				if( nx != -1 ) cp[i][k][s[i][j] - 'a'] += trie.nodes[nx].exist + trie.nodes[nx].accept.size();
			}
          	cur = trie.nodes[cur].nxt[ s[i][j]-'a' ];
		}
	}
	int q; cin>>q;
	for(int p=0;p<q;p++){
		int num; string jun;
		int ans = 0;
		cin>>num;
		cin>>jun;
		num--;
		ans += prx[num];
		for(int i=0;i<26;i++){
			for(int j=i+1;j<26;j++){
				ans += cp[num][jun[i]-'a'][jun[j]-'a'];
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 289772
#include<stdio.h>


void pressbutten(int A,int B) {
	int sum=0;
	if (A >= B) {
		sum += A;
		A--;
		if (A > B) {
			sum += A;

		}
		else
			sum += B;
	}
	else {
	
		sum += B;
		B--;
		if (B > A) {
			sum += B;

		}
		else
			sum += A;
	}

	printf("%d",sum);
}

int main() {
	int a, b;
	scanf("%d %d",&a,&b);
	pressbutten(a,b);

	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := ReadString()
	m := make(map[rune]bool)
	for _, c := range S {
		if m[c] {
			fmt.Println("no")
			return
		}
		m[c] = true
	}
	fmt.Println("yes")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
import sys

def warshall_floyd(v_count, matrix):
    for i in range(v_count):
        for j, c2 in enumerate(matrix[j][i] for j in range(v_count)):
            for k, c1, c3 in zip(range(v_count), matrix[j], matrix[i]):
                if c1 > c2+c3:
                    matrix[j][k] = c2+c3
    return matrix


def has_negative_cycle(a) -> bool:
    return any(row[i] < 0 for i, row in enumerate(a))


V, E = map(int, input().split())
inf = float("inf")
matrix = [[inf]*V for _ in [0]*V]
for i in range(V):
    matrix[i][i] = 0
for s, t, d in (map(int, l.split()) for l in sys.stdin):
    matrix[s][t] = d
warshall_floyd(V, matrix)
if has_negative_cycle(matrix):
    print("NEGATIVE CYCLE")
else:
    for row in matrix:
        print(" ".join(map(lambda n: str(n) if n!=inf else "INF", row)))


Measured memory_bytes: 6220
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t A[100000];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	for (;;)
	{
		in >> N;
		if (N == 0) { break; }
		bool over1 = false;
		int32_t count = 0;
		for (size_t i = 0; i < N; i++)
		{
			in >> A[i];
			if (A[i] > 0) {
				++count;
				over1 |= (A[i] >= 2);
			}
		}
		if (over1) {
			out << count + 1 << endl;
		}
		else {
			out << "NA" << endl;
		}
	}

	return 0;
}
#endif



Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long h = Long.parseLong(scanner.next());
        long x = 1;
        long atc = 0;
        for (int i = 0; true; i++) {
            h = h / 2;
            atc = atc + x;
            x = x * 2;
            if (h == 0) {
                System.out.println(atc);
                break;
            }

        }
    }
}

Measured memory_bytes: 21844