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

vector<int> l(26, 0);
int last(int d, int i) { return l.at(i); }

int score(int d, int t, vector<int> &c, vector<vector<int>> &s) {
    int res = s.at(d).at(t);
    for(int i = 0; i < 26; i++) {
        if(i != t) {
            res -= c.at(i) * (d - last(d, i));
        }
    }
    return res;
}

int loss(int d, int t) {
    return (d - l.at(t)) * (d - l.at(t));
}

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D + 1, vector<int>(26));

    for(int i = 0; i < 26; i++) {
        cin >> c.at(i);
    }
    for(int d = 1; d <= D; d++) {
        for(int i = 0; i < 26; i++) {
            cin >> s.at(d).at(i);
        }
    }

    int v = 0;
    for(int d = 1; d <= D; d++) {
        int max_score = -9999999;
        int max_t = -1;
        for(int i = 0; i < 26; i++) {
            int is = score(d, i, c, s) + loss(d, i);
            if(max_score < is) {
                max_score = is;
                max_t = i;
            }
        }
        v += max_score;
        l.at(max_t) = d;
        cout << (max_t + 1) << endl;
    }

    return 0;
}

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

int main(){
  ll n; cin >> n;
  double ans;
  double odd = 0.0;
  double dd = 0.0;
  for(int i=1; i<=n; i++){
    if(i%2 == 0){
      dd += 1.0;
    }else{
      odd += 1.0;
    }
  }
  ans = odd / (double)n;
  cout << ans << endl;
  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 all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int n;cin>>n;
    int m=sqrt(n)+1;
    int ans=0;
    for(int i=m;;i--){
        if(n%i==0){
            ans+=i-1;
            ans+=n/i-1;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  rep(i,N)  cin >> A.at(i);
  rep(i,N)  cin >> B.at(i);

  vector<int> cnt(N+1);
  rep(i,N){
    cnt.at(A.at(i))++;
    cnt.at(B.at(i))++;
  }
  rep(i,N+1){
    if(cnt.at(i) > N){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  vector<pair<int,pair<int,pair<int,int>>>> X(N+1);
  rep(i,N+1)  X.at(i) = m_p(0, m_p(0, m_p(0, i)));
  rep(i,N){
    X.at(A.at(i)).fi++;
    X.at(A.at(i)).se.fi++;
    X.at(B.at(i)).fi++;
    X.at(B.at(i)).se.se.fi++;
  }
  sort(all(X));
  reverse(all(X));

  vector<int> c,d;
  rep(i,N){
    int tmp = X.at(i).se.se.se;
    rep(j,X.at(i).se.fi)  c.e_b(tmp);
    rep(j,X.at(i).se.se.fi) d.e_b(tmp);
  }
  debug_vec(c);
  debug_vec(d);

  int r = 0;
  rep(i,N){
    if(c.at(i) != d.at(i))  continue;
    if(i == N-1)  break;
    chmax(r,i+1);

    while(c.at(i) == d.at(r)){
      r++;
      if(r >= N) break;
    }
    if(r >= N) break;
    swap(d.at(i), d.at(r));
  }
  int l=0;
  for(int i=N-1;i>=0;i--){
    if(c.at(i) == d.at(i)){
      swap(d.at(i), d.at(l));
      l++;
    }
  }

  vector<vector<int>> ans(N+1);
  rep(i,N)  ans.at(c.at(i)).e_b(d.at(i));
  rep(i,N+1){
    rep(j,sz(ans.at(i)))  cout << ans.at(i).at(j) << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 21248
#include <stdio.h>

int main(void) {
  int n,a[101],i,j,z = 0,change;
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&a[i]);
  for(i = 0; i < n; i++){
    for(j = n - 1; j >= i + 1; j--){
      if(a[j] < a[j - 1]){
        change = a[j];
        a[j] = a[j - 1];
        a[j - 1] = change;
        z++;
      }
    }
  }
  for(i = 0; i < n; i++){
    if(i != 0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",z);
  return 0;
}


Measured memory_bytes: 2104
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

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


	public void exec() throws Exception{
		final long N = sc.nextLong();
		if(N%2==1) {
			out.println(0);
			return;
		}
		if(N<100) {
			out.println(N/10);
			return;
		}
		long div = 10;
		long sum = 0;
		while(N>div) {
			sum += N/div;
			div*=5;
		}
		if(N==div) {
			sum++;
		}
		out.println(sum);
		/*
		final long N = sc.nextLong();
		if(N%2==1) {
			out.println(0);
			return;
		}
		if(N<100) {
			out.println(N/10);
			return;
		}
		long n = N / 2;
		long div = 5;
		long sum = 0;
		long ord = 1;
		while(N>ord) {
			sum += n/div;
			div *=5;
			ord *=10;
		}
		if(N==ord) {
			sum++;
		}else {
			sum--;
		}
		err.println(N+","+n+","+div+","+ord);
		out.println(sum);
		*/
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> p;
  for (int i = 0; i < K; i++) {
    int l, r;
    cin >> l >> r;
    p.push_back(make_pair(l, r));
  }

  vector<ll> dp(2 * N + 1, 0);
  dp[1] = 1;
  for (int i = 1; i < N; i++) {
    dp[i] += dp[i - 1];
    dp[i] %= mod;
    for (auto j : p) {
      dp[i + j.first] += dp[i];
      dp[i + j.second + 1] -= dp[i];
      dp[i + j.first] %= mod;
      if (dp[i + j.second + 1] < 0) dp[i + j.second + 1] += mod;
    }
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  for (int x=N;x<1000;x++) {
    if (x%10==(x%100-x%10)/10 && x%10==x/100) {
      cout << x << endl;
      break;
    }
  }
}

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

int main() {
	
	int n;
	cin>>n;
	vector<int>dp(3,0);
    vector<int>newdp(3,0);
    	for(int i=0;i<n;i++)
	{vector<int> inp(3,0);
    
		for(int j=0;j<3;j++)
		{
			cin>>inp[j];
		}
		for(int k=0;k<3;k++)
		{newdp[k]=inp[k];
			for(int l=0;l<3;l++)
			{if(k!=l)
				newdp[k]=max(newdp[k],inp[k]+dp[l]);
			}
			
		}
        dp=newdp;
	}
    
	cout<<*max_element(dp.begin(),dp.end())<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#072_C
n = int(input())
a = list(map(int, input().split()))
sa = [0 for _ in range(0, 100001)]
for ai in a:
    sa[ai] += 1
    
ans = 0
for i in range(1, 100000):
    ans = max(ans, sa[i-1] + sa[i] + sa[i+1])
    
print(ans)

Measured memory_bytes: 13964
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define MAX_N (1000000)

QWORD aqwPhi[MAX_N + 1];
QWORD aqwFareyTable[MAX_N + 1];

void calcPhiTable()
{
	REP(i, 0, MAX_N + 1) aqwPhi[i] = i;

	REP(i, 2, MAX_N + 1) {
		if (aqwPhi[i] == i) { //iが素数の時
			for (int multiNum = i; multiNum <= MAX_N + 1; multiNum += i) {
				aqwPhi[multiNum] = aqwPhi[multiNum] / i * (i - 1);
			}		
		}
	}

}

void solve_main()
{
	calcPhiTable();

	aqwFareyTable[1] = 2;
	REP(i, 2, MAX_N + 1) aqwFareyTable[i] = aqwFareyTable[i - 1] + aqwPhi[i];

	int T;
	cin >> T; 

	REP(i, 0, T) {
		int temp;
		cin >> temp;
		
		cout << aqwFareyTable[temp] << endl;
	}


}


int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 18704
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 1000000007

int C[200000],dp[200001],p[200001];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&C[i]);

    fill(p,p+200001,-1);
    dp[0] = 1;
    for (i = 0; i < N; i++) {
        dp[i+1] = dp[i];
        if ((p[C[i]] != -1) && (p[C[i]] < i-1)) dp[i+1] += dp[p[C[i]]+1];
        dp[i+1] %= MOD;
        p[C[i]] = i;
    }
    printf("%d\n",dp[N]);

    return 0;
}



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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    map<ll, ll> dp[N + 1];
    dp[0][0] = 0;
    for (ll i = 1; i <= N; ++i)
    {
        for (ll j = 0; j < i; ++j)
        {
            for (ll k = w[0] * j; k <= w[0] * j + 3 * j; ++k)
            {
                if (dp[i - 1].find(k) != dp[i - 1].end())
                {
                    if (dp[i - 1].find(k + w[i - 1]) != dp[i - 1].end())
                    {
                        dp[i][k + w[i - 1]] = max(dp[i - 1][k + w[i - 1]], dp[i - 1][k] + v[i - 1]);
                    }
                    else
                    {
                        dp[i][k + w[i - 1]] = dp[i - 1][k] + v[i - 1];
                    }

                    if (dp[i].find(k) == dp[i].end())
                    {
                        dp[i][k] = dp[i - 1][k];
                    }
                }
            }
        }
    }
    ll ans = 0;
    REPV(it, dp[N])
    {
        if (it->first <= W)
        {
            ans = max(ans, it->second);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, i;
      cin >> n;
      lld A[n];
      lld f;
      f = 1;
      foi(i, n)
      {
      	cin >> A[i];
      	if (A[i]%2 == 0)
      	{
      		if (A[i]%3!=0 && A[i]%5!=0)
      		{
      			f = 0;
      		}
      	}
      }
      if (f == 1)
      	cout << "APPROVED";
      else
      	cout << "DENIED";
      return 0;
}

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

using namespace std;

const int maxn = 5e5 + 10;
bool vis[maxn];
vector<int> prime;

void init()
{
  vis[0] = vis[1] = true;
  for(int i = 2; i * i < maxn; i ++)
  {
    if(!vis[i])
      for(int j = i * i; j < maxn; j += i) vis[j] = true;
  }
  for(int i = 2; i < maxn; i ++ ) if(!vis[i]) prime.push_back(i);
}

int main()
{
  init();
  int x;
  scanf("%d", &x);
  int y = lower_bound(prime.begin(), prime.end(), x) - prime.begin();
  printf("%d\n", prime[y]);
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) { cin >> h[i]; }
  sort(begin(h), end(h));
  rep(i, n - k) { ans += h[i]; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#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

int cnt[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[200010];
    rep(i, N) cin >> A[i];
    rep(i, N) cnt[A[i]]++;
    int kind = 0;
    rep(i, 200001) if(cnt[i] > 0) kind++;
    sort(cnt, cnt + 200001, greater<int>());
    int n = 200001;
    int ans = 0;
    while(kind > K) {
        n--;
        if(cnt[n] == 0) continue;
        ans += cnt[n];
        kind--;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 5050;

ll n, k, p[N];
ll c[N];

int main() { 
	scanf("%lld%lld", &n, &k);
	for(int i = 1;i <= n; ++i) scanf("%lld", &p[i]);
	for(int i = 1;i <= n; ++i) scanf("%lld", &c[i]);
	ll ans = -0x3f3f3f3f3f3f3f3f;
	for(int i = 1;i <= n; ++i) {
		ll tmp = 0; int now = i, tot = 0;
		do {
			tot++; 
			now = p[now];
			tmp += c[now];
			ans = max(ans, tmp);
		} while(now != i && tot < k);
		if(tot <= k) {
			int d = k / tot, x = tot;
			tot = k % tot;
			if(d > 1) {
				tmp = tmp * (d - 1);
				ans = max(ans, tmp);
				tot += x;
			}
		} else tot = 0;
		while(tot--) {
			ans = max(ans, tmp);
			now = p[now];
			tmp += c[now];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3836
import java.util.*;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() , d = sc.nextInt() , x = sc.nextInt();
		int[] A = new int[n];
		for(int i=0;i<n;i++){
			A[i]=sc.nextInt();
		}
		int answer=x;
		for(int i=0;i<n;i++){
			answer=answer+(d-1)/A[i]+1;
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<string> va(n);
  rep(i, n) cin >> va[i];
  int m;
  cin >> m;
  vector<string> vb(m);
  rep(i, m) cin >> vb[i];

  int ans = 0;
  rep(i, n){
    int now = 0;
    string t = va[i];
    rep(j, n) if(va[j] == t) now++;
    rep(k, m) if(vb[k] == t) now--;
    if(now > ans) ans = now;
  }
  cout << ans << endl;
}


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

#define N 100009
bool prohibited[ N ];
int dp[ N ], md = 1e9 + 7;

int mod( int a ){
    return a % md;
}

int main(){
    int n, m, ar[ N ];
    cin >> n >> m;
    for( int i = 1; i <= m; i++ ) {
        cin >> ar[i];
        prohibited[ar[i]] = 1;
    }

    dp[ 0 ] = 1;
    dp[ 1 ] = ( prohibited[1] ) ? 0 : 1;

    for( int i = 2; i <= n; i++ )
        dp[ i ] = (prohibited[i]) ? 0 : mod(dp[ i - 1 ] + dp[ i - 2 ]);

//    for( int i = 0; i <= n; i++ )
//        cout << dp[ i ] << " ";

    cout << dp[ n ];

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <stack>
#include <queue>
#include <string>

using namespace std;
int main(){
	stack<int> s;
	int n;
	string word;
	int kake,hiku,tasu,kekka;
	kekka=0;
	tasu=0;
	hiku=0;
	while(cin >> word){
		if(word=="+"){
			tasu=s.top();
			s.pop();
			tasu=tasu+s.top();
			s.pop();
			s.push(tasu);
			
		}else if(word=="-"){
			hiku=s.top();
			s.pop();
			hiku=s.top()-hiku;
			s.pop();
			s.push(hiku);
			
		}else if(word=="*"){
			kake=s.top();
			s.pop();
			kake=kake*s.top();
			s.pop();
			s.push(kake);
			
		}else{
			n=stoi(word);
			s.push(n);
		}
	}
	
	cout << s.top() << endl;
	
	
	return 0;
}

Measured memory_bytes: 3144
//https://atcoder.jp/contests/abc163/tasks/abc163_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll m;
	cin>>m;
	vector <ll> p;
	p.resize(m);
	ll i;
	for(i=0;i<m;i++)
	{
		cin>>p[i];
		n=n-p[i];
	}
	if(n==0)
	{
		cout<<"0"<<"\n";
	}
	else if(n<0)
	{
		cout<<"-1"<<"\n";
	}
	else
	{
		cout<<n<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 3672
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-01 15:38:02
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

class Combination {
 public:
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 2000 + 5;

  Combination() { build(); }

  std::array<int64, n_> fact_;
  std::array<int64, n_> inv_;
  std::array<int64, n_> finv_;

  // return nCk
  int64 get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return fact_[n] * (finv_[k] * finv_[n - k] % mod_) % mod_;
  }

 private:
  void build() noexcept {
    fact_[0] = 1;
    fact_[1] = 1;
    finv_[0] = 1;
    finv_[1] = 1;
    inv_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      fact_[i] = fact_[i - 1] * i % mod_;
      inv_[i] = mod_ - inv_[mod_ % i] * (mod_ / i) % mod_;
      finv_[i] = finv_[i - 1] * inv_[i] % mod_;
    }
  }
};

Combination kyomu;

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

  int n, k; cin >> n >> k;
  if (n < k) {
    cout << 0 << endl;
  } else {
    cout << kyomu.get(n - 1, n - k) << endl;
  } 

  return 0;
}


Measured memory_bytes: 3256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int A, B;
    cin >> A >> B;
    if (A <= 9 && B <= 9) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a[3][101],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      cin>>n;
      rep(i,2)rep(j,n)cin>>a[i][j];
      rep(i,n){
          rep(j,i+1){
              cnt+=a[0][j];
          }
          rrep(j,i,n){
              cnt+=a[1][j];
          }
          ans=max(ans,cnt);
          cnt=0;
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


import numpy as np

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

    
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct



s=factorize(float(input()))

res=0

for ss,n in s:
    tmp=np.floor((np.sqrt(8*n+1)-1)/2)
    #print(tmp)
    res+=tmp

print(int(np.floor(res)))

#print(s)

Measured memory_bytes: 27164
n, d = map(int, input().split())
count = 0
x_list = [list(map(int, input().split())) for _ in range(n)]

for i in range(n-1):
    for j in range(i+1, n):
        count += (sum((a-b)**2 for a,b in zip(x_list[i], x_list[j]))**0.5).is_integer()
print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	bool array[30]={false};
	string input;
	cin >> input;
	for(int i=0;i<input.size();i++){
		array[input[i]-97]=true;
	}//a=0 b=1 ...
	for(int i=0;i<26;i++){
		if(!array[i]){
			char a=i+97;
			cout << a << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}


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

const long MOD=1000000007;
int main(){
    long H,W,K;
    cin>>H>>W>>K;
    
    vector<long> F(W+2);
    F.at(0)=1;
    F.at(1)=1;
    for(int i=2;i<W+2;i++){
        F.at(i)=F.at(i-1)+F.at(i-2);
    }
    
    vector<vector<long>> dp(H+1,vector<long>(W,0));
    dp.at(0).at(0)=1;
    
    for(int h=1;h<=H;h++){
        for(int w=0;w<W;w++){
            if(w>0) dp.at(h).at(w)+=dp.at(h-1).at(w-1)*F.at(w-1)*F.at(W-w-1);
            if(w<W-1) dp.at(h).at(w)+=dp.at(h-1).at(w+1)*F.at(w)*F.at(W-w-2);
            dp.at(h).at(w)+=dp.at(h-1).at(w)*F.at(w)*F.at(W-w-1);
            dp.at(h).at(w)%=MOD;
        }
    }
    
    cout<<dp.at(H).at(K-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }
#define pb push_back
#define vi vector<int>
#define vii vector<<int>>
#define mii map<int, int>
#define pii pair<int, int>
#define qii priority_que<int, vector<int>, greater<int>>				
#define For(i, n) for(int i = 0; i < n; ++i)
#define For1(i, n) for(int i = 1; i <= n; ++i)
#define Forlr(i, l, r) for(int i = l; i <= r; ++i)
#define Forrl(i, r, l) for(int i = r; i >= l; --i)
using ll = long long;
int n, m, k, q;
const int INF = 1e9 + 5;
const int nax = 1e5 + 5;

void solve() {
	mii ma;
	int x;
	cin >> x >> n;
	vi a(n);
	For(i, n){
		cin >> a[i];
	}
	Forlr(i, -400, 400){
		ma[i] = 1;
	}
	For(i, n){
		ma[a[i]] = 0;
	}
	int rs = 1e9, ans = 0;
	Forlr(i, -400, 400){
		if(ma[i]){
			if(rs > abs(x - i)){
				rs = abs(x - i);
				ans = i;
			}
		}
	}
	cout << ans;
}

int main()
{
	fast();
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	
}

Measured memory_bytes: 3700
n, m = map(int, input().split())
h = list(map(int, input().split()))
is_good = []
for i in range(n):is_good.append(1)
for i in range(m):
  a, b = map(int, input().split())
  #print(h[a-1], h[b-1])
  if  (h[a-1] > h[b-1]):is_good[b-1] = 0
  elif(h[a-1] < h[b-1]):is_good[a-1] = 0
  else:
    is_good[b-1] = 0
    is_good[a-1] = 0

ans = 0
for i in is_good:
  if(i):ans+=1
print(ans)
  

Measured memory_bytes: 84728
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				int k = n - i - j;
				if (10000 * i + 5000 * j + 1000 * k == y) {
					System.out.println(i + " " + j + " " + k);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}

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

using namespace std;
typedef long long ll;
ll f[3005][3005][4];
ll a[3005][3005],val;
int n,m,k,x,y;
int main()
{
    scanf("%d %d %d",&n,&m,&k);
    memset(f,0,sizeof f);
    for(int i=1;i<=k;i++)
    {
        scanf("%d %d %lld",&x,&y,&val);
        a[x][y]+=val;
        f[x][y][1]+=val;
    }
    //for(int i=0;i<4;i++) f[0][0][i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            for(int p=0;p<=min(j,3);p++)
            {

                for(int l=0;l<=min(j,3);l++) f[i][j][p]=max(f[i][j][p],f[i-1][j][l]+a[i][j]);
                if(j-1>=0&&(p-2)>=0) f[i][j][p]=max(f[i][j][p],f[i][j-1][p-1]+a[i][j]);
                if(i-1>=0&&(p-1)>=0) f[i][j][p]=max(f[i][j][p],f[i-1][j][p]);
                if(j-1>=0&&(p-1)>=0) f[i][j][p]=max(f[i][j][p],f[i][j-1][p]);
                //cout<<i<<" "<<j<<" "<<p<<" "<<f[i][j][p]<<endl;
            }

        }
    }
    ll mx=0;
    for(int i=0;i<4;i++) mx=max(mx,f[n][m][i]);
    printf("%lld\n",mx);
    return 0;
}

/*

1 4 4
1 1 3
1 2 1
1 3 4
1 4 2
9
*/


Measured memory_bytes: 356296
module mod1
implicit none
integer :: par(0:100000)
end module mod1
 
program test
use mod1
implicit none
integer :: n,m,i,j,k,count=0
integer :: p(200000),x(200000),y(200000)
 
read(*,*) n,m
read(*,*) (p(i),i=1,n)
do i=1,m
	read(*,*) x(i),y(i)
enddo
 
!親の番号
do i=0,n
	par(i) = i
enddo

!連結していく
do i=1,m
	call unite(x(i),y(i))
enddo

!判定する
do i=1,n
	if(same(i,p(i)) == 1)then
		count = count + 1
	endif
enddo

write(*,*) count

contains
recursive function root(x) result(res)
integer :: x,res
	if(par(x) == x) then
		continue
	else
		par(x) = root(par(x))
	endif
	res = par(x)
end function

subroutine unite(x,y) !連結
integer :: x,y
x = root(x)
y = root(y)
if(x .ne. y) then
	par(x) = y
endif
end subroutine
 
 
function same(x,y) !判定
integer :: x,y,same
if(root(x) .eq. root(y)) then
	same = 1
else
	same = 0
endif
end function
 
end program test

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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



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

    int ans=0, cnt1=0, cnt2=0;
    cnt1+=(s[0]=='L')+(s[n-1]=='R');
    for(int i=0; i+1<n; i++){
        if(s[i] == 'R' && s[i+1] == 'L') cnt2++;
    }
    if(cnt1 == 0){
        if(k < cnt2) ans=n-(cnt2-k)*2;
        else ans=n-1;
    }
    else{
        if(k <= cnt2) ans=n-(cnt2-k)*2-cnt1;
        else ans=n-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {
    string a,b,c;
    cin>>a>>b>>c;

    int num=0;

    while(true){
        if(num == 0){
            if(a.size() == 0){
                cout<<"A"<<endl;
                break;
            }
                num = a[0] - 'a';
                a = a.substr(1);
        }
        else if(num ==1){
            if(b.size() == 0){
                cout<<'B'<<endl;
                break;
            }
                num = b[0] - 'a';
                b = b.substr(1);
        }
        else if(num ==2){
            if(c.size() == 0){
                cout<<'C'<<endl;
                break;
            }
                num = c[0] - 'a';
                c = c.substr(1);
        }
    }

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(){
  char num[1001];
  
  while(1){
    scanf("%s", num);
    if( num[0] == '0' ) break;
    int sum = 0;
    for( int i = 0; i < strlen(num); i++ ){
      sum += (num[i]-'0');
      // ??¢?????????????????????????????¨??£???????????????0??¨
      // ??????????????????????????????????????£?????°??????????????????
    }
    printf("%d\n", sum);
  }
  
  return 0;
}

Measured memory_bytes: 964
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	while(cin>>n,n){
		vint v(10,0);
		rep(i,n){
			int t;
			cin>>t;
			v[t]++;
		}
		rep(i,10){
			if(v[i]==0){
				cout<<"-"<<endl;
			}
			else{
				rep(j,v[i]){
					cout<<"*";
				}
				cout<<endl;
			}
		}
	}
}

Measured memory_bytes: 1184
from string import ascii_lowercase

s = input()

result = len(s)

for c in ascii_lowercase:
    t = s

    count_c = t.count(c)
    if count_c == 0:
        continue

    n_operations = 0

    while len(t) > count_c:
        t_next = [None] * (len(t) - 1)
        count_c_next = 0
        for i in range(len(t_next)):
            if t[i] == c or t[i + 1] == c:
                t_next[i] = c
                count_c_next += 1
            else:
                t_next[i] = '0'
        t = t_next
        count_c = count_c_next
        n_operations += 1

    result = min(result, n_operations)

print(result)

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    string str=s;
    reverse(str.begin(),str.end());
    if(s!=str)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int n=s.length();
    string s1=s.substr(0,((n-1)/2));
    string s2=s.substr(((n+3)/2)-1);
    string sr1=s1;
    reverse(s1.begin(),s1.end());
    string sr2=s2;
    reverse(s2.begin(),s2.end());
    if(s1==sr1 && s2==sr2)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inf = 100100;
int main() {
  int n;
  cin >> n;
  vector<int> m(100100);
  int maxi=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i); 
  }
  
  for(int i=0;i<n;i++){
    if(maxi < a.at(i)){
      maxi = a.at(i);
    }
  }
  
  for(int i=0;i<n;i++){
    m.at(a.at(i))++;
  }
  
  ll initial=0;
  for(int i=0;i<inf;i++){
    initial += i*m.at(i);
  }
  //cout << initial << endl;
  
  ll sum = initial;
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int b,c;
    cin >> b >> c;
    sum += (c-b)*m.at(b);
    m.at(c) += m.at(b);
    m.at(b) = 0;
    cout << sum << endl;
  }

  return(0);
}

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

#define MAX 11

int main(){
  int n,t;
  int a[MAX],b[MAX],c[MAX],d[MAX];
  char s[MAX][100],tmp[MAX][100];
  char hoge[MAX][100];

  scanf("%d %d",&n,&t);
  for(int i=0; i<n; i++){
    scanf("%d:%d %s %d:%d %s",&a[i],&b[i],s[i],&c[i],&d[i],tmp[i]);
  }

  int ans=0;
  for(int i=0; i<n-1; i++){
    if( (a[i+1]*60+b[i+1]) - (c[i]*60 + d[i]) >= t) ans++;
  }
  cout << ans << endl;
  for(int i=0; i<n-1; i++){
    int x =  (a[i+1]*60+b[i+1]) - (c[i]*60+d[i]);
    if( x >= t )
      printf("%s %d\n",s[i+1],x);
  }



}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
long long s(long long n) {
    if (n < 10) return n;
    else 
    {
        long long d = 0, m = n, sum = 0, k, l;
        while (m != 0)
        {
            d++;
            m /= 10;
        }
        sum += n;
        for (long long i = 0; i < d - 1; ++i)
        {
            k = floor(pow(10, i + 1));
            l = floor(pow(2, d - i - 2));
            sum += (n % k) * l + s(n / k);
        }
        return sum;
    }    
    
}
int main() {
    long long n;
    cin >> n;
    cout << s(n);
}

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

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N;
    vector<string> v;

    for (int i = 0; i < N; i++)
    {
        cin >> S;
        v.push_back(S);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    cout << v.size();
}

Measured memory_bytes: 11664
a=list(input())
ans=0
b=a[0::2]
c=a[1::2]
for i in range(len(b)):
  if b[i]!='L':
    ans+=1
for i in range(len(c)):
  if c[i]!='R':
    ans+=1
if ans==len(a):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;


int n,m;
int a[50],b[50];

bool graph[50][50];
bool visited[50];

void dfs(int v){

    visited[v] = true;
    REP(i,n){

        if(graph[v][i] == false){//隣接していない
            continue;
        }
        if(visited[i] == true){//既に行った
            continue;
        }
        dfs(i);
    }    
}

int main(){

    cin  >> n >> m;

    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    REP(i,m){

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;//隣接を切る

        REP(j,n){
            visited[j] = false;
        }
        
        dfs(0);

        bool bridge = false;

        REP(j,n){

            if(visited[j] == false){
                bridge = true;
            }
        }

        if(bridge){
            ans++;
        }

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 10;
int a[maxn];
int main()
{
  int n , k;
  scanf("%d%d",&n,&k);
  for(int i = 0 ; i < n ; i++) scanf("%d",&a[i]);
  int ans = 0;
  for(int i = 1 ; i <= min(k,n); i++) // 取i个
  {
    for(int j = 0 ; j <= i ; j++) // 左边j个 右边 i-j个
    {
      int sum = 0;
      vector<int>v;
      for(int l = 0 ; l < j ; l ++) v.push_back(a[l]) , sum += a[l];
      for(int l = n - 1 ; l >= n - (i - j); l--) v.push_back(a[l]) , sum += a[l];
      sort(v.begin(),v.end());
      //printf("%d \n",i);
      //for(int m : v) cout<<m<<" ";puts("");
      for(int l = 0 ; l < k - i ; l++)
      {
        if(v[l] < 0) sum -= v[l];
      }
      ans = max(ans,sum);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
class Heap
  attr_reader :size
  def initialize
    @heap = []
    @size = 0
  end
  def sum
    @heap.inject(:+)
  end
  def push(n)
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    top
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
a = input_a

q = Heap.new

a.each do |num|
  q.push(-num)
end

m.times do |i|
  max = q.pop
  max = -(-max / 2)
  q.push(max)
end

sum = 0
while q.size != 0
  sum += -q.pop
end
puts sum

Measured memory_bytes: 9556
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int array[16];
	int state,sum_cost,used_num;
};

int N,M;
int POW[17];
int dp[65536];
int futon[16],demand[101];

void func(){

	futon[0] = 0;
	for(int i = 1; i <= N; i++)scanf("%d",&futon[i]);
	demand[0] = 0;
	for(int i = 1; i <= M; i++)scanf("%d",&demand[i]);

	sort(demand,demand+(M+1));

	N++;

	for(int i = 0; i < POW[N]; i++)dp[i] = BIG_NUM;

	Info first;
	first.state = 0;
	first.used_num = 0;
	first.sum_cost = 0;

	queue<Info> Q;

	Q.push(first);

	int tmp_sum,next_state;

	while(!Q.empty()){

		if(Q.front().used_num == N){
			Q.pop();
		}else if(Q.front().sum_cost > dp[Q.front().state]){
			Q.pop();
		}else{

			for(int loop = 0; loop < N; loop++){
				if(Q.front().state & (1 << loop)){
					//Do noghint
				}else{
					Info next_info;
					for(int i = 0; i < Q.front().used_num; i++)next_info.array[i] = Q.front().array[i];
					next_info.array[Q.front().used_num] = futon[loop];

					if(Q.front().used_num > 0){
						next_info.array[Q.front().used_num] += next_info.array[Q.front().used_num-1];
					}
					int index = 0;
					tmp_sum = 0;
					for(int i = 1; i <= M; i++){
						while(index < Q.front().used_num && abs(demand[i]-next_info.array[index]) > abs(demand[i]-next_info.array[index+1]))index++;
						tmp_sum += abs(demand[i]-next_info.array[index]);
					}

					next_state = Q.front().state + POW[loop];

					if(dp[next_state] > tmp_sum){
						dp[next_state] = tmp_sum;
						next_info.state = next_state;
						next_info.sum_cost = tmp_sum;
						next_info.used_num = Q.front().used_num+1;
						Q.push(next_info);
					}
				}
			}
			Q.pop();
		}
	}

	printf("%d\n",dp[POW[N]-1]);
}


int main(){

	for(int i = 0; i < 17; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}
	return 0;

}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a > b) cout << "a > b" << endl;
    else if(a == b) cout << "a == b" << endl;
    else cout << "a < b" << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

int N,A,B,C,D;
map<int,int>dp;
int solve(int n){
	if( n == 0 ) return 0;
	if( n == 1 ) return D;
	if( dp.count(n) )return dp[n];
	if( __builtin_mul_overflow(n,D,&dp[n]) ){
		dp[n] = 1e18;
	}
	int x = (n/2)*2;
	int X = ((n+1)/2)*2;
	int y = (n/3)*3;
	int Y = ((n+2)/3)*3;
	int z = (n/5)*5;
	int Z = ((n+4)/5)*5;
	
	dp[n] = min( dp[n] , D * abs(x-n) + A + solve(x/2) );
	dp[n] = min( dp[n] , D * abs(X-n) + A + solve(X/2) );
	
	dp[n] = min( dp[n] , D * abs(y-n) + B + solve(y/3) );
	dp[n] = min( dp[n] , D * abs(Y-n) + B + solve(Y/3) );
	
	dp[n] = min( dp[n] , D * abs(z-n) + C + solve(z/5) );
	dp[n] = min( dp[n] , D * abs(Z-n) + C + solve(Z/5) );
	
	return dp[n];
}
		
int32_t main(){
	IOS
	int t;cin>>t;
	while( t-- ){
		dp.clear();
		cin >> N >> A >> B >> C >> D;
		cout << solve(N) << endl;
	}
	

}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
const double eps = 1e-6;

ll a[N],b[N];

int main() {
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]);
	
	ll now = 1000ll;
	for(int i = 1;i < n;++i){
		if(a[i] < a[i+1])
			now = (now%a[i]+now/a[i]*a[i+1]);
	}
	
	printf("%lld\n",now);
    return 0;
}


Measured memory_bytes: 3816