akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,N;
ll dp[100];

int main() {
	
	dp[0] = 2;
	dp[1] = 1;
	REPI(2,87) {
		dp[i] = dp[i-1] + dp[i-2];
	}
	
	cin >> N;	
	cout << dp[N];
	
	return 0;
}


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

const int MaxN=1e6+5;

int N;
char S[MaxN];
int A[MaxN];

int main(){
	int i,j,t,x,sum=0;
	scanf("%s",S);
	N=strlen(S);
	for(i=0;i<N;i++)
		A[N-1-i]=S[i]-'0';
	for(i=t=0;i<N;i++){
		x=(A[i]*9+t)/10;
		A[i]=(A[i]*9+t)%10;
		t=x;
	}
	if(t)
		A[N++]=t;
	for(i=0;i<N;i++)
		sum+=A[i];
	for(i=1;i<=N+10;i++){
		for(j=0,t=9;j<N;j++){
			x=(A[j]+t)/10;
			sum-=A[j];
			A[j]=(A[j]+t)%10;
			t=x,sum+=A[j];
			if(!t)
				break;
		}
		if(t)
			A[N++]=t,sum+=t;
		if(sum<=9*i)
			break;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool prime[1000000]; 
void SieveOfEratosthenes(long long int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    
    memset(prime, true, sizeof(prime)); 
  
    for (long long int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (long long int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
   
} 
int main() {
    long long int a;
    SieveOfEratosthenes(1000000);
    cin>>a;
    while(1)
    {
        
        if(prime[a])
        {
            cout<<a<<endl;
            break;
        }
        a++;
    }
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(1);
    int N;
    cin >> N;
    vector<ll> X(N);
    int base = N / 2;
    int f = floor((N-1)/2);
    int s = ceil(N/2);
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    vector<ll> Y = X;
    sort(all(Y));
    f = Y[f];
    s = Y[s];
    //cout << f << " " << s << endl;
    for (int i = 0; i < N; i++)
    {
        if(X[i] <= f){
            cout << s << endl;
        }
        else{
            cout << f << endl;
        }
    }
}


Measured memory_bytes: 6320
/*
[abc128] F - Frog Jump
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int s[MAX_N];
bool used[MAX_N];

ll solve() {
    ll ans = 0;
    for (int d = 1; d < N - 1; d++) {
        ll t = 0;
        for (int k = 0; d < N - 1 - k * d; k++) {
            used[k * d] = true;
            if (used[N - 1 - k * d]) {
                break;
            }
            t += s[k * d] + s[N - 1 - k * d];
            ans = max(ans, t);
        }
        for (int k = 0; k * d < N - 1; k++) {
            used[k * d] = false;
        }
    }

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

int l;
LL a[200000];
LL dp[5][200002];

int main(){
  cin>>l;
  REP(i,l){
    cin>>a[i];
  }
  dp[0][0]=a[0];
  dp[1][0]=(a[0]%2)?1:(a[0]==0?2:0);
  dp[2][0]=(a[0]%2)?0:1;
  dp[3][0]=1e15;
  dp[4][0]=1e15;
  FOR(i,1,l){
    dp[0][i]=dp[0][i-1]+a[i];
    dp[1][i]=min(dp[0][i-1],dp[1][i-1])+((a[i]%2)?1:(a[i]==0?2:0));
    dp[2][i]=min(dp[0][i-1],min(dp[1][i-1],dp[2][i-1]))+((a[i]%2)?0:1);
    dp[3][i]=min(dp[2][i-1],dp[3][i-1])+((a[i]%2)?1:(a[i]==0?2:0));
    dp[4][i]=min(min(min(min(dp[4][i-1]+a[i],dp[3][i-1]+a[i]),dp[2][i-1]+a[i]),dp[1][i-1]+a[i]),dp[0][i-1]+a[i]);

    /*
    REP(j,5)
      cerr<<dp[j][i]<<" ";
    cerr<<endl;
    */
    
    REP(j,5)dp[j][i]=min(dp[j][i],(LL)1e12);
  }
  cout<<min(min(min(min(dp[0][l-1],dp[1][l-1]),dp[2][l-1]),dp[3][l-1]),dp[4][l-1])<<endl;
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;

ll ar[100010];
ll dp[100010];
ll n;

int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(ll i=1; i<=n; i++)
        cin>>ar[i];
    dp[1]=0;
    dp[0]=1e6;
    for(ll i=2; i<=n; i++)
    {
        ll l=abs(ar[i-2]-ar[i])+dp[i-2];
        ll r=abs(ar[i-1]-ar[i])+dp[i-1];
        dp[i]=min(l,r);
    }
    cout<<dp[n]<<nn;

}








Measured memory_bytes: 1792
alp=[*"a".."z"];n=Array.new(26,0);ans=[alp,n].transpose.to_h
($stdin.read.chomp.scan(/[a-zA-Z]/).map(&:downcase).sort).each{|s|ans[s]+=1}
alp.each{|a|puts "#{a} : #{ans[a]}"}



Measured memory_bytes: 6888
s = input()
ans = s[0]
count = 0
for i in range(1, len(s)):
    if ans[len(ans)-1] == s[i]:
        if s[i] == "0":
            ans += "1"
        else:
            ans += "0"
        count += 1
    else:
        ans += s[i]
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int x;
    cin>>x;
    if (x<=6) {
        cout<<1<<endl;
    } else {
        if (x%11==0) {
            cout<<2*(x/11)<<endl;
        } else if (x%11<=6) {
            cout<<2*(x/11)+1<<endl;
        } else {
            cout<<2*(x/11)+2<<endl;
        }
    }
}


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

int n,m,w,h,r,l;
long long v[100005],x[100005];
long long rv[100005],lv[100005];
long long frv[100005],dnum[100005];
//long long rd[100005],ld[100005];
long long mv=0,c,suma=0,sumb=0;

int main(){
  int i,j;
  cin >> n >> c;
  x[0]=0;
  x[n+1]=c;
  for(i=1;i<=n;i++){
    cin >> x[i] >> v[i];
  }
  rv[0]=0;
  lv[0]=0;
  frv[0]=0;
  dnum[0]=0;
  for(i=1;i<=n;i++){
    suma+=v[i];
    sumb+=v[n+1-i];
    rv[i]=suma-x[i];
    if(rv[i]>frv[i-1]){
      frv[i]=rv[i];
      dnum[i]=i;
    }
    else {
      frv[i]=frv[i-1];
      dnum[i]=dnum[i-1];
    }
    lv[i]=max(lv[i-1],sumb-c+x[n+1-i]);
  }
  /*for(i=0;i<=n;i++){
    //cout << i <<" "<< rv[i] <<" "<< lv[i] <<" "<< rd[i] <<" " << ld[i] <<" "<< frv[i]<<" " <<dnum[i]<<endl;
    }*/
  for(i=0;i<=n;i++){
    mv=max(mv,lv[i]+frv[n-i]-min(c-x[n+1-i],x[dnum[n-i]]));
    //cout << i << " " << mv << endl;
  } 
  cout << mv << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int min(int a, int b)
{
    return a < b? a: b;
}

int main(void)
{
    long long q, h, s, d, n;
    scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
    s = min(s, min(q * 4, h * 2));
    d = min(d, s * 2);
    long long ans = n / 2 * d + n % 2 * s;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int n;
vector<int> a;

int check(int c){
	int su = 0;
	for(int i:a){
		su += (i-c)*(i-c);
	}
	return su;
}

int main(){
	fastread;
	cin>>n;
	a.resize(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int mi = min_el(a);
	int mx = max_el(a);
	mi = a[mi];
	mx = a[mx];
	int ans  = INT_MAX;
	for(int i=mi;i<=mx;i++){
		int cost = check(i);
		ans = min(ans,cost);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

int xCnt[100005];
char xChar[100005];

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

  string s;
  cin >> s;

  int idx = 0;

  rep(i, s.length()) {
    if(s[i] == 'x') {
      xCnt[idx]++;
    } else {
      xChar[idx] = s[i];
      idx++;
    }
  }

  bool canDo = true;
  int res = 0;

  rep(i, idx/2) {
    if (xChar[i] != xChar[idx-i-1]) {
      canDo = false;
    }
  }

  rep(i, (idx+1)/2) {
    res += abs(xCnt[i] - xCnt[idx-i]);
  }

  cout << (canDo?res:-1) << endl;
}


Measured memory_bytes: 832
#include<cstdio>
#include<algorithm>
int n,k,q,mi;
int a[2010],b[2010],ans[2001],cn,Ans=2147483647;
int main(){
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		mi=a[i];
		int l=1,r=1;
		while(l<=n){
			while(a[l]<mi&&l<n) l++;
			r=l;
			while(a[r+1]>=mi&&r<n) r++;
			if(r-l+1>=k){
				for(int j=l;j<=r;j++) b[j]=a[j];
				std::sort(b+l,b+r+1);
				for(int j=l;j<=r-k+1;j++) ans[++cn]=b[j];
			}
			l=r+1;
		}
		std::sort(ans+1,ans+cn+1);
		if(cn>=q) if(ans[q]-ans[1]<Ans) Ans=ans[q]-ans[1];
		cn=0;
	}
	printf("%d\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++ ){
cout << "#";
}
cout << "\n";
}
cout << endl;
}

return 0;
}


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

double ave(int x){
        int sum = 0;
        if(x==0)return 0;

        for(int i=1; i<(x+1); i++){
                sum +=i;
        }
        return static_cast<double>(sum)/x;
}

int main()
{
        int n,k;
        std::cin >> n >> k;
        //std::vector<int> p(n+1); for(int i=1; i<n+1; i++)std::cin >> p[i];

        printf("%d\n", n*k);
        return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MAXN 200010
#define mod 998244353
ll dta[MAXN];

struct Tree
{
	ll sum;
	ll lazy;
};

Tree tree[MAXN * 4];

void build(int node, int low, int high)
{
	//cout << node << ' ' << low << ' ' << high << endl;
	if(low == high)
	{
		tree[node].sum = dta[low];
		tree[node].lazy = 0;
		return;
	}

	int left = node * 2;
	int right = left + 1;
	int mid = (low + high) >> 1;

	build(left, low, mid);
	build(right, mid + 1, high);

	tree[node].sum = (tree[left].sum + tree[right].sum)%mod;
	tree[node].lazy = 0;
}

void update(int node, int low, int high, int lr, int hr, ll val)
{
	if(tree[node].lazy)
	{
		tree[node].sum += ((high - low + 1)%mod) * (tree[node].lazy%mod);
		tree[node].sum%=mod;

		if(low != high)
		{
			tree[node * 2].lazy += tree[node].lazy;
			tree[node * 2].lazy%=mod;
			tree[node * 2 + 1].lazy += tree[node].lazy;
			tree[node * 2 + 1].lazy%=mod;

		}

		tree[node].lazy = 0;
	}

	if(low > hr || high < lr)
		return;

	if(low >= lr && high <= hr)
	{
		tree[node].sum += ((high - low + 1) %mod) * (val%mod);
		tree[node].sum%=mod;
		
		if(low != high)
		{
			tree[node * 2].lazy += val;
			tree[node * 2].lazy%=mod;
			tree[node * 2 + 1].lazy += val;
			tree[node * 2 + 1].lazy%=mod;
		}

		return;
	}

	int left = node * 2;
	int right = left + 1;
	int mid = (low + high) >> 1;

	update(left, low, mid, lr, hr, val);
	update(right, mid + 1, high, lr, hr, val);

	tree[node].sum = (tree[left].sum + tree[right].sum)%mod;
}

ll query(int node, int low, int high, int lr, int hr)
{
	if(low > hr || high < lr)
		return 0;

	if(tree[node].lazy)
	{
		tree[node].sum += ((high - low + 1)%mod) * (tree[node].lazy%mod);
		tree[node].sum%=mod;
		if(low != high)
		{
			tree[node * 2].lazy += tree[node].lazy;
			tree[node * 2].lazy%=mod;
			tree[node * 2 + 1].lazy += tree[node].lazy;
			tree[node * 2 + 1].lazy%=mod;
		}

		tree[node].lazy = 0;
	}

	if(low >= lr && high <= hr)
	{
		return tree[node].sum%mod;
	}

	int left = node * 2;
	int right = left + 1;
	int mid = (low + high) >> 1;

	ll p = query(left, low, mid, lr, hr);
	p%=mod;
	p += query(right, mid + 1, high, lr, hr);
	p%=mod;

	return p;
}

ll l[11], r[11];

int main()
{
	ll i, j, n, m, k;

	scanf("%lld %lld", &n, &k);

	for(i=0; i<k; i++) scanf("%lld %lld", &l[i], &r[i]);

	//cout<<"*"<<endl;


	dta[n]=1;
	
	build(1, 1, n);

	//cout<<"*"<<endl;

	for(i=n; i>1; i--)
	{
		ll val=query(1, 1, n, i, i);
		for(j=0; j<=k; j++)
		{
			if(i-l[j]<1) continue;
			ll lft=max(1LL, i-r[j]), rght=i-l[j];
			update(1, 1, n, lft, rght, val);
		}
	}

	ll res=query(1, 1, n, 1, 1);

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





	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    rep(i, n){
        int tmp;
        cin >> tmp;
        a.push(tmp);
    }
    rep(i, m){
        int mx = a.top(); a.pop();
        a.push(mx / 2); 
    }
    ll ans = 0;
    rep(i, n){
        ans += a.top(); a.pop();
    }
    cout << ans << endl;
}

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

int f(string t) {
	int h = 10 * (t[0] - '0') + t[1] - '0';
	int m = 10 * (t[3] - '0') + t[4] - '0';
	int s = 10 * (t[6] - '0') + t[7] - '0';
	return 60 * ((60 * h) + m) + s;
}

int main() {
	int n;
	while (cin >> n, n) {
		deque<pair<int, int>> q, r;
		for (int i = 0; i < n; i++) {
			string s, t;
			cin >> s >> t;
			q.push_back(make_pair(f(s), f(t)));
		}
		sort(begin(q), end(q));
		int m = 1;
		auto l = q.front();
		q.pop_front();
		while (!q.empty()) {
			auto p = q.front();
			q.pop_front();
			if (l.second <= p.first) {
				l = p;
			} else {
				r.push_back(p);
			}
			if (q.empty() && !r.empty()) {
				m++;
				while (!r.empty()) {
					q.push_back(r.front());
					r.pop_front();
				}
				l = q.front();
				q.pop_front();
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

vector<long long int> fibo(100001,-1);
long long int fibonatti(long long int n){
    if(fibo[n]!=-1){
        return fibo[n];
    }else if(n==0){
        fibo[0]=1;
        return 1;
    }else if(n==1){
        fibo[1]=1;
        return 1;
    }else if(n>=2){
        fibo[n]=(fibonatti(n-1)+fibonatti(n-2))%MOD;
        return fibo[n];
    }
}
 
int main(){
    ll n,m;
    in(n,m);
    vector<int> vec(m);
    in(vec);
    fibonatti(100000);
    vec.push_back(n+1);
    ll target=0,ans=1,d=0;
    rep(i,m+1){
        if(i==0)target=vec[i]-1;
        else target=vec[i]-vec[i-1]-2;
        if(target==-1){
            ans=0;
            break;
        }
        d=0;
        if(target==0)d=1;
        else if(target==1)d=1;
        else if(target==2)d=2;
        else if(target>=3){
            d=fibo[target];
        }
        ans*=d;
        if(ans>MOD)ans%=(ll)MOD;
    }
    out(ans);
}


Measured memory_bytes: 8000
#include<bits/stdc++.h>
    using namespace std;
    const double pi = 3.141592654;
    int main()
    {
    int n;
    cin>>n;
    int flag=0;
    while(n!=0)
    {
    	
      int r=n%10;
      n=n/10;
      if(r==7)
      {
      	flag=1;
      	
	  }
    	
    	
	}
	
	
	if(flag==1)
	{
		
		
		cout<<"Yes"<<endl;
	}
	
	
	else if(flag==0)
	{
		cout<<"No"<<endl;
		
	}
    
    
     
    return 0;
    
}

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod;    }
ll add(ll a, ll b)  { return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;
	ll n,k,r,s,p;
	cin>>n>>k>>r>>s>>p;

	string t;
	cin>>t;

	string win;
	forn(i,0,n)
	{
		if(t[i] == 'r')
		{
			win.pb('p');
		}
		else if(t[i] == 'p')
		{
			win.pb('s');
		}
		else
			win.pb('r');
	}

	vector<ll>play[k];
	set<ll>taken;

	forn(i,0,k)
	{
		ll j = i;
		while(j<n)
		{
			//if(taken.find(j) == taken.end())
			{
				//taken.insert(j);
				play[i].pb(j);
			}
			j+=k;
		}
	}

	// forn(i,0,k)
	// {
	// 	for(auto x:play[i])
	// 		cout<<x<<" ";
	// 	cout<<endl;
	// }



	ll ans = 0;
	// forn(i,0,k)
	// {
	// 	forn(j,0,(ll)play[i].size())
	// 	{
	// 		if(j%2==0)
	// 		{
	// 			if(win[play[i][j]] == 'r')
	// 			{
	// 				ans+=r;
	// 				cout<<"r";
	// 			}
	// 			else if(win[play[i][j]] == 's')
	// 			{
	// 				ans+=s;
	// 				cout<<"s";
	// 			}
	// 			else
	// 			{
	// 				cout<<"p";
	// 				ans+=p;
	// 			}
	// 		}
	// 		else
	// 		{
	// 			if(win[play[i][j]] != win[play[i][j-1]])
	// 			{
	// 				if(win[play[i][j]] == 'r')
	// 				{
	// 					cout<<"r";
	// 					ans+=r;
	// 				}
	// 				else if(win[play[i][j]] == 's')
	// 				{
	// 					cout<<"s";
	// 					ans+=s;
	// 				}
	// 				else
	// 				{
	// 					cout<<"p";
	// 					ans+=p;
	// 				}
	// 			}
	// 			else
	// 				cout<<" ";
	// 		}
	// 	}

	// 	cout<<endl;
	// }

	forn(i,0,k)
	{
		forn(j,0,(ll)play[i].size())
		{
			ll ii = j;

			ll cnt = 1;
			while((ii+1)<(ll)play[i].size() && win[play[i][ii+1]] == win[play[i][ii]])
			{
				cnt++;
				ii++;
				j++;
				//cout<<ii<<" ";
			}
			//j--;
			ii = j;	
			if(win[play[i][ii]] == 'r')
			{
				ans += (cnt-cnt/2)*r;
			}
			else if(win[play[i][ii]] == 's')
			{
				ans += (cnt-cnt/2)*s;
			}
			else
			{
				ans += (cnt-cnt/2)*p;
			}

		}
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 5328
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t) cout << "Yes"<<endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  rep(i,a+1){
    int x = b*i+c;
    if(x%a==0){ cout << "YES" << endl; return 0; }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;
int main(void) {
	int K, N;
	scanf("%d%d", &N, &K);

	vector<int>vec(N);
	int num;
	for (int i = 0; i < N; i++) {
		scanf("%d", &num);
		vec[i] = num;
	}

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

	int sum=0;
	for (int i = 0; i < K; i++) {
		sum += vec[i];
	}

	printf("%d", sum);

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
        int dx=x2-x1,dy=y2-y1;
        printf("%d %d %d %d\n",x2-dy,y2+dx,x1-dy,y1+dx);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//define
#define itn int //for int typo error
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto&a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second
//typedef
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;
typedef pair<int, int> pii;
inline int rint(){int x; scanf("%d", &x); return x;}
//can modify here
const ll mod = 1000000007;
//don't ever modify here, a^b % mod function, extended euclid algo, gcd
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll eea(ll a, ll b, ll &x, ll &y){if(!b){x=1,y=0;return a;} ll x1,y1; ll d = eea(b,a%b,x1,y1);x=y1;y=x1-(ll)(a/b)*y1;return d;}
ll gcd(ll a, ll b){ll x; ll y; return eea(a,b,x,y);}

//code here
void solve()
{
    int n = rint();
    if(n%2)
        cout << n/2+1;
    else
        cout << n/2;
}

int main() {
    //For faster IO, comment out for interative problems
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	//int t = rint();
	//rep(i,0,t) solve();
    //rep(i,0,t)
        solve();
	return 0;
}


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

int main(){
	int t, h, m, s;

	cin >> t;

	h = t / 3600;
	m = (t - (h * 3600)) / 60;
	s = t - (h * 3600 + m * 60) ;

	cout << h << ':' << m << ':' << s << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  priority_queue<ll> t;
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
    t.push(A[i]);
  }
  ll nmax = t.top();
  t.pop();
  for (int i = 0; i < N; ++i)
  {
    if (A[i] == nmax)
      printf("%lld\n", t.top());
    else
      printf("%lld\n", nmax);
  }

  return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int M=1000000,N=M+5,mod=998244353;
ll to[N],inv[N],dp[N],ans;
int main(){
	int n=read();
	For(i,1,n)to[read()]++;
	For(i,1,M){ans-=to[i]*i; to[i]*=i; inv[i]=i==1?1:mod-mod/i*inv[mod%i]%mod;}
	Rep(i,M,1){
		for(int j=i;j<=M;j+=i)dp[i]+=to[j];
		dp[i]%=mod;
		dp[i]=dp[i]*dp[i]%mod;
		for(int j=i+i;j<=M;j+=i)dp[i]-=dp[j];
		dp[i]%=mod;
		ans=(ans+dp[i]*inv[i])%mod;
	}
	cout<<(ans*inv[2]%mod+mod)%mod<<endl;
}

Measured memory_bytes: 23680
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  int sza = sa.size();
  int szb = sb.size();
  int szc = sc.size();

  int ia = 0;
  int ib = 0;
  int ic = 0;
  char nxt = 'a';
  while(1){
    if(ia == sza && nxt == 'a'){
      cout << "A" << endl;
      return 0;
    }
    if(ib == szb && nxt == 'b'){
      cout << "B" << endl;
      return 0;
    }
    if(ic == szc && nxt == 'c'){
      cout << "C" << endl;
      return 0;
    }

    if(nxt == 'a'){
      nxt = sa[ia];
      ia++;
    }
    else if(nxt == 'b'){
      nxt = sb[ib];
      ib++;
    }
    else if(nxt == 'c'){
      nxt = sc[ic];
      ic++;
    }

    //cout << ia << ib << ic << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
al = [int(a) for a in input().split()]

odd_num = sum([1 for a in al if a % 2 == 1])
even_num = len(al) - odd_num

ans = "YES"
if odd_num % 2 == 1:
    ans = "NO"
if odd_num == 1 and even_num == 0:
    ans = "YES"

print(ans)

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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int res = 0;
	while (true) {
		[&] {
			while (a > 0) {
				res++;
				a--;
				k--;
				if (k < 1) return;
			}
			while (b > 0) {
				b--;
				k--;

				if (k < 1) return
				
				
				;
			}
			while (c > 0) {
				res--;
				k--;

				if (k < 1) return;
			}
		}();

		break;
	}

	cout << res;

	return 0;	
}

Measured memory_bytes: 3652
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

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

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int table[maxn][3];
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", table[j] + i);
    }
  }
  return 1;
}

int a[maxn];
int xr[maxn];

int used[maxn];

void solve() {
  for (int i = 0; i < n; ++i) {
    if (abs(table[i][1] - table[i][0]) != 1 || abs(table[i][2] - table[i][1]) != 1) {
      printf("No\n");
      return;
    }
    a[i] = (table[i][0] - 1) / 3;
    xr[i] = (table[i][0] > table[i][2]);
  }

  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }
  int whole[2] = {(((n + 1) / 2) & 1), ((n / 2) & 1)};
  for (int i = 0; i < n; ++i) {
    if ((a[i] & 1) != (i & 1)) {
      printf("No\n");
      return;
    }
    whole[!(i & 1)] ^= xr[i];

    if (!used[i]) {
      whole[i & 1] ^= 1;
      for (int x = i; !used[x]; x = a[x]) {
        used[x] = 1;
      }
    }
  }
  if (whole[0] || whole[1]) {
    printf("No\n");
  } else {
    printf("Yes\n");
    //printf("No\n");
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>

int main(){
	  int i;
    int count=0;
  	char s[3];

  	for(i=0; i<3; i++){
    	scanf("%c", &s[i]);
    }

    if(s[0]=='1'){
      count++;
    }
    if(s[1]=='1'){
      count++;
    }
    if(s[2]=='1'){
      count++;
    }

    printf("%d", count);


  return 0;

}


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

int main() {
  int n;
  ll t,a;
  cin >> n >> t >> a;
  rep(i,1,n){
    ll vt,va;
    cin >> vt >> va;
    if(va >= a && vt >= t){a = va;t = vt;}
    else{
      ll bt,ba;
      bt = t/vt;
      if(t%vt != 0) bt++;
      ba = a/va;
      if(a%va != 0) ba++;
      a = max(bt,ba)*va;
      t = max(bt,ba)*vt;
      //cout << t << " " << a << endl;
    }
  }
  cout << t+a << endl;
}

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

int main() {

    int N;

    cin >> N;

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            
            if (i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;

}

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

using namespace std;

void max_self(long long& a , long long b){
  a = max(a , b);
}

int main() {
  int n ; cin>>n;
  vector<pair<long long, int> > v;
  for(int i = 0 ; i < n; ++i){
    long long x ; cin>>x;
    v.emplace_back(x , i);
  }
  sort(v.rbegin() , v.rend());
  vector<vector<long long> > dp(n + 1 , vector<long long>(n + 1 , -1000000000 - 9));
  dp[0][0] = 0;
  for(int i = 0 ; i < n; ++i){
    int p = v[i].second;
    for(int j = 0 ; j <= i; ++j){
      max_self(dp[i + 1][j + 1] , dp[i][j] + abs(p - j) * v[i].first);
      max_self(dp[i + 1][j] , dp[i][j] + abs(n - 1 - (i - j) - p) * v[i].first);
    }
  }
  long long ans = 0;
  for(int i = 0 ; i <= n; ++i){
    max_self(ans , dp[n][i]);
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 34668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

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

    int n, r;
    cin >> n >> r;

    if (n < 10) {
        int ans = r + 100 * (10 - n);
        cout << ans << "\n";
    }
    else {
        cout << r << "\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;
ll n, m, k;
const ll NMAX = 300005;
ll ival[NMAX], jval[NMAX];

ll vx[NMAX], vy[NMAX];

ll imax = -1, jmax = -1;
ll cnt = 0;
ll mmax = -1;
ll valx, valy;

int main()
{
    ll i, x, y;
    cin >> n >> m >> k; valx = valy = 0;
    for(i = 1; i <= k; i++) {
        cin >> x >> y;
        vx[i] = x; vy[i] = y;
        ival[x]++;
        jval[y]++;
        if(ival[x] > imax) {
            imax = ival[x];
            valx = 1;
        }
        else if(imax == ival[x])
            valx++;
        if(jval[y] > jmax) {
            jmax = jval[y];
            valy = 1;
        }
        else if(jmax == jval[y])
            valy++;
    }
    cnt = valx * valy;
    for(i = 1; i <= k; i++) {
        if(imax + jmax == ival[vx[i]] + jval[vy[i]]) {
            cnt--;
        }
    }
    if(cnt > 0) {
        cout << imax + jmax;
    } else {
        cout << imax + jmax - 1;
    }
    return 0;
}


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

int main() {
	long long int X, i, j, f = 1;
	cin>>X;
	for (i = X;;i++)
	{
	    f = 1;
	    if (i == 2)
	    {
	        cout<<i;
	        break;
	    }
	    else
	    {
	        for (j = 2; j < X/2; j++)
	            if (i % j == 0)
	            {
	                f = 0; break;
	            }
	        if (f)
	        {
	            cout<<i;
	            break;
	        }
	    }
	}
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp.chars
n = s.size

ans = [0]*(n+1)

i = 0
while i < n
  if s[i] == '<'
    while i < n && s[i] == '<' # 右にある<を数える
      ans[i+1] = ans[i] + 1
      i += 1
    end
  else
    i += 1
  end
end

i = n-1
while i >= 0
  if s[i] == '>'
    while i >= 0 && s[i] == '>'
      ans[i] = [ans[i+1] + 1, ans[i]].max
      i -= 1
    end
  else
    i -= 1
  end
end

print ans.inject(:+)

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

int n;

void dfs(string s, int i, int k)
{
  if (i == n) {
    cout << s << endl;
    return;
  }
  int num = s[i-1] - 'a';
  k = max(k, num+1);
  for (int j=0; j<k+1; j++) {
    dfs(s, i+1, k);
    s[i]++;
  }
}

int main()
{
  cin >> n;
  string s = "";
  rep(i, n) s.push_back('a');
  dfs(s, 1, 1);

  return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
int main()
{
	char s[1005];
	char s1[1005];
	char s2[1005];
	char s3[1005];
	scanf("%s%s",s,s1);
	int n=strlen(s);
	strcpy(s3,s);
	int f=0;
	for(int j=0;j<n;j++){
		for(int i=1;i<n;i++){
		s2[0]=s3[n-1];
		s2[i]=s3[i-1];		
		}
		s2[n]='\0';
		if(strcmp(s2,s1)==0){
			f=1;
			break;	
		}
		strcpy(s3,s2);
	}
	if(f==1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
<?php
// ini_set('error_reporting' , E_ALL & ~E_NOTICE);

// define('DEBUG', true);
define('DEBUG', false);

$x = 100000;
// $x = 4000;
$p = array_pad(array(), $x, false);
$q = array_pad(array(), $x, 0);

$p[0] = true;
$p[1] = true;

$x_max = sqrt($x);

for ($i = 2; $i <= $x_max; $i++) {
	$l = $x / $i;
	for ($j = 2; $j <= $l; $j++) {
		$p[$i * $j] = true;
	}
}

foreach ($p as $k => $v) {
	if ($v === false) {
		if (DEBUG) {
			echo $k . PHP_EOL;
		}

	}
}

$cnt = 0;
for ($i = 1; $i < $x; $i++) {
	$r = ($i + 1) / 2;
	if ($p[$i] === false &&
		$p[$r] === false
	) {
		$cnt++;
	}
	$q[$i] = $cnt;
}

for ($i = 1; $i <= $x; $i++) {
	if ($q[$i] != $q[$i - 2]) {
		if (DEBUG) {
			echo $i . " " . $q[$i] . PHP_EOL;
		}

	}
}

fscanf(STDIN, "%d", $Q);
for ($i = 0; $i < $Q; $i++) {
	fscanf(STDIN, "%d %d", $l, $r);
	echo ($q[$r] - $q[$l - 1]) . PHP_EOL;
}


Measured memory_bytes: 13176
#include<iostream>
#include<vector>
#include<cstring>
#include<climits>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

ll n;
ll a[MAX],b[MAX],c[MAX];

void bottomUP(){
    ll dp[n][3];
    dp[0][0] = a[0], dp[0][1]=b[0], dp[0][2]=c[0];

    for(int i=1; i<n; i++){
        // if ith day I perform a activity, then what's the max points I have got on (i-1)th day,
        // by not performing a activity
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]); 
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]); 
        // cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }
 
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

int main(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    bottomUP();
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,k;cin >> n>>k;
    vl h(n);rep(i,n)cin >> h[i];
    vl dp(n,INF);dp[0]=0;
    rep(i,n){
        rep(j,k+1){
            if(i+j>=n)break;
            chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    //rep(i,n)cout << dp[i] <<endl;
    cout << dp[n-1] <<endl;
}

Measured memory_bytes: 4684
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

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

using ll = long long;

using namespace std;

int main(){

  std::vector<int> a,b,c;
  int n;
  int k = 0;

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

  ++k;
  b.resize(n);
  c.resize(k);

  for( int i = 0; i < k; ++i){
    c[i] = 0;
  }

  for( int j = 0; j < n; ++j){
    ++c[a[j]];
  }

  for( int i = 1; i < k; ++i){
    c[i] = c[i] + c[i-1];
  }

  for( int j = n-1; j >= 0; --j){
    b[c[a[j]]-1] = a[j];
    --c[a[j]];
  }

  for( int i = 0; i < n-1; ++i){
    cout << b[i] << " ";
  }
  cout << b[n-1] << endl;
}

Measured memory_bytes: 18344
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;


int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;

   for ( int i = 0; cin >> ch; i++ ) {
       if ( ch == '\\' ) S1.push(i);
       else if ( ch == '/'  && S1.size() > 0) {
           int j = S1.top();
           S1.pop();
           int a = i - j;
           sum += a;
           while ( S2.size() > 0 && S2.top().first > j ) {
               a += S2.top().second;
               S2.pop();
       } 
       S2.push(make_pair(j, a));
       }
   }

   vector<int> ans;
   while ( S2.size() > 0 ) {
       ans.push_back(S2.top().second);
       S2.pop();
   }
   reverse(ans.begin(), ans.end());
   cout << sum << endl;
   cout << ans.size();
   for ( int i = 0; i < ans.size(); i++ ) {
       cout << " ";
       cout << ans[i];
   }
   cout << endl;
   return 0;
}



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

int main(){
	using ll = long long ;
	ll n ; cin >> n ;
	ll a,b ;
	a = b = 1 ;
	for(int i=0;i<n;i++){
		ll T,A ;
		cin >> T >> A ;
		ll sub = max((a+T-1)/T,(b+A-1)/A) ;
		a = T*sub ;
		b = A*sub ;
	}
	cout << a+b << endl ;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int i =(a) ; i <= (b); i++)
#define REP(i,n)  FOR( i, 0, (n) - 1 )
#define max(a,b) a > b ? a : b;

int main(){
  int a,b,c; cin >> a >> b >> c;
  if(b < c) swap(b,c);
  if(a < b) swap(a,b);
  cout << 10 * a + b + c << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int a,b;
    cin >> a>> b;
    int h=100,w=100;
    int g[100][100];
    rep(i,100){
        rep(j,100){
            if(i<50){
                g[i][j]=0;
            }else{
                g[i][j]=1;
            }
        }
    }
    a--;b--;
    int ith=1,itw=1;
    while(a>0){
        g[ith][itw]=1;
        a--;
        if(itw<98){
            itw+=2;
        }else{
            itw=1;
            ith+=2;
        }
    }
    ith=51;itw=1;
    while(b>0){
        g[ith][itw]=0;
        b--;
        if(itw<98){
            itw+=2;
        }else{
            itw=1;
            ith+=2;
        }
    }
    cout<<h<<' '<<w<<endl;
    rep(i,100){
        rep(j,100){
            if(g[i][j]==1){
                cout<<'.';
            }else{
                cout<<'#';
            }
            if(j==99){
                cout<<endl;
            }
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	long long n; scanf ("%lld", &n);

	int d[64] = { 0, };
	for (int i = 1; i < 64; i++){
		for (int j = 63 - i; j >= 0; j--){
			d[j + i] = max(d[j + i], d[j] + 1);
		}
	}

	int ans = 0;
	for (long long i = 2; i*i <= n; i++) if (n % i == 0){
		int c = 0;
		while (n % i == 0) n /= i, c++;
		ans += d[c];
	}
	if (n > 1) ans++;
	printf ("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3200