akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int N, M, Q;
  cin >> N >> M >> Q;
  vi l(200009), r(200009);
  vvi x(509, vi(509, 0)), c(509, vi(509, 0));

  for (int i = 1; i <= M; i++)
  {
    cin >> l.at(i) >> r.at(i);
    x.at(l.at(i)).at(r.at(i))++;
  }
  for (int i = 1; i <= N; i++)
  {
    for (int j = 1; j <= N; j++)
    {
      c.at(i).at(j) = c.at(i).at(j - 1) + x.at(i).at(j);
    }
  }
  vi ans(Q, 0);
  rep(i, Q)
  {
    int p, q;
    cin >> p >> q;
    for (int j = p; j <= q;j++){
      ans.at(i) += c.at(j).at(q) - c.at(j).at(p - 1);
    }
  }
  rep(i, Q) cout << ans.at(i) << endl;

  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
typedef pair<int,pii>piii;
int n,m;
char a[1010][1010];
int d[1010][1010];
bool outboard(int x,int y){
	return x<1||x>n||y<1||y>m;
}
void dijkstra(int sx,int sy){
	set<piii>pq;
	memset(d,INF,sizeof d);
	d[sx][sy]=0;
//	d[s]=0;
	pq.insert(mp(0,mp(sx,sy)));
	while(!pq.empty()){
		pii v=pq.begin()->S;
		pq.erase(pq.begin());
		int x=v.F,y=v.S;
		for(int i=x-2;i<=x+2;i++)
			for(int j=y-2;j<=y+2;j++){
				if(outboard(i,j)||a[i][j]=='#')continue;
				int tp;
				if(abs(i-x)+abs(j-y)==1)tp=0;
				else tp=1;
                if(d[i][j]>d[x][y]+tp){
					d[i][j]=d[x][y]+tp;
					pq.insert(mp(d[i][j],mp(i,j)));
                }
			}
//		for(int i=0;i<G[v].size();i++){
//			pii e=G[v][i];
//			int p=e.S,to=e.F;
//			if(d[to]>d[v]+p){
//				d[to]=d[v]+p;
//				pq.insert(mp(d[to],to));
//			}
//		}
	}
}
int main(){
	cin>>n>>m;
	int sx,sy,ex,ey;
	cin>>sx>>sy>>ex>>ey;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
//	dfs(sx,sy,0);
	dijkstra(sx,sy);
	if(d[ex][ey]==INF)puts("-1");
	else cout<<d[ex][ey]<<endl;
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=m;j++)cout<<dis[i][j]<<' ';
//		puts("");
//	}
	return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int h, w, d;
	cin >> h >> w >> d;

	vector<vector<int>> a(h, vector<int>(w));
	map<int, pair<int, int>> mp;
	rep (i, 0, h) {
		rep (j, 0, w) {
			cin >> a[i][j];
			mp[a[i][j]] = make_pair(i, j);
		}
	}

	vector<int> cum_sum(h * w + 1, 0);
	rep (i, d + 1, h * w + 1) {
		cum_sum[i] = cum_sum[i - d]
			+ abs(mp[i].first - mp[i - d].first)
			+ abs(mp[i].second - mp[i - d].second);
	}

	int q;
	cin >> q;

	int l, r;
	rep (i, 0, q) {
		cin >> l >> r;

		ll magic_cost = cum_sum[r] - cum_sum[l];
		cout << magic_cost << endl;
	}

	return 0;
}


Measured memory_bytes: 7424
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const i64 inf = 1e15;


int main()
{
	int n;
	i64 x;
	i64 ans = inf;
	vector<i64> as;

	scanf("%d%lld", &n, &x);
	as.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%lld", &as[i]);

	vector<i64> mincost = as;

	for(int step = 0; step < n; ++step) {

		i64 cost = 0;

		for(int t = 0; t < n; ++t)
			mincost[t] = min(mincost[t], as[(t + step) % n]);
		for(int t = 0; t < n; ++t)
			cost += mincost[t];

		ans = min(ans, cost + step * x);
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i==0 || i==H-1 || j==0 || j==W-1){
                    cout << "#";
                }else{
                    cout << ".";
                }
                
            }
            cout << endl;
        } cout << endl;
        
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;

typedef unsigned long long ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN = 150;
const int MAXW = 1e5 + 5;
const int MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

int add(int x, int y) { return ((x % MOD)  + (y % MOD)) % MOD;             }
int mul(int x, int y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;   }
int sub(int x, int y) { return add(x, -y + MOD);                           }

ll n, W, w[MAXN], v[MAXN];

ll dp[MAXN][MAXW];

ll solve(ll x, ll curW) {
	if(curW < 0) return -INF;
	if(x == 0 || curW == 0) return 0;
	if(dp[x][curW] != -1) return dp[x][curW];
	return dp[x][curW] = max(v[x] + solve(x - 1, curW - w[x]), solve(x - 1, curW));
}

void init() {
	
	for(int i = 1; i <= n; ++i) {
		for(int j = 0; j <= W; ++j) {
			if(j - w[i] >= 0) dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j]);
			else dp[i][j] = dp[i - 1][j];
		}
	}

}

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

	cin >> n >> W;



	for(int i = 1 ; i <= n ; ++i) {
		cin >> w[i] >> v[i];
	}

	
	init();
		
	cout << dp[n][W] << endl;



	return 0;
}




Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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;
}

const ll INF = 1LL << 60;

int main() {
    int N,M;
    cin >> N >> M;
    vector<bool> broken(N+1);
    rep(i,M) {
        int a;
        cin >> a;
        broken.at(a)=true;
    }

    vector<int> dp(N+2);
    const int mod = 1000000007;
    dp.at(N)=1;
    for(int i=N-1;i>=0;i--) {
        if(broken.at(i)) {
            dp.at(i)=0;
            continue;
        }
        dp.at(i)=(dp.at(i+1)+dp.at(i+2))%mod;
    }
    
    cout << dp.at(0) << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;



const ll md = 998244353;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
  ll n;
  cin>>n;

  int N = n+10;
  vector<ll> inv(N,1), fac(N, 1), ifac(N, 1), pw2(N,1), pw3(N,1);
  rep(i,2,N) {
    inv[i] = md - (md / i) * inv[md % i] % md;
    fac[i] = fac[i-1] * i % md;
    ifac[i] = ifac[i-1] * inv[i] % md;
    pw2[i-1] = pw2[i-2] * 2 % md;
    pw3[i-1] = pw3[i-2] * 3 % md;
  }
  auto binom = [&](ll n, ll k) {
    if(k < 0 || k > n) return 0LL;
    return fac[n] * ifac[k] % md * ifac[n-k] % md;
  };

  ll ans = pw3[n];
  rep(i,0,n) {
    if(2*i <= n) continue;
    ll cur = pw2[n-i] * binom(n,i) % md;
    ans = (ans - 2*cur + 2*md) %md;
  }

  ans = (ans-2 + md) % md; // why?

  cout << ans << endl;
}


Measured memory_bytes: 390912
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n;
    cin >> n;
    cout << n/3 << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

void insertion_sort(vi &a, int n, int g, int &count) {
  for (int i = g; i < n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      count++;
    }

    a[j + g] = v;
  }
}

void shell_sort(vi &a, int n) {
  int count = 0;
  int m = n;
  vi g;
  while (m != 0) {
    m /= 2;
    if (m > 0) g.push_back(m);
  }
  if (!g.size()) g.push_back(1);
  
  m = g.size();
  cout << m << endl;
  
  rep(i, m) {
    insertion_sort(a, n, g[i], count);

    cout << g[i];
    i != m - 1 ? (cout << " ") : (cout << endl);
  }
  
  cout << count << endl;
  
  for (auto i: a) cout << i << endl;
}

int main() {
  int n;
  cin >> n;

  vi a(n);
  rep(i, n) cin >> a[i];

  shell_sort(a, n);
}



Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;
    cin>>s;
    bool f=false;
    if(s.at(5)=='0'){
        if(s.at(6)=='1' || s.at(6)=='2' || s.at(6)=='3' ||s.at(6)=='4'){
            f=true;
        }
    }
    if(f){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main()
{
  int N;
  scanf("%d", &N);
  int v[N];
  unordered_map<int, int> ind;
  for(int i=0; i<N; i++)
  {
    scanf("%d", &v[i]);
    ind[v[i]] = i;
  }
  sort(v, v+N);
  int tot = 0;
  for(int i=0; i<N; i++)
   if(i%2 != ind[v[i]]%2)
    tot++;
  printf("%d", tot/2);
  return 0;
}


Measured memory_bytes: 4772
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	string s;
	cin >> s;
	int len=s.size();
	int count=0;

	repd(i,1,len){
		if(s[i-1]==s[i]){
			count++;
			if(s[i]=='0'){
				s[i]='1';
			}else{
				s[i]='0';
			}
		}
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))
#define PI 3.14159265358979

int main()
{
	int sum;
	while(scanf("%d",&sum),sum)
	{
		int i;
		for(i = 0;i < 9;i++)
		{
			int price;
			scanf("%d",&price);
			sum-=price;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        sys.exit()
    if k % 7 == 0:
        l = k * 9 // 7
    else:
        l = k * 9
    r = 1       # カウント
    p = 10 ** r
    while (p % l) != 1:
        p = (p * 10) % l
        r += 1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ld EPS=10e-8;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

vector<vector<ll>> V(100007);
ll chek[100007];

void dfs(ll num,ll T){
    chek[num]=T;
    rep(i,V[num].size()){
        if(chek[V[num][i]]==0){
            dfs(V[num][i],T);
        }
    }
}

int main(){
    ll N,M;cin >> N >> M;
    ll A,B,T=1;
    rep(i,M){
        cin >> A >> B;
        V[A].pb(B);
        V[B].pb(A);
    }
    rep(i,N){
        if(chek[i]==0){
            dfs(i,T);
            T++;
        }
    }
    ll Q;cin >> Q;
    rep(i,Q){
        cin >> A >> B;
        if(chek[A]==chek[B]){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }
}


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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 1e5 + 5;

int a[kN], n;
int Gcd(int x, int y) { return y ? Gcd(y, x % y) : x; }
void Div() {
	int g = a[1];
	for(int i = 2; i <= n; ++i) g = Gcd(g, a[i]);
	for(int i = 1; i <= n; ++i) a[i] /= g;
}

int main() {
	int cur = 0; rd(n);
	for(int i = 1; i <= n; ++i) rd(a[i]);
	while(true) {
		int cnt = 0, ecnt = 0, p; bool flag = false;
		for(int i = 1; i <= n; ++i) {
			if(a[i] % 2 == 0) ++cnt;
			else p = i, ++ecnt;
			if(a[i] == 1) flag = true;
		}
		if(flag) return printf((cnt % 2 == 1) ^ cur ? "First" : "Second"), 0;
		if(cnt % 2 == 1) return printf(cur ? "Second" : "First"), 0;
		if(ecnt > 1 && cnt % 2 == 0) return printf(cur ? "First" : "Second"), 0;
		--a[p]; Div(); cur ^= 1;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> p(m,0);
  vector<string> s(m,"");
  rep(i,m) {
    cin >> p.at(i) >> s.at(i);
  }
  ll ac=0ll;
  ll wa=0ll;
  vector<int> check(n+1,0);
  vector<int> wacount(n+1,0);

  rep(i,m) {
    // AC でない
    if(!check.at(p.at(i))) {
      if(s.at(i) == "AC") {
        check.at(p.at(i)) = 1;
        ac+=1;
        wa+=wacount.at(p.at(i));
      } else {
        wacount.at(p.at(i))++;
      }
    }
  }

  cout << ac << " " << wa << endl;

  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=0;i<=n;++i)
#define INF 100000000
#define MOD 1000000009
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int Q;
int l, r;
int ans;
bool is_prime[100001];
int is_2017prime[100001];

int main(){
    cin >> Q;

    rep(i, 100000) is_prime[i] = 1;
    is_prime[0] = is_prime[1] = 0;
    for(int i=2;i * i <= 100000;++i){
        if(is_prime[i] == 1){
            for(int j = 2 * i;j<= 100000;j += i){
                is_prime[j] = 0;
            }
        }
    }

    is_2017prime[0] = is_2017prime[1] = is_2017prime[2] = 0;

    for(int i=3;i<=100000;++i){
        if(is_prime[i] == 1 && is_prime[(i+1)/2] ==1){
            is_2017prime[i] = is_2017prime[i-1] + 1;
        } else {
            is_2017prime[i] = is_2017prime[i-1];
        }
    }

    REP(i, Q){
        cin >> l >> r;
        cout << is_2017prime[r] - is_2017prime[l-1] << endl;
    }

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

map<ll,ll> mp;

//素因数分解
template <class T>
void prime_factor(T x){
	for(T i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			mp[i]++;
		}
	}
	if (x!=1){
		mp[x]++;
	}
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	FOR(i,1,n+1){
		prime_factor(i);
	}
	ll ans=0;
	vector<ll> cnt(5,0);
	for(auto itr:mp){
		if(itr.se>=74){
			rep(i,5) cnt[i]++;
		}else if(itr.se>=24){
			FOR(i,1,5) cnt[i]++;
		}else if(itr.se>=14){
			FOR(i,2,5) cnt[i]++;
		}else if(itr.se>=4){
			FOR(i,3,5) cnt[i]++;
		}else if(itr.se>=2){
			FOR(i,4,5) cnt[i]++;
		}
	}
	//^74
	ans+=cnt[0];
	//^24*^2
	ans+=cnt[1]*(cnt[4]-1);
	//^14*^4
	ans+=cnt[2]*(cnt[3]-1);
	//^4*^4*^2
	ans+=cnt[3]*(cnt[3]-1)*(cnt[4]-2)/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int a=1;
int n,k;
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
         if(2*a<a+k){
          a=2*a;}
         else{a=a+k;}
}
cout<<a;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;
    cout << t2 - t1 - k << endl;
}


Measured memory_bytes: 3192
from collections import deque


class Dice:
    def __init__(self, *surface):
        self._surface = surface

        self._mapping_sn = deque([0, 1, 5, 4], maxlen=4)
        self._mapping_we = deque([0, 3, 5, 2], maxlen=4)

    @property
    def top(self):
        return self._surface[self._mapping_sn[0]]

    def roll_s(self):
        self._mapping_sn.rotate(1)
        self._mapping_we[0] = self._mapping_sn[0]
        self._mapping_we[2] = self._mapping_sn[2]

    def roll_n(self):
        self._mapping_sn.rotate(-1)
        self._mapping_we[0] = self._mapping_sn[0]
        self._mapping_we[2] = self._mapping_sn[2]

    def roll_w(self):
        self._mapping_we.rotate(1)
        self._mapping_sn[0] = self._mapping_we[0]
        self._mapping_sn[2] = self._mapping_we[2]

    def roll_e(self):
        self._mapping_we.rotate(-1)
        self._mapping_sn[0] = self._mapping_we[0]
        self._mapping_sn[2] = self._mapping_we[2]


if __name__ == '__main__':
    surface = map(int, input().split())
    d = Dice(*surface)
    commands = list(input().lower())
    for c in commands:
        getattr(d, 'roll_' + c)()
    print(d.top)


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

int main()
{
    string s;
    cin>>s;
    bool flag = true;
    for(int i=0;i<s.length(); i++)
    {
        if(i % 2 == 0 && s[i] == 'L') {flag = false;break;}
        if(i % 2 == 1 && s[i] == 'R') {flag = false; break;}
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> hs(n);
    for (ll i = 0; i < n; ++i) {
        cin >> hs[i];
    }
    sort(hs.begin(), hs.end());
    ll ans = 0;
    for (ll i = 0; i < n - k; ++i) {
        ans += hs[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
a,b,c = gets.split(' ').map(&:to_i)
k = gets.to_i

loop do
  break if a < b

  b *= 2
  k -= 1
  break if k == 0
end

loop do
  break if k == 0
  break if b < c

  c *= 2
  k -= 1
  break if k == 0
end

if a < b && b < c
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N, X; cin >> N >> X;
	ll m[1000];
	ll minV = 1 << 21;
	rep(i, 0, N) {
		cin >> m[i];
		X -= m[i];
		minV = min(minV, m[i]);
	}
	cout << N + X / minV << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    int h , m , s;
    h=a/3600;
    m=(a%3600)/60;
    s=(a%3600)%60;
    cout<<h<<":"<<m<<":"<<s<<endl;

    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
using namespace std;

#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair

int solve()
{
  ll n;
  cin>>n;
  
  ll arr[n];
  
  for(ll i=0;i<n;i++)
    cin>>arr[i];
  
  ll dist[n];
  
  dist[0]=0;
  dist[1]=abs(arr[1]-arr[0]);
  
  for(ll i=2;i<n;i++)
    dist[i]=min(dist[i-1]+abs(arr[i]-arr[i-1]),dist[i-2]+abs(arr[i]-arr[i-2]));
  
  cout<<dist[n-1]<<endl;

    return 0;
}

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

    /*ll t;
    cin>>t;
    while(t--)*/
        solve();

    return 0;
}

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

using namespace std;

using ll = long long;

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

    int n, k, a;

    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a;

    cout << 1 + ceil((n - k) / (k - 1.0)) << endl;

    return 0;
}


Measured memory_bytes: 256
K = int(input())
 
i, a = 0, 0
l = []
for i in range(K):
  a = (10*a + 7) % K
  l.append(a)

j, ans = 0, -1
for j in range(K):
  if l[j] == 0:
    ans = j + 1
    break

print(ans)

Measured memory_bytes: 48624
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll k, x;
    cin >> k >> x;
    if (500 * k >= x)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            double x1 = double.Parse(line[0]);
            double y1 = double.Parse(line[1]);
            double x2 = double.Parse(line[2]);
            double y2 = double.Parse(line[3]);
            Console.WriteLine(Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)));
        }
    }
}



Measured memory_bytes: 16012
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

using namespace std;

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

    size_t N;
    cin >> N;

    vector<int> l(N);
    for (auto &elem : l) {
        cin >> elem;
    }

    sort(l.begin(), l.end());

    int64_t res = 0;
    for (int mid = 0; mid < N; ++mid) {
        for (int low = mid - 1; low >= 0; --low) {
            auto it = lower_bound(l.begin(), l.end(), l[mid] + l[low]);
            int64_t ng = distance(it, l.end());
            res += (N - 1 - mid) - ng;
        }
    }

    cout << res << "\n";

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string str, hi;
    str = "hi";
    hi = "hi";
    while(1){
        if(s == str){
            cout << "Yes" << endl;
            break;
        }

        if(str.size() >= 20){
            cout << "No" << endl;
            break;
        }
        str += hi;

    }
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int Search(int num,int ans);
void Sort(int C[10]);
int Answer_1(void);
int Answer_2(void);
int a[10],b[10],d[10],e[10];
int main(void){
	int i,j,m;
	scanf("%d",&m);
	for(i=1;i<=6;i++){
		scanf("%d",&e[i]);
		d[i] = e[i];}
	for(j=0;j<m;j++){
		for(i=1;i<=6;i++){
			scanf("%d",&b[i]);
			a[i] = b[i];
		}
		Sort(a); Sort(d);
		if(Answer_1()) return 0;
		Search(1,2);
		Search(1,3);
		Search(2,3);
		if(Answer_2()) return 0;
	}
	printf("Yes\n");	
	return 0;
}			
			
	
void Sort(int C[10]){
	int tmp,i;
	for(i=1;i<6;i++){
		if(C[i]>C[i+1]){
			tmp = C[i+1];
			C[i+1] = C[i];
			C[i] = tmp;	
		}
	}
}
int Search(int num,int ans){
	int tmp,i;
	for(i=0;i<4;i++){
		if(b[num]==e[num])
			return 0;
		tmp = b[num];
		b[num] = b[ans];
		b[ans] = b[7-num];
		b[7-num] = b[7-ans];
		b[7-ans] = tmp;
	}
	return 0;
}
int Answer_1(void){
	int i,cnt=0;
	for(i=1;i<=6;i++){
		if(a[i] == d[i])
			cnt++;
	}
	if((cnt==6) && (a[1]==a[2]) && (a[2]==a[3]) && (a[3]==a[4]) && (a[4]==a[5])){
		printf("No\n");
		return 1;
	}
	return 0;
}
int Answer_2(void){
	int i,cnt=0;
	for(i=1;i<=6;i++){
		if(b[i] == e[i])
			cnt+=1;
	}
	if(cnt==6){
		printf("No\n");
		return 1;
	}
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int A, B;
    std::cin >> A >> B;

    int res = std::max({A + B, A + A - 1, B + B - 1});
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main {
    static final Scanner sc = new Scanner(System.in);
    static int n, m;
    static int[] p = new int[100005];
    static int x, y;
    
    static int ans = 0;
    
    static UnionFind uf = new UnionFind(100005);
    
    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();

        for (int i = 1; i <= n; ++i) {
            p[i] = sc.nextInt();
        }

        for (int i = 0; i < m; ++i) {
            x = sc.nextInt();
            y = sc.nextInt();

            uf.unite(p[x], p[y]);
        }

        for (int i = 1; i <= n; i++) {
            if (uf.isSameGroup(p[i], i)) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

/**
 * @author ei1710
 * @version 1.05
 */


/**
 * 素集合データ構造.<br>
 * 各操作O(a(n))程度(a() はアッカーマン関数の逆関数)
 */
class UnionFind {

    /**
     * 添字の示すノードの親.<br>
     * 親がない = 自身が根のとき、-1 * (集合の大きさ)をもつ
     */
    int[] parent;

    /**
     * 木の大きさ.<br>
     * あまり速くならなかった<br>
     * 計算量は O(log n) から O(a(n))くらいまで落ちるはずなのに
     */
    int[] rank;

    /** nmemb個の要素からなる UnionFind */
    public UnionFind(int nmemb) {
        parent = new int[nmemb];
        rank = new int[nmemb];
        
        Arrays.fill(parent, -1);
        Arrays.fill(rank, 0);
    }

    /**
     * 根を求める
     * @param x 根を求めるノードの番号
     */
    protected int root(int x) {
        if (parent[x] < 0) {
            return x;
        }
        
        parent[x] = root(parent[x]);
        return parent[x];
    }

    /** ノードx, yが同じ集合であるかを確かめる */
    public boolean isSameGroup(int x, int y) {
        return root(x) == root(y);
    }

    /**
     * ノードx, y を併合.
     * x, yがすでに同じ集合にあるときは何もしない
     */
    public void unite(int x, int y) {

        x = root(x);
        y = root(y);

        if (x == y) {
            return;
        }

        //小さい木を大きい方へマージ(木の高さを抑えられるので)
        if (rank[x] > rank[y]) {
            parent[x] += parent[y];
            parent[y] = x;
        }
        else {
            parent[y] += parent[x];
            parent[x] = y;

            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        
        return;
    }

    /** グループの大きさ(=要素数)を調べる */
    public int groupSize(int x) {
        return -1 * parent[root(x)];
    }
}


Measured memory_bytes: 91324
#include <stdio.h>
int main()
{
	int A,B,C,K,i,X,max,sum;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&K);
	max=A;
	if(max<B)
		max=B;
	if(max<C)
		max=C;
	X=max;
	for (int i = 0; i < K; ++i)
	{
		X*=2;
	}
	if(max==A)
		sum=X+B+C;
	if(max==B)
		sum=A+X+C;
	if(max==C)
		sum=A+B+X;
	printf("%d",sum);

	return 0;
}

Measured memory_bytes: 128
#include <math.h>
#include <stdio.h>
typedef long long ll;
int main() {
	ll n;
	scanf("%lld", &n);
	int j;
	int list[1000] = {0};
	for (int i = 1; i < 99; i++) {
		if (n <= pow(26, i)) {
			n--;
			for (j = 0; j < i; j++) {
				list[j] = n % 26;
				n /= 26;
			}
			break;
		} else {
			n -= pow(26, i);
		}
	}
	for (int i = j - 1; i >= 0; i--) {
		// printf("%d\n", list[i]);
		printf("%c", list[i] + 'a');
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2416
{-# OPTIONS_GHC -Wall #-}

readInt :: String -> Int
readInt = read

isOk :: [Int] -> Int -> Bool
isOk _ 0  = True
isOk [] _ = False
isOk (a:as) m
    | a > m     = isOk as m
    | otherwise = (isOk as (m-a)) || (isOk as m)

yesno :: Bool -> String
yesno True  = "yes"
yesno False = "no"

main :: IO ()
main = do
    _  <- fmap readInt getLine
    as <- fmap (map readInt . words) getLine
    _  <- fmap readInt getLine
    ms <- fmap (map readInt . words) getLine
    let ans = map (isOk as) ms
    mapM_ (putStrLn . yesno) ans



Measured memory_bytes: 5124
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: usize, b: usize,
        s: Chars,
    }
    if s[a] == '-' {
        println!(
            "{}",
            if s[0..a].iter().all(|c| *c != '-')
                && s[(a + 1)..(a + b + 1)].iter().all(|c| *c != '-')
            {
                "Yes"
            } else {
                "No"
            }
        );
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
#include <ctime>

using namespace std;

#define int long long
#define double long double

const int N = 1000001;

int get(string s) {
    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        ans += s[i] - '0';
    }
    return ans;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int ans = 1000000;
    for (int i = 1; i < n; ++i) {
        int a = i, b = n - i;
        ans = min(ans, get(to_string(a)) + get(to_string(b)));
    }
    cout << ans;
    return 0;
}   

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; ++i) cin >> s[i] >> t[i];
  Cin(string, x);

  int ans = 0;
  bool ok = false;
  for (int i = 0; i < n; ++i) {
    if (!ok) {
      if (s[i] == x) ok = true;
    } else
      ans += t[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
typedef std::vector<pl> vpl;
const long double EPS = 1e-9;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
#define rsort(a,n) sort(a,a+n,greater<>())

const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 200;

int main(void){
    str s,t;
    ll n;
    ll L[90];
    
    in1(n);
    L[0] = 2;
    L[1] = 1;
    For(i, 2, 90) L[i] = L[i-1] + L[i-2];
    prl(L[n]);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;
typedef long long ll;

int main(){
  int n, s, r;
  
  cin >> n;

  ll dp[101][40];
  memset(dp, 0, sizeof(dp));

  cin >> s;
  dp[0][s+10] = 1;

  for(int i = 1; i < n-1; i++){
    cin >> s;
    
    for(int j = 10; j <= 30; j++){
      if(dp[i-1][j] != 0){
        dp[i][j+s] += dp[i-1][j];
        dp[i][j-s] += dp[i-1][j];
      }
    }
  }

  cin >> r;

  cout << dp[n-2][r+10] << endl;

  return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#define MAX_N 999999

int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int m, int n) {
  int cnt = 0;
  int i, p = 0;
  for (int i = 0; i <= n; i++) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++];
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
      }
    }
  }

  for (i = m + 1; i <= n; i++) {
    if (is_prime[i]) {
      cnt++;
    }
  }

  return cnt;
}

int main() {
  int n;

  scanf("%d", &n);
  while (n != 0) {
    printf("%d\n", sieve(n, 2 * n));
    scanf("%d", &n);
  }

  return 0;
}

Measured memory_bytes: 1268
import java.util.Scanner;

//Ben Toh
public class Main{
	
	void run(){
		double EPS = 1e-13;
		double[] res = new double[100001];
		res[1] = 1;
		for(int n=2;n<=100000;n++){
			double p = 1, win = 0.5;
			int k = 1;
			while(EPS<p && k<n){
				double not = p*(1-win);
				res[n] += not*(k+res[Math.max(0, n-k-1)]);
				p*=win; win/=2; k++;
			}
			res[n]+=n*p;
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			System.out.printf("%.8f\n", res[n]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);

	for(auto&an:a){
		cin >> an;
	}

	int out = 0;
	for (;;){
		for(auto &an:a){
			if(an%2!=0){
				goto out;
			}else{
				an /= 2;
			}
		}
		out++;
	}

	out:
	cout << out << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long
#define pb push_back
#define mod 1000000007
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define inf 1e18
#define pre(x,y) fixed<<setprecision(y)<<x
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define gcd(x,y) __gcd(x,y)
#define mp make_pair

int solveGame(int a[],vector<vector<int>> &dp,int i,int j,int n)
{
	if(i>j) return 0;
	if(i==j) return dp[i][i]=a[i];
	else if(dp[i][j]!=-1) return dp[i][j];
	else
	{
		int x=a[i]+min(solveGame(a,dp,i+1,j-1,n),solveGame(a,dp,i+2,j,n));
		int y=a[j]+min(solveGame(a,dp,i+1,j-1,n),solveGame(a,dp,i,j-2,n));
		return dp[i][j]=max(x,y);
	}
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i,j,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    vector<vector<int>> dp(n,vector<int>(n));
    for(i=0;i<n;i++)
    {
    	for(j=0;j<n;j++) dp[i][j]=-1;
    }
    k=solveGame(a,dp,0,n-1,n);
    int sum=0;
    for(i=0;i<n;i++) sum+=a[i];
    cout<<k-(sum-k)<<endl;
	return 0;
}


Measured memory_bytes: 73916
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

int main()
{
  string s;cin >> s;
  int n = s.size();
  vector<vector<mint>> dp(n+1,vector<mint>(13));
  dp[0][0].x = 1;
  rep(i,n){
    rep(j,13){
      if(s[i]=='?'){
	rep(k,10){
	  dp[i+1][(j*10+k)%13] += dp[i][j];
	}
      }
      else{
	int kk = s[i]-'0';
	dp[i+1][(j*10+kk)%13] += dp[i][j];
      }
    }
  }

  cout << dp[n][5].x << "\n";
  
  return 0;
}


Measured memory_bytes: 13568
n = int(input())
s = []
for i in range(n):
  s.append(input())
  
ans = "Yes"

for i in range(n-1):
  if s[i] in s[i+1:n]:
    ans = "No"
  elif s[i][len(s[i])-1] != s[i+1][0]:
    ans = "No"
    
print(ans)
 


Measured memory_bytes: 3060
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        c: Chars,
    }

    let mut ans = 0;
    let mut l = 0;
    let mut r = n - 1;

    while l < r {
        if c[l] == 'R' {
            l += 1;
            continue;
        }
        if c[r] == 'W' {
            r -= 1;
            continue;
        }

        ans += 1;
        l += 1;
        r -= 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1
#define max 10000007


bool binary(ll r[], ll st, ll ed,const ll& key, ll& m)
{
    ll mid;
    while(st<=ed)
    {
        mid = (st+ed)/2;
        if(r[mid]==key)
        {
            m = mid;

            return true;
        }
        else if(r[mid]< key)
        {
            ed = mid - 1;
        }
        else
            st = mid + 1;
    }
    m = 0;
//    cout <<"False\n";
    return false;
}

int main()
{
    string s;
    cin >> s;
    ll zero = 0, one = 0;

    for(ul i = 0;  i < s.length(); i++)
        if(s[i]==48)
            zero++;
        else
            one++;



    cout << 2*min(zero, one);

}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int a[100000];

int main(){
  int n;
  int cnt = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for(int i = 0; i < n; i++){
    if(a[a[i-1]-1] == i)
      cnt++;
  }

  cout << cnt/2 << endl;

  return 0;
}


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

int a[3][105],dp[3][105];

int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=2;i++)
	{
		for (int j=1;j<=n;j++)  cin>>a[i][j];
	}
	dp[1][1]=a[1][1];
	for (int i=1;i<=2;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (i==1&&j==1)  continue;
			if (i==1)  dp[i][j]=dp[i][j-1]+a[i][j];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
		}
	}
	cout<<dp[2][n]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
      public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int a[] = new int[5];
	for(int i=0;i<5;i++){
	    a[i] = sc.nextInt();
	}
	for(int i=0;i<5;i++){
	    if(a[i]==0){
		System.out.println(i+1);
		break;
	    }
	}
	sc.close();
      }
}


Measured memory_bytes: 35804
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
     [w, h, x, y] <- getIntList
     putStr . show $ solve w h
     putStr " "
     putStrLn $ check w h x y

solve w h = fromIntegral (w * h) / 2

check w h x y
    | w == 2 * x && h == 2 * y = "1"
    | otherwise = "0"

Measured memory_bytes: 508