akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool end=false;

void dfs(string s){
  if(s=="ABC"&&!(end)){
    cout<<"Yes"<<endl;
    end =true;
  }
  //cout<<"s:"<<s<<endl;
  string sa,sb,sc;
  bool update=false,updatea=true,updateb=true,updatec=true;
  int L=s.size();
  int i=0,j=0;
  while(i<L){
    //cout<<"s["<<i<<"]:"<<s[i]<<endl;
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      sa+='A';
      sb+='B';
      sc+='C';
      update=true;
      i+=2;
    }else{
      sa+=s[i];
      sb+=s[i];
      sc+=s[i];
      if(s[i]=='A') updatea=false;
      if(s[i]=='B') updateb=false;
      if(s[i]=='C') updatec=false;
    }
    i++;
    j++;
  }/*
  cout<<"sa:"<<sa<<endl;
  cout<<"sb:"<<sb<<endl;
  cout<<"sc:"<<sc<<endl;
*/
  if(update){
    if(updatea) dfs(sa);
    if(updateb) dfs(sb);
    if(updatec) dfs(sc);
  }
  return ;
}

int main(){
  string s;
  cin>>s;
  dfs(s);
  if(!end){
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 46416
ans = 0
input()
a = list(map(int, input().split()))
c = [0] * (10 ** 5 + 1)
for i in a:
    c[i] += 1
for x in range(min(a), max(a)+1):
    m = c[x - 1] + c[x] + c[x + 1]
    ans = max(ans, m)
print(ans)

Measured memory_bytes: 14008
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  int count[3];
  fill(count, count + 3, 0);
  for (int i = 0; i < 3; i++) {
    count[s[i] - 'a']++;
  }
  if (count[0] == 1 && count[1] == 1 && count[2] == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n=sz(s);
  int w=0;
  rep(i,n){
    if(s[i]=='o') w++;
  }
  if(15-n>=8-w) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<int> v(n, -1);

    if (m == 0 && n == 1) {
        cout << 0 << endl;
        return 0;
    } else if (m == 0 && n > 1) {
        cout << pow(10, n-1) << endl;
        return 0;
    }

    for (int i = 0; i < m; i++) {
        int s, c; cin >> s >> c;
        if (v[n-s] == -1) {
            v[n-s] = c;
        } else {
            if (v[n-s] == c) continue;
            else {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if ( n > 1 && v[n-1] == 0) {
        cout << -1 << endl;
        return 0;
    }

    if (v[n-1] == -1) v[n-1] = 1;

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (v[n-1-i] == -1) {
            v[n-1-i] = 0;
        }
        res += v[n-1-i] * pow(10, n-1-i);
    }

    cout << res << endl;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    lint A;
    string B;
    cin >> A >> B;

    if (A == 0) {
        cout << 0 << endl;
        return;
    }

    lint C = (lint)((B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0'));

    lint ans = (A * C) / 100;
    cout << ans << endl;
}

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


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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int dp[N][3];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, i, ai, bi, ci;
	cin>>n;
	for(i=0; i<n; i++){
		cin>>ai>>bi>>ci;
		if(i == 0){
			dp[i][0] = ai;
			dp[i][1] = bi;
			dp[i][2] = ci;
		}
		else{
			dp[i][0] = ai + max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = bi + max(dp[i-1][2], dp[i-1][0]);
			dp[i][2] = ci + max(dp[i-1][0], dp[i-1][1]);
		}
	}
	cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
	return 0;
}

Measured memory_bytes: 1408
n, time_slice = map(int, input().split())

job = []
burst_time =[]
for i in range(n):
    a, b = input().split()
    b = int(b)
    job.append(a)
    burst_time.append(b)

dic = dict(zip(job, burst_time))
turn_around_time = 0

while True:
    if not job:
        break

    job_copy = job[:]

    for i in job_copy:
        if dic[i] > time_slice:
            turn_around_time += time_slice
            dic[i] = dic[i] - time_slice
            job.append(i)

        else:
            turn_around_time += dic[i]
            print(i, turn_around_time)

        del job[0]



Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  cout << count(begin(s), end(s), '2') << '\n';
}

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

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	string s;
	cin >> s;
	int n = s.size();
	vector<ll> A(n+1,0);
	rep(i,n){
		if(s[i]=='<'){
			A[i+1] = A[i] + 1;
		}
	}	
	//for(auto x: A){
	//	cout << x << " " ;
	//}
	//cout << endl;
	for(int i = 1 ; i <= n ; i++){
		if(s[n-i]=='>'){
			chmax(A[n-i],A[n-i+1]+1);
			//A[n-i] = A[n-i+1] + 1;
		}
	}
	//for(auto x: A){
	//	cout << x << " " ;
	//}
	//cout << endl;
	//

//	for(int i = n-1 ; i >=0 ; i --){
	ll ans = 0;
	rep(i,n+1){
		ans += A[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 4740
#include <stdio.h>

int main(void)
{
	int H1,H2,M1,M2,K,answer;
	scanf("%d",&H1);
	scanf("%d",&M1);
	scanf("%d",&H2);
	scanf("%d",&M2);
	scanf("%d",&K);
	answer=(H2-H1)*60+(M2-M1)-K;
	printf("%d",answer);
	return 0;
}

Measured memory_bytes: 1728
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int a[114514][3];

int main() {
	int n;
	const int max = 100000;
	cin >> n;
	map<int, int> mp;
	ll ans = 0;
	REP(i, n) {
		int x;
		cin >> x;
		if (x > max)ans++;
		else mp[x]++;
	}
	for (int i = 1; i <= max; i++) {
		if (mp[i] >= i)ans += mp[i] - i;
		else ans += mp[i];
	}
	cout << ans;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int64_t N;
void func(int64_t cur, int use, int64_t &cnt){
    if (cur > N) return ;
    if (use == 0b111) ++cnt;

    func(cur * 10 + 7, use | 0b001, cnt);
    func(cur * 10 + 5, use | 0b010, cnt);
    func(cur * 10 + 3, use | 0b100, cnt);
}


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

cin >> N;

int64_t ans = 0;
func(0, 0, ans);

cout << ans << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        int a[n], count = 1;
        vector<int> v;
        int i;
        for (i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (int i = 0; i < n; i++) {
            if (i + k < n) {
                if (a[i] < a[i + k] ) {
                    cout << "Yes" << endl;
                }
                else {
                    cout << "No" << endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;	
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	
	int l,r,d;
	cin>>l>>r>>d;
	ll ans = 0;
	for(int i = l;i <=r ;i++)
		if(i%d == 0)ans++;
	cout<<ans;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;
ll ans = 0, pw[21];
void dfs (ll id, ll len, ll d, ll x = 1) {
    if (id == len/2) {
        if (d == 0) {
            ans += x * ((len & 1) ? 10 : 1);
        }
    } else {
        ll lb = -10, ub = 10;
        ll rt = pw[len-id-1] - pw[id];
        for (ll i=-9; i<=9; i++) {
            if (rt * i <= d) {
                lb = max(lb, i);
            } else {
                ub = min(ub, i);
            }
        }
        if (lb > -10) {
            dfs(id+1, len, d-lb*rt, x * (10 - abs(lb) - (!id)));
        }
        if (ub < 10) {
            dfs(id+1, len, d-ub*rt, x * (10 - abs(ub) - (!id)));
        }
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    pw[0] = 1;
    REP1 (i, 18) {
        pw[i] = pw[i-1] * 10;
    }

    ll d;
    cin >> d;

    REP1 (i, 18) {
        dfs(0, i, d);
    }

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


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

using namespace std;
#define BUF (100005)
#define ll long long 

char s[BUF];
int n;
int cnt[3];

int main(void){
	cin >> s;

	for(int i=0;i<strlen(s);i++) cnt[s[i]-'a']++;

	int f=1;
	
	if(abs(cnt[2]-cnt[1])>1) f=0;
	if(abs(cnt[1]-cnt[0])>1) f=0;
	if(abs(cnt[0]-cnt[2])>1) f=0;

	if(f) cout << "YES";
	else cout << "NO";	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll MOD= 1000000007;
#define pb push_back
#define mpr make_pair
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll a,b;
    cin>>a>>b;
  	if((a==1 && b==2) ||(a==2 && b==1))
		cout<<3<<endl;
 	else if((a==2 && b==3) ||(a==3 && b==2))
		cout<<1<<endl;
	else
    	cout<<2<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T, class S> inline int Digit_L(T n, S b){
  int res = 0;
  while(n){
    res++;
    n /= b;
  }
  return res;
}
template<class T, class S> inline int Digit_L(T n, S res[]){
  int sz = 0;
  while(n){
    res[sz++] = n % 10;
    n /= 10;
  }
  return sz;
}
int N;
int M;
int S[5];
int C[5];
int sz;
int d[10];
int main(){
  int i;
  int k;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
      rd(C[Lj4PdHRW]);
    }
  }
  for(k=0;;k++){
    sz =Digit_L(k, d);
    if(k==0){
      sz = 1;
      d[0] = 0;
    }
    if(sz > N){
      break;
    }
    if(sz < N){
      continue;
    }
    for(i=(0);i<(M);i++){
      if(d[sz-S[i]] != C[i]){
        goto e98WHCEY;
      }
    }
    wt_L(k);
    wt_L('\n');
    return 0;
    e98WHCEY:;
  }
  wt_L(-1);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200227-1

// --- original code ---
// int N, M, S[5], C[5];
// int sz, d[10];
// {
//   int i, k;
//   rd(N,M,(S,C)(M));
//   for(k=0;;k++){
//     sz = Digit(k, d);
//     if(k==0) sz = 1, d[0] = 0;
//     if(sz > N) break;
//     if(sz < N) continue;
//     rep(i,M) if(d[sz-S[i]] != C[i]) break_continue;
//     wt(k);
//     return 0;
//   }
//   wt(-1);
// }


Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n, k;
		cin >> n >> k;
		vi v(n);
		for(ll int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
		sort(all(v));
		ll int sm = 0;
		for(ll int i = 0; i < k; i++)
		{
			sm += v[i];
		}
		cout << sm << endl;
	}
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include<vector>
#include<algorithm>
#define lli long long int
// #include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	lli i,n,k,temp,s;
	// i=1;
	s=0;
	temp=0;
	cin>>n>>k;
	vector<lli> v(n);
	for(lli i=0;i<n;i++)cin>>v[i];
	sort(v.begin(),v.end());
	s=n-k;
	for(lli i=0;i<s;i++){
		temp+=v[i];
	}
	cout<<temp<<endl;
	
	return 0;
}

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

using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0 || S[i] != S[i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 10000000000000
using namespace std;

int main() {
 
int64_t N,ans=INF,tmpx,tmpy;
cin >>N;
  for(int i=1; i<=sqrt(N); i++){
    if(N%i==0&&ans>(i+(N/i))){ans=i+(N/i);tmpx=i;tmpy=N/i;}}
ans-=2;

 cout<<ans<<endl;
// vector<int> A(N);
// for(int i=0; i<N; i++){cin>>A[i];}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;



int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,v,w,c,n,t,m,k,x,y=0,ans=1;
    string str,s="",u;
    int X,Y;
    cin>>X>>Y;
    bool ok=false;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            if(2*i+4*j==Y and i+j==X)ok=true;
        }
    }
    if(ok){
        cout<<"Yes";
    }else{
        cout<<"No";
    }




    cout<<endl;
    return 0;
}




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

#define fasten(v) v.reserve(v.size())
#define wait() system("pause")
#define clock_starts() clock_t begin = clock()
#define clock_ends() clock_t end = clock()
#define print_running_time() double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; \
printf("Elapsed Time : %.10f second(s)\n", elapsed_secs)
#define read(s) freopen(s, "r", stdin)
#define write(s) freopen(s, "w", stdout)
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) v.begin(), v.end()
#define printBinary(n) cout << #n << " = " << bitset<64>(n) << endl
typedef priority_queue<int, vector<int>, greater<int> > min_pq;

#define UNASSIGNED 0

struct cell {
	bool single_nki;
	int one, two;
	cell() {
		single_nki = false;
		one = two = 0;
	}
	cell(string s) {
		one = 0, two = 0;
		vector<string> temp;
		for(int i=0; i<s.size(); i++) {
			if(s[i] == '/') {
				s[i] = ' ';
			}
		}
		stringstream is(s);
		string ss;
		while(is >> ss) {
			temp.push_back(ss);
		}
		if(temp.size() == 1) single_nki = true;
		else single_nki = false;
		if(single_nki) {
			if(temp[0] == "-") one = UNASSIGNED;
			else one = temp[0][0]-'0';
		}
		else {
			if(temp[0] == "-") one = UNASSIGNED;
			else one = temp[0][0]-'0';
			if(temp[1] == "-") two = UNASSIGNED;
			else two = temp[1][0]-'0';
		}
	}
	void print() {
		cout<<one<<' '<<two<<endl;
	}
};

cell a[maxn][maxn];

int solve() {
	int row, col;
	if(!funloc(row, col)) return 1;

}

int32_t main() {
  	for(int i=1; i<=6; i++) {
  		for(int j=1; j<=6; j++) {
  			string ss; cin>>ss;
  			a[i][j] = cell(ss);
  		}
  	}
  	int ret = solve();
    wait();
    return 0;
}*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define wait() system("pause")

int32_t main() {
	int n, k;
	cin>>n>>k;
	int ret = 1;
	for(int i=1; i<=n; i++) {
		ret = min(ret*2LL, ret+k);
	}
	cout<<ret<<endl;
	//wait();
    return 0;
}

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


int main(){
    int N, maxF=0;
    string tmp;
    map<string, int> S;
    queue<string> Q;

    cin >> N;
    rep(i,N) {
        cin >> tmp;
        auto itr = S.find(tmp);
        if (itr != S.end()){
            S[tmp]++;
        }
        else{
            S[tmp] =1;
        }
    }
    for (auto itr = S.begin(); itr != S.end(); ++itr){
        if (maxF == itr->second ){
            Q.push(itr->first);
        }
        else if(maxF < itr->second ){
            while(!Q.empty()) Q.pop();
            maxF = itr->second;
            Q.push(itr->first);
        }
        else{
        }
    }
    while(!Q.empty()){
        cout << Q.front() << endl;
        Q.pop();
    }
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int n,m,c,ans=0;
int b[25],a[25][25];
int main()
{
    scanf("%d%d%d",&n,&m,&c);
    for(int i=1;i<=m;i++)
        scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=m;j++)
        {
            int x;
            scanf("%d",&x);
            sum+=x*b[j];
        }
        if(sum+c>0) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(m)]
    ans = "IMPOSSIBLE"
    list_1 = []
    list_n = []
    for i in range(m):
        if ab[i][0] == 1:
            list_1.append(ab[i][1])
        elif ab[i][1] == n:
            list_n.append(ab[i][0])
    if len(set(list_1) & set(list_n)) > 0:
        ans = "POSSIBLE"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54696
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    ab = 0
    A = list(map(int, input().split()))
    for j in range(M):
        ab += A[j] * B[j]
    if ab + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

#define MAX_N 100
#define MAX_W 10000

void solve();

int N, W;
int v[MAX_N + 1], w[MAX_N + 1];
int dp[MAX_N + 1][MAX_W + 1];

int main() {

    cin >> N >> W;

    //??????0
    v[0] = 0;
    w[0] = 0;

    //??????1~
    for (int i = 1; i <= N; i++) {
        cin >> v[i] >> w[i];
    }

    solve();
    cout << dp[N][W] << endl;

    return 0;
}

void solve(){
    for (int i = 1; i <= N; i++) {          //??????1??????????????????
        for (int j = 0; j <= W; j++) {
            /* ????????? */
	  if(w[i] > j){
	    dp[i][j] = dp[i-1][j];
	  }else{
	    dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
	  }
	}
    }
}

Measured memory_bytes: 6996
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

int n,dp[100111][2],nxt[100111][2];
LL a[2],s[100111];
int main()
{
	get3(n,a[0],a[1]);
	for(int i=1;i<=n;i++)get1(s[i]);
	
	nxt[n+1][0]=nxt[n+1][1]=n+1;
	for(int i=n;i>1;i--)
	{
		if(s[i]-s[i-1]>=a[0])nxt[i][0]=nxt[i+1][0];else nxt[i][0]=i;
		if(s[i]-s[i-1]>=a[1])nxt[i][1]=nxt[i+1][1];else nxt[i][1]=i;
	}
	dp[n][0]=dp[n][1]=1;
	for(int i=n-1;i>=1;i--)for(int j=0;j<2;j++)
	{
		int id=upper_bound(s+1,s+n+1,s[i]+a[j]-1)-s-1;
		if(id==i)
		{
			dp[i][j]=dp[i+1][0]+dp[i+1][1];
			if(dp[i][j]>=mod)dp[i][j]-=mod;
		}
		else if(id==i+1||nxt[i+2][j^1]>id)dp[i][j]=dp[id][j^1];
		else dp[i][j]=0;
//		printf("%d %d id= %d dp= %d nxt= %d\n",i,j,id,dp[i][j],nxt[i+2][j^1]);
	}
	printendl((dp[1][0]+dp[1][1])%mod);
	return 0;
}

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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n; cin >> n;
    vector<vector<int>> act(n,vector<int>(3));
    rep(i,n)rep(j,3)cin>>act[i][j];
    //1-index
    vector<vector<int>> dp(100100,vector<int>(3,0));
    for(int i=0; i<n; i++){
        //今日
        rep(j,3){
            //昨日
            rep(k,3){
                if(j==k) continue;
                chmax(dp[i+1][j],dp[i][k]+act[i][j]);

            }
        }
    }
    auto itr=max_element(all(dp[n]));
    cout<<*itr<<endl;
    
}

Measured memory_bytes: 11136
let () =
  let counting_sort a b k =
    let len = (Array.length a) -1 and
        c = Array.make (k+1) 0 in
    Array.iter (fun x -> c.(x) <- c.(x)+1) a;
    for i = 1 to k do
      c.(i) <- c.(i) + c.(i-1)
    done;
    for i = 0 to len do
      let j = len - i in
      b.(c.(a.(j))-1) <- a.(j);c.(a.(j)) <- c.(a.(j))-1
    done;b
  in
  let read x = Scanf.scanf " %d" (fun y -> y) in
  let n = read_int () in
  let a = Array.init n read in
  let res = counting_sort a (Array.make n 0) 10000 in
  Printf.printf "%d" res.(0);
  for i = 1 to n-1 do
    Printf.printf  " %d" res.(i)
  done;
  Printf.printf "\n"
;;

Measured memory_bytes: 36216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

// hanbun-zenrekkyo
class Program
{
    static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Program().solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    int N;
    long V;
    void solve()
    {
        N = cin.nextint;
        V = cin.nextlong;

        var A = cin.scanlong;
        var B = cin.scanlong;
        var C = cin.scanlong;
        var D = cin.scanlong;

        var T = new List<long>();
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                var m = A[i] + B[j];
                if (m > V - 2) continue;
                T.Add(m);
            }
        }
        var S = T.ToArray();
        Array.Sort(S);

        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                var m = C[i] + D[j];
                if (m > V - 2) continue;
                ans += UpperBound(S, V - m) - LowerBound(S, V - m);
            }
        }

        Console.WriteLine(ans);
    }


    int UpperBound(long[] arr, long val)
    {
        int low = 0, high = arr.Length;
        int mid;

        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid] <= val) low = mid + 1;
            else high = mid;
        }
        return low;
    }

    int LowerBound(long[] arr, long val)
    {
        int low = 0, high = arr.Length;
        int mid;

        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid] < val) low = mid + 1;
            else high = mid;
        }
        return low;
    }

}


class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return Console.ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int N, W; cin >> N >> W;
    vl v(N), w(N);
    vl dp(W+1);

    rep(i,N) cin >> v[i] >> w[i];
    rep(i,N) rrep(j,W+1){
        if(j - w[i] >= 0)
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    }
    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 3300
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

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

    for(LL b = -1000; b <= 1000; b++){
        LL y = x + (b * b * b * b * b);
        for(LL a = -1000; a <= 1000;a++){
            LL a5 = a * a * a * a * a;
            if(a5 == y){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys
from heapq import heapify, heappop

def solve(N: int, K: int, V: "List[int]"):
    ans = 0
    for n_all in range(min(N, K)+1):
        for n_l in range(n_all+1):
            n_r = n_all - n_l
            tmp_v = V[:n_l] + V[N-n_r:]
            heapify(tmp_v)
            i = 0
            while len(tmp_v) > 0 and tmp_v[0] < 0 and i < K-n_all:
                _ = heappop(tmp_v)
                i += 1
            ans = max(ans, sum(tmp_v))
    print(ans)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    V = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, V)

if __name__ == '__main__':
    main()


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

int main() {
  int H, W;
  char s[50+10][50+10] = {};
  cin >> H >> W;
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == '#') continue;
      
      int b = 0;
      if (s[i-1][j-1] == '#') b++;
      if (s[i-1][j  ] == '#') b++;
      if (s[i-1][j+1] == '#') b++;

      if (s[i][j-1] == '#') b++;
      if (s[i][j+1] == '#') b++;

      if (s[i+1][j-1] == '#') b++;
      if (s[i+1][j  ] == '#') b++;
      if (s[i+1][j+1] == '#') b++;
      
      s[i][j] = b + '0';
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
  
}



Measured memory_bytes: 256
<?php
// Your code here!
$insert1 = explode(" ",trim(fgets(STDIN)));
$N = $insert1[0];
$M = $insert1[1];
$insert2 = explode(" ",trim(fgets(STDIN)));

$sum = array_sum($insert2);
for($i=0; $i <= count($insert2)-1; $i++){
    if($insert2[$i] >= $sum / (4*$M)){
        $results[] = $insert2[$i];
    }
}

if(count($results) >= $M){
    echo "Yes".PHP_EOL;
}else{
    echo "No".PHP_EOL;
}

Measured memory_bytes: 4728
n,W=[int(j) for j in input().split()]
wv=[[int(j) for j in input().split()]for i in range(n)]
import numpy as np
dp=np.zeros(W+1,dtype=np.int64)
for w,v in wv:
    dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp.max())

Measured memory_bytes: 16344
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int a,b,c;
    a=0;
    int j=0;
    while(1){
        if(j>=4){
            break;
        }
        cin>>b>>c;
        if(b==1){
            cout<<c*6000<<endl;
        }else if(b==2){
            cout<<c*4000<<endl;
        }else if(b==3){
            cout<<c*3000<<endl;
        }else{
            cout<<c*2000<<endl;
        }
        j++;
    }
}



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

using namespace std;

int main() {

	int n, m, tmp;

	cin >> n >> m;
	for (int i = 0;i < m;i++) {
		cin >> tmp;
		n -= tmp;
	}

	if(n>=0) cout << n << endl;
	else cout << "-1" << endl;

	return 0;
}


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

using namespace std;

const int MOD=(int)1e9+7;

int add(int a,int b)
{
    a+=b;
    if(a>=MOD)
    {
        a-=MOD;
    }
    if(a<0)
    {
        a+=MOD;
    }
    return a;
}

int mul(int a,int b)
{
    return a*(long long)b%MOD;
}


typedef long long ll;
typedef long double ld;

const int N=300+5;

int n;
int f[N];
ld dp[N][N][N];

ld calc(int a,int b,int c)
{
    if(dp[a][b][c]!=-1) return dp[a][b][c];
    dp[a][b][c]=0;
    ld p[5];
    p[1]=a/(ld)(a+b+c);
    p[2]=b/(ld)(a+b+c);
    p[3]=c/(ld)(a+b+c);
    if(p[1])
    {
        dp[a][b][c]+=p[1]*(1+calc(a-1,b,c));
    }
    if(p[2])
    {
        dp[a][b][c]+=p[2]*(1+calc(a+1,b-1,c));
    }
    if(p[3])
    {
        dp[a][b][c]+=p[3]*(1+calc(a,b+1,c-1));
    }
    int d=n-a-b-c;
    if(d>0)
    {
        dp[a][b][c]+=d/(ld)(a+b+c);
    }
    return dp[a][b][c];
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) for(int k=0;k<N;k++) dp[i][j][k]=-1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        x--;
        f[x]++;
    }
    dp[0][0][0]=0;
    int a=f[0],b=f[1],c=f[2];
    cout<<fixed<<setprecision(9)<<calc(a,b,c)<<"\n";
    return 0;
}



Measured memory_bytes: 443648
#include <bits/stdc++.h>
#define ln(S) (S).length()
using namespace std;

typedef long long llint;



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

	for (int i = 0; i < ln(s); ++i)
	{
		cout << s[i];

		if (i == 3)
			cout << " ";
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[], int n, int key){
	int i=0;
	A[n]=key;
	while(A[i] != key)i++;
	return i != n;
}

int main(){
	int i, n, A[10000+1], q, key, sum=0;
	
	scanf("%d",&n);
	for(i=0; i<n; i++) scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for(i=0; i<q; i++){
		scanf("%d",&key);
		if(search(A, n, key)) sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 636
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
inf = 999999999

n = int(input())
h = list(map(int, input().split()))

dp = [inf] * (n + 1)
dp[0] = 0
for i in range(0, n - 1):
    cost = abs(h[i + 1] - h[i])
    dp[i + 1] = min(dp[i + 1], dp[i] + cost)
    if i + 2 < n:
        cost = abs(h[i + 2] - h[i])
        dp[i + 2] = min(dp[i + 2], dp[i] + cost)

print(dp[n - 1])


Measured memory_bytes: 20248
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


int main() {
    ll N,M;
    cin>>N>>M;
    ll max_gcd=1;
    for(ll i= 1;i*i<=M;i++){
        if(M%i==0){
            if(M/i>=N){
                max_gcd=max(max_gcd,i);
            }
            if(i>=N){
                max_gcd=max(max_gcd,M/i);
            }
            
        }
        
    }
    cout<<max_gcd<<endl;
    
return 0;
}

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

//B - Collecting Balls (Easy Version)
int main() {
  int n, k;
  cin >> n >> k;
  
  int sum = 0;
  vector<int> x(n);
  for (int i = 0; i < n ; i++){
    cin >> x.at(i);
    sum += min(x.at(i) , k-x.at(i))*2;
  }
  cout << sum << endl;
}


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

//約数列挙（因数分解）
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

// n以下の素数テーブル
// https://qiita.com/peria/items/a4ff4ddb3336f7b81d50
vector<bool> prime_table(int n) {
	vector<bool> prime(n + 1, true);
	if(n >= 0) prime[0] = false;
	if(n >= 1) prime[1] = false;
	for(int i = 2; i * i <= n; i++) {
		if(!prime[i]) continue;
		for(int j = i + i; j <= n; j += i) {	// j = i * iで良い？
			prime[j] = false;
		}
	}
	return prime;
}

vector<int> Eratosthenes( const int N )
{
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	auto prime = prime_table(n+1);
	vector<ll> p(n + 1, 1);
    for( int i = 2; i <= n; i++ )
    {
        // if( prime[ i ] )
        {
            for( int j = i; j <= n; j += i )
            {
                p[ j ] += 1;
            }
        }
    }
	
	
	// for(auto t: p) cout << t << endl;
	for(int i = 1;i<=n;i++) {
		ans += i * p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 82720
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cctype>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1)
    {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 1; i <= 1000; i++)
    {
        if ((a * i % b == c))
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main()
{
	int len,num;string a;
	cin>>len>>num;
	cin>>a;
	for(int i=0;i<len;i++){
		if(i==num-1)cout<<(char)(a[i]+32);
		else cout<<a[i];
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-8;

typedef complex<double> P;
typedef complex<double> Vec;

double cross(Vec a, Vec b) {
	return a.real() * b.imag() - a.imag() * b.real();
}

bool comp(P a, P b) {
	if (a.real() != b.real()) return a.real() < b.real();
	return a.imag() < b.imag();
}

vector<P> convex_full(vector<P> p) {
	sort(ALL(p), comp);
	
	vector<P> res(2 * p.size());
	int k = 0;
	
	// ?????´??????
	REP(i, p.size()) {
		while (k > 1 && cross(res[k - 1] - res[k - 2], p[i] - res[k - 2]) <= 0) k--;
		res[k++] = p[i];
	}
	
	// ?????´??????
	for (int i = (int)p.size() - 2, c1 = k; i >= 0; i--) {
		while (k > c1 && cross(res[k - 1] - res[k - 2], p[i] - res[k - 2]) <= 0) k--;
		res[k++] = p[i];
	}
	
	res.resize(k - 1);
	return res;
}

int main() {
	int n;
	while (cin >> n, n) {
		vector<P> p(n);
		REP(i, n) {
			double x, y;
			scanf("%lf,%lf", &x, &y);
			p[i] = P(x, y);
		}
		
		vector<P> cf = convex_full(p);
		
		cout << p.size() - cf.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {

	int n;
	cin >> n;

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (n == i * 4 + j * 7) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;

}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  int64 k;
  cin >> n >> k;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    xs[i]--;
  }

  vector<int64> ts(n, -1);
  int v = 0;
  int64 t = 0;
  ts[0] = 0;
  while (t < k) {
    v = xs[v];
    t++;
    if (ts[v] < 0) {
      ts[v] = t;
    } else {
      int64 cycle = t - ts[v];
      if (k - t > cycle) {
        t += (k - t) / cycle * cycle;
      }
    }
  }
  cout << v + 1 << endl;
}

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

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

    if (s.size() <= k) {
        cout << s << endl;
        return 0;
    }

    string ans = s.substr(0,k) + "...";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628