akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int rev = 0;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int T,F;
    string C;
    string forward="";
    string back = "";
    for(int i=0; i<Q; i++){
        cin >> T;
        if(T==1){
            rev = (rev+1)%2;
        }else{
            cin >> F >> C;
            if((F+rev)%2) forward=C+forward;
            else back +=C;
        }
    }
    string ans = forward + S + back;
    if(rev) reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 1360
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int D, E;

int main() {
    while(cin >> D >> E, D&&E){
        double minV = 10000.0;
        int x, y;
        for(int i=0; i<=D/2; ++i){
            x=i; y=D-i;
            double temp = sqrt(x*x+y*y)-E;
            if(temp<0) temp*=-1;
            minV = min((double)minV, temp);
        }
        cout << fixed << minV << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

#define MAX 45

int F[MAX];

int fibonacci(int);

int main()
{
  int n, i;
  int fib[MAX];

  scanf("%d", &n);

  for( i = 0 ; i < MAX ;i++ ) F[i] = -1;

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

int fibonacci(int n)
{
  if( n == 0 || n == 1 ) return F[n] = 1;
  if( F[n] != -1 ) return F[n];
  
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pb push_back
int cnt[2005];
vector<int>E[200005];
ll jc[200005];
ll sum[200005];
ll dp[200005];
const ll mod=1e9+7;
ll ans[200005];
ll ap(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll ad(ll a,ll b)
{
	return ((a%mod)+(b%mod))%mod;
}
ll ksm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)res=ap(res,a);
		a=ap(a,a);
		b/=2;
	}
	return res;
}
void dfs(int u,int fa)
{
	//cout<<u<<endl;
	ll now=1;
	sum[u]=1;
	if(E[u].size())
	rep(i,0,E[u].size()-1)
	{
		int v=E[u][i];
		if(v==fa)continue;
		dfs(v,u);
		now=ap(now,dp[v]);
		now=ap(now,ksm(jc[sum[v]],mod-2));
		sum[u]+=sum[v];
	}
	now=ap(now,jc[sum[u]-1]);
	dp[u]=now;
//	cout<<u<<" "<<now<<endl;
}
void swap(int u,int v)
{
	ll now=dp[u];
	now=ap(now,ksm(jc[sum[u]-1],mod-2));
	now=ap(now,jc[sum[u]-1-sum[v]]);
	now=ap(now,ksm(dp[v],mod-2));
	now=ap(now,jc[sum[v]]);
	dp[u]=now;
	ll now2=dp[v];
	now2=ap(now2,ksm(jc[sum[v]-1],mod-2));
	sum[u]-=sum[v];
	sum[v]+=sum[u];
	now2=ap(now2,jc[sum[v]-1]);
	now2=ap(now2,dp[u]);
	now2=ap(now2,ksm(jc[sum[u]],mod-2));
	//if(v==2)cout<<sum[v]<<"??"<<endl;
	dp[v]=now2;
}
void dfs2(int u,int fa)
{
	ans[u]=dp[u];
//	if(u==2)cout<<dp[1]<<"?"<<endl;
	if(E[u].size())
	rep(i,0,E[u].size()-1)
	{
		int v=E[u][i];
		if(v==fa)continue;
		swap(u,v);
		dfs2(v,u);
		swap(v,u);
	}
}
int main(int argc, char** argv) {
	int n;
	cin>>n;
	jc[0]=1;
	rep(i,1,n)
	{
		jc[i]=ap(jc[i-1],i);
	}
	rep(i,1,n-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		E[x].pb(y);
		E[y].pb(x);
	}
	dfs(1,-1);
	dfs2(1,-1);
	//cout<<dp[2]<<endl;
	rep(i,1,n)
	printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 20212
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
using namespace std;
#define MAXN 21
int n , k , dp[1 << 21][21];
char ch[1 << 21];
int main() {
    cin >> n >> k;
    for( int i = 0 ; i <= n ; ++ i ) {
        scanf("%s",ch);
        for( int j = 0 ; j < ( 1 << i ) ; ++ j )
            dp[( 1 << i ) | j][i] = ( ch[j] == '1' );
    }
    for( int i = n ; i >= 0 ; -- i ) {
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) // sta : ( 1 << i ) | j
            for( int k = i ; k >= 0 ; -- k ) if( dp[( 1 << i ) | j][k] ) {
                int S = ( j >> k ) , T = ( j & ( 1 << k ) - 1 ) , f = dp[( 1 << i ) | j][k];
                if( k ) dp[( 1 << i - k ) | S][0] += f;
                int ls = T & ( 1 << k ) - 1 , re = (~T) & ( 1 << k ) - 1;
                if( T ) {
                    int u = 31 - __builtin_clz( ls );
//                    cout << ls << ' ' << u << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( 1 << u ) | ( T & ( 1 << u ) - 1 )][u] += f;
                }
                if( re ) {
                    int u = 31 - __builtin_clz( re );
//                    cout << T << ' ' << u << ' ' << k << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( T & ( 1 << u ) - 1)][u] += f;
                }
            }
    }
    for( int i = n ; i >= 0 ; -- i )
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) if( dp[( 1 << i ) | j][0] >= k ) {
            for( int k = i - 1 ; k >= 0 ; -- k ) printf("%d",( j >> k ) & 1);
            return 0;
        }
}

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

int main()
{
    string s, res = "AC";
    int c_check = 0;
    cin >> s;
    for(int i = 1; i < s.length(); i++){
      if((s[i] != 'C' || i == s.length()-1) && ( s[i] < 97 || s[i] > 122 )){
        res = "WA";
      }
      if(i>1 && i<s.length()-1 && s[i] == 'C') c_check++;
    }
    if(s[0]!='A' || c_check != 1) res = "WA";
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 2000000000;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	int T; cin >> T;
	rep(i, T){
		int N, f = 0; cin >> N;
		ll A[N];
		rep(i, N) cin >> A[i];
		string S; cin >> S;
		vector<ll> basis;
		for(int j=S.size()-1; j>=0; j--){
			if(S[j] == '0'){
				for(auto b : basis) chmin(A[j], A[j]^b);
				if(A[j]){
					for(auto b : basis) chmin(b, b^A[j]);
					basis.pb(A[j]);
				}
			}else{
				for(auto b : basis) chmin(A[j], A[j]^b);
				if(A[j]) f = 1;
			}
		}
		cout << f << endl;
	}
	return 0;
}


Measured memory_bytes: 3588
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(b>d)cout<<1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}
int32_t main()
{
	k_007();
	// int JUDGE_ONLINE = 1;
	// if (fopen("ip1.txt", "r")) {
	// 	JUDGE_ONLINE = 0;
	// 	assert(freopen("ip1.txt", "r", stdin));
	// 	assert(freopen("op1.txt", "w", stdout));
	// }
	int a,b;
	cin>>a>>b;
	if((a==1&&b==2) || (b==1&&a==2))
	{
		cout<<3<<endl;
	}
	else if((a==2 && b ==3) || (b==2 && a ==3))
	{
		cout<<1<<endl;
	}
	else if((a==3 && b==1) || (a==1 && b==3))
	{
		cout<<2<<endl;
	}
	// if (!JUDGE_ONLINE) {
	// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	// }
}


Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int H,W;
  cin>>H>>W;
  vector<vector<char> > mat;
  for (int i = 0; i < H; i++)
  {
    vector<char> vec(W);
    bool check = 0;
    // DEBUG("call");
    for (int j = 0; j < W; j++)
    {
      char A;
      cin>>A;
      vec[j] = A;
      if(A == '#') check = 1;
      
    }

    if(check == 1)mat.push_back(vec);
    
  }
  // DEBUG(mat);
  vector<int> check(W,false);
  for (int j = 0; j < W; j++)
  {
    bool ok = true;
    for (int i = 0; i < mat.size(); i++)
    {
      if(mat[i][j] =='#') ok =false;
    }
    check[j] = ok;
  }
  

  for (int i = 0; i < mat.size(); i++)
  {
    for (int h = 0; h < W; h++)
    {
      if(check[h] == false)
      {
        cout<<mat[i][h];
      }
    }
    cout<<endl;
  }
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
# cook your dish here
#import numpy as np
n=int(input())
a = list(map(int,input().split()))

c =0
k = 0

for i in range(1,n):
    if a[i] == a[i-1]:
        k += 1
        if k %2 == 1:
            c += 1
    else:
        k = 0
print(c)

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]

P = []
def dfs(dmax, now):
    if len(now) == N:
        P.append(now)
        return
    for n in range(dmax, M+1):
        dfs(n, now+[n])
dfs(1, [])
ans = 0
for A in P:
    score = 0
    for a, b, c, d in ABCD:
        if A[b-1] - A[a-1] == c:
            score += d
    ans = max(ans, score)

print(ans)

Measured memory_bytes: 93396
#include<stdio.h>

int main()
{
  long a,b,c,x,y;
  
  scanf("%ld%ld%ld%ld%ld",&a,&b,&c,&x,&y);
  
  long long ans=0;
  if(a+b<=2*c)
  {
    ans=a*x+b*y;
  }
  else
  {
    int max=(x>y)?x:y;
    int min=(max==x)?y:x;
    int rest=(max==x)?a:b;
    
    int tmp1=c*2*max;
    int tmp2=c*2*min+rest*(max-min);
    
    if(tmp1<tmp2)
    {
      ans=tmp1;
    }
    else
    {
      ans=tmp2;
    }
  }
  
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=200005;
const int MOD=1e9+7;
const int Inv=500000004;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==0) return 1;
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
int JC[N],inv[N];
void Init (int n)
{
	JC[0]=1;for (int u=1;u<=n;u++) JC[u]=mul(JC[u-1],u);
	inv[n]=Pow(JC[n],MOD-2);
	for (int u=n-1;u>=0;u--) inv[u]=mul(inv[u+1],u+1);
}
int C (int x,int y)	{return mul(JC[x],mul(inv[y],inv[x-y]));}
int a[N],b[N];
int f[4005][4005]; 
int main()
{
	Init(8000);
	int n;
	scanf("%d",&n);
	for (int u=1;u<=n;u++)	
	{
		scanf("%d%d",&a[u],&b[u]);
		f[2001-a[u]][2001-b[u]]++;
	}
	for (int u=1;u<=4002;u++)
	for (int i=1;i<=4002;i++)
	f[u][i]=add(f[u][i],add(f[u-1][i],f[u][i-1]))%MOD;
	int ans=0;
	for (int u=1;u<=n;u++) 
	{
		ans=add(ans,f[a[u]+2001][2001+b[u]]);
		//printf("YES:%d\n",f[a[u]+2001][b[u]+2001]);
		ans=dec(ans,C(a[u]*2+b[u]*2,a[u]*2));
	}
	ans=mul(ans,Inv);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

int n, m, q;
int a[50], b[50], c[50], d[50];
int A[50];

int dfs(int depth, int cur) {
    if (depth >= n) {
        int sum = 0;
        rep(i, q) {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
                sum += d[i];
            }
        }
        return sum;
    }

    int best = 0;
    for (int i = cur; i <= m; i++) {
        A[depth] = i;
        int score = dfs(depth + 1, i);
        best = max(score, best);
    }
    return best;
}

int main()
{
    cin >> n >> m >> q;
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    put(dfs(0, 1));
    
    
    return 0;
}

Measured memory_bytes: 3608
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 52;

int N;
string s1, s2;

ll dp[MAX_N][3][3];

ll paint(int i, int c0, int c1);

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

    cin >> N;

    cin >> s1;

    cin >> s2;

    memset(dp, -1, sizeof(dp));

    ll ans = 0;
    if (s1[0] == s2[0]) {
        for (int i = 0; i < 3; i++) {
            ans = (ans + paint(0, i, i)) % MOD;
        }
    } else {
        ans = ((paint(0, 0, 1) + paint(0, 0, 2)) % MOD + paint(0, 1, 2)) % MOD;
        ans = (ans * 2) % MOD;
    }

    cout << ans << "\n";

    return 0;
}

ll paint(int i, int c0, int c1)
{
    if (dp[i][c0][c1] != -1) {
        return dp[i][c0][c1];
    }
    if (i == N - 1) {
        return dp[i][c0][c1] = 1;
    }
    if (c0 == c1) {
        if (s1[i + 1] == s2[i + 1]) {
            return dp[i][c0][c1] = (paint(i + 1, (c0 + 1) % 3, (c0 + 1) % 3) + paint(i + 1, (c0 + 2) % 3, (c0 + 2) % 3)) % MOD;
        } else {
            return dp[i][c0][c1] = (paint(i + 1, (c0 + 1) % 3, (c0 + 2) % 3) + paint(i + 1, (c0 + 2) % 3, (c0 + 1) % 3)) % MOD;
        }
    } else {
        if (s1[i] == s1[i + 1]) {
            return dp[i][c0][c1] = paint(i + 1, c0, c1);
        } else {
            int c2 = 3 - (c0 + c1);
            if (s1[i + 1] == s2[i + 1]) {
                return dp[i][c0][c1] = paint(i + 1, c2, c2);
            } else {
                return dp[i][c0][c1] = ((paint(i + 1, c1, c0) + paint(i + 1, c1, c2)) % MOD + paint(i + 1, c2, c0)) % MOD;
            }
        }
    }
}

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

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

    string str = "No";

    for(int i = 0; i < 10; ++i){
        for(int j = 0; j < 10; ++j){
            if(i * j == n){
                str = "Yes";
            }
        }
    }

    cout << str << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  char c;
  cin >> c;

  switch (c) {
    case ('a'):
    case ('i'):
    case ('u'):
    case ('e'):
    case ('o'):
      out("vowel");
      return;
    default:
      out("consonant");
  }
}
int main(void) { solve(); }

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

int main() {
  string s[2];
  cin >> s[0] >> s[1];
  for(int i=0; i<s[0].size(); i++) {
    cout << s[0][i];
    if(i<s[1].size()) cout << s[1][i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    long N,T;
    cin>>N>>T;
    vector<long> A(N);
    priority_queue<long> que;
    map<long,long> mp;
    long now;
    long cnt=0;
    rep(i,N) cin>>A[i];
    reverse(A.begin(),A.end());
    rep(i,N-1){
        que.push(A[i]);
        now = A[i+1];
        mp[que.top()-now]++;
    }
    long ans=0,maxf=0;
    for(auto i:mp){
        if(maxf<i.first){
            maxf=i.first;
            ans=i.second;
        }
    }
    if(maxf<0) cout<<1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 8052
from itertools import permutations

N,M = map(int,input().split())

Matrix = [[False for i in range(N)] for j in range(N)]

for i in range(N) :
    Matrix[i][i] = True
for i in range(M) :
    row,col = map(int,input().split())
    row -= 1
    col -= 1
    Matrix[row][col] = True
    Matrix[col][row] = True

arange = range(2,N+1)

ans = 0
for pm in permutations(arange) :
    pm = [1] + list(pm)
    for row,col in zip(pm,pm[1:]) :
        row -= 1
        col -= 1
        if not Matrix[row][col] :
            break
    else :
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(){
	long long max, A, B, N, x;
	int i;

	scanf("%lld %lld %lld", &A, &B, &N);

	x = fmin(B-1, N);
	max = A*x/B - A*(x/B);

	printf("%lld", max);
	return 0;
}


Measured memory_bytes: 2152
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());

			int x = n, sum = 0;
			while (x > 0) {
				sum += x % 10;
				x /= 10;
			}
			if (n % sum == 0) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}

		}
	}
}


Measured memory_bytes: 27384
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  	int N;
  	cin >> N;
  
  	int *A = (int *)malloc(sizeof(int)*N);
    if (A == NULL) {
        printf("Memory cannot be allocated.");
    }
  
	for(int i=1; i<=N-1; i++){
    	cin >> A[i];
    }
  	
  	int *Out = (int *)malloc(sizeof(int)*N);
    if (Out == NULL) {
        printf("Memory cannot be allocated.");
    }
  	for(int i=0;i < N; i++){
		Out[i]=0;
    }
  
  	int num;
  	for(int i=1;i <=N-1; i++){
		num=A[i];
      	Out[num-1]++;
    }
  	for(int i=0;i < N;i++){
    	cout << Out[i] << endl;
    }
}

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


def main():
    n = int(input())
    csf = [list(map(int, input().split())) for _ in range(n-1)]
    arr = []
    for i in range(len(csf)):
        arr.append(csf[i:])

    for x in arr:
        ans = x[0][0] + x[0][1]
        for c, s, f in x[1:]:
            if ans > s:
                if ans % f == 0:
                    ans += c
                else:
                    ans += c + f - ans % f
            else:
                ans = c + s
        print(ans)
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
N,C,K = list(map(int,input().split()))
T = [int(input()) for _ in range(N)]

T.sort()

cnt = 0
passengers = 0
due = 0
for t in T:
  if passengers == 0:
    cnt +=1
    passengers += 1
    due = t + K
  elif passengers > 0 and passengers < C and t <= due:
    passengers +=1
  elif t > due or passengers == C:
    passengers = 1
    due = t + K
    cnt +=1
  #print(t, passengers, due, cnt)

print(cnt)

Measured memory_bytes: 7484
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,x;
	scanf("%d %d %d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
	x=a+b+c+d+e+f+g+h+i+j;
	printf("%d\n",x);
	return 0;
}	

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

int main() {
  int n;
  cin>>n;
  vector<long long>a(100001);
  for(int i=0;i<n;i++){
    long long x;
    cin>>x;
    a[x]++;
  }
  int q;
  cin>>q;
  long long ans=0;
  for(int i=0;i<100001;i++){
    ans+=a[i]*i;
  }
  for(int i=0;i<q;i++){
    int b,c;
    cin>>b>>c;
    ans-=a[b]*b;
    ans+=a[b]*c;
    a[c]+=a[b];
    a[b]=0;
    cout<<ans<<endl;
  }
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n;

long long solve();
bool ch(long long x);

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for(long long i = 1; i * i <= n; ++i)
    if(n % i == 0) {
      if(i != 1 && ch(i)) ++res;
      if(i * i != n && ch(n / i)) ++res;
    }
  long long p = n - 1;
  for(long long i = 1; i * i <= p; ++i)
    if(p % i == 0) {
      if(i != 1) ++res;
      if(i * i != p) ++res;
    }
  return res;
}

bool ch(long long x) {
  long long now = n;
  while(now % x == 0) now /= x;
  return now % x == 1;
}

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

int main()
{
    int day;
    cin >> day;
    switch (day)
    {
    case 25:
        cout << "Christmas" << endl;
        break;
    case 24:
        cout << "Christmas Eve" << endl;
        break;
    case 23:
        cout << "Christmas Eve Eve" << endl;
        break;
    case 22:
        cout << "Christmas Eve Eve Eve" << endl;
        break;
    default:
        break;
    } 
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
int n;
int *S;

bool binarysearch(int k){
	int left = 0;
	int right = n;
	int mid;
	while(left < right){
		mid = (left + right)/2;
		if(S[mid] == k){
			return true;
		}
		if(k > S[mid]){
			left = mid + 1;
		}else if(k < S[mid]){
			right = mid;
		}
	}
		return false;
}

int main(){
	int count = 0;
	cin >> n;
	S = new int[n];
	for(int i = 0;i < n;i++){
		cin >> S[i];
	}
	int q;
	cin >> q;
	int data;
	for(int j = 0;j < q;j++){
		cin >> data;
		if(binarysearch(data)) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1568
#include<stdio.h>
 
#define M 100
#define INFTY (1 << 21)
 
int a[M + 2];
int b[M+1][M+1]; 
int c[M+1][M+1]; 
 
int matrix_cost(n){
    int i,j,k,d;
    int s = n;
    for (i=1;i<=n;i++) {
        for(j=1;j<=n;j++) {
            b[i][j] = INFTY;
        }
        b[i][i] = 0;
    }
 
    for(j=1;j<=s-1;j++){
        for(i=1;i<=s-j;i++){
            for(k=i+1;k<=i+j;k++){
                d = b[i][k-1] + b[k][i+j] + a[i]*a[k]*a[i+j+1];
                if(d<b[i][i+j]){
                    b[i][i+j] = d;
                    c[i][i+j] = k;
                }
            }
        }
    }
     
    return b[1][s];
}
 
int main(void) {
    int i, n;
    scanf("%d\n", &n);
    for(i=1;i<=n;i++) {
        scanf("%d %d\n", &a[i], &a[i+1]);
    }
     
    printf("%d\n", matrix_cost(n));
    return 0;
}

Measured memory_bytes: 680
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b,mx,mn;
scanf("%d",&n);
scanf("%d %d",&a,&b);
mx=a;mn=b;
for(int i=1;i<n;++i){
scanf("%d %d",&a,&b);
mx=max(a,mx);
mn=min(b,mn);
}
printf("%d\n",mx+mn);
return 0;
}

Measured memory_bytes: 256
<?php

$a = explode(' ', trim(fgets(STDIN)));

$left = '';

for ($i = 0; $i < (int)$a[1]; $i++) {
    $left .= $a[0];
}

$right = '';

for ($i = 0; $i < (int)$a[0]; $i++) {
    $right  .= $a[1];
}

$arr = [$left, $right];
sort($arr);

echo $arr[1];


Measured memory_bytes: 4728
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa=[0]
bb=[0]
a_sum=0
b_sum=0

for i in range(n):
    if (a_sum+a[i])<=k:
        a_sum+=a[i]
        aa.append(a_sum)
    else:
        break
for i in range(m):
    if (b_sum+b[i])<=k:
        b_sum+=b[i]
        bb.append(b_sum)
    else:
        break

#print(aa)
#print(bb)
cnt=len(bb)-1
ans=0
for i in range(len(aa)):
    for j in range(cnt,-1,-1):
        if bb[j]<=(k-aa[i]):
            cnt=j
            ans=max(ans,(i+j))
            break
print(ans)

Measured memory_bytes: 42448
n = int(input())
results = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    if ans >= 3:
        break
    if results[i][0] == results[i][1]:
        ans += 1
    else:
        ans = 0
if ans >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9084
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,M,X=LI()
AS=LI()

bef=0
aft=0
for i in AS:
    if i <= X:
        bef += 1
    else:
        aft += 1

print(min(bef, aft))


Measured memory_bytes: 9232
import sys

A, B = [int(x) for x in input().split()]
S = input()

if (len(S) != A + B + 1):
    print('No')
    sys.exit()

ng = False
for i in range(A):
    n = ord(S[i]) - ord('0')
    if (n < 0 or n > 9):
        ng = True

for i in range(A + 1, A + B + 1):
    n = ord(S[i]) - ord('0')
    if (n < 0 or n > 9):
        ng = True

if (S[A] != '-'):
    ng = True

print('Yes' if not ng else 'No')

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc170/tasks/abc170_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll X, N;
  cin >> X >> N;

  VL ps(N);
  rep(i, N) cin >> ps[i];

  ll res = 0;
  ll res_diff = X;

  rep1(target, 101) {
    if (any_of(all(ps), [&](ll p) { return p == target; })) continue;

    ll diff = abs(X - target);
    if (chmin(res_diff, diff)) {
      res = target;
    }
  }

  cout << res << "\n";
}


Measured memory_bytes: 3660
dish = [input() for i in range(5)]

a = []

for i in range(5):
    a.append(int(dish[i][-1]))

r = []

for i in range(5):
    r.append(int(dish[i]))
    
for i in range(5):
    if a[i] == 0:
        a[i] += 10

for i in range(5):
    if i != a.index(min(a)):
            r[i] += 10 - a[i]

print(sum(r))

Measured memory_bytes: 3064
class Dice
  def initialize(t, s, e, w, n, b)
    $north = n
    $south = s
    $east = e
    $west = w
    $top = t
    $bottom = b
  end

  def execute_orders(orders)
    length = orders.length
    for i in 0...length
      if orders[i] == "N"
        move_north
      elsif orders[i] == "S"
        move_south
      elsif orders[i] == "E"
        move_east
      elsif orders[i] == "W"
        move_west
      else
        puts "error!"
      end
    end
  end

  def check_dices_same(order_t, order_s, order_e, order_w, order_n, order_b)
    100.times do
      execute_orders(["N", "E"].sample)
      if $top == order_t && $south == order_s && $east == order_e && $west == order_w && $north == order_n && $bottom == order_b
        return true
        break
      end
    end
    return false
  end


  private
  def move_north
    north = $north
    south = $south
    top = $top
    bottom = $bottom
    $north = top
    $top = south
    $bottom = north
    $south = bottom
  end

  def move_south
    north = $north
    south = $south
    top = $top
    bottom = $bottom
    $south = top
    $bottom = south
    $north = bottom
    $top = north
  end

  def move_east
    top = $top
    bottom = $bottom
    east = $east
    west = $west
    $east = top
    $bottom = east
    $west = bottom
    $top = west
  end

  def move_west
    top = $top
    bottom = $bottom
    east = $east
    west = $west
    $west = top
    $bottom = west
    $east = bottom
    $top = east
  end
end

dice_numbers_1 = gets.chomp.split.map(&:to_i)
dice_numbers_2 = gets.chomp.split.map(&:to_i)
dice1 = Dice.new(dice_numbers_1[0], dice_numbers_1[1], dice_numbers_1[2], dice_numbers_1[3], dice_numbers_1[4], dice_numbers_1[5])
if dice1.check_dices_same(dice_numbers_2[0], dice_numbers_2[1], dice_numbers_2[2], dice_numbers_2[3], dice_numbers_2[4], dice_numbers_2[5])
  puts "Yes"
else
  puts "No"
end

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

int main() 
{
    double N, S, A, T, x, D, AnsD, AnsP=1;
    cin >> N >> S >> A;
    
    for (int i=1; i<=N; i++)
    {
      	cin >> x;
        if (i==1) 
        {
           T = S-x*0.006;
           D = A-T;
           if (D<0) 
           {
             D = -D;
           }
           AnsD = D;
           continue;
        }
        T = S-x*0.006;
        D = A-T;
        if (D<0) D = -D;
        if (D<AnsD) 
        {
        	AnsD = D;
        	AnsP = i;
        }
    }
  	cout << AnsP << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}
struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};


void solve(){
  int n;
  cin>>n;
  string ans;
  while(n){
    n-=1;
    ans+=(char)('a'+n%26);
    n/=26;
  }
  reverse(all(ans));
  cout<<ans<<"\n";
}

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


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll= long long;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0)cout<<(b-a)/2<<endl;
    else cout<<min((a-1)+((b-a)+1)/2,(n-b)+(n-(a+(n-b))+1)/2)<<endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) if(isDebugMode) cout<<#x<<"="<<x<<","
#define debugarr(arr,N,M){if(isDebugMode) rep(i,N+1){rep(j,M+1)\
	{if(arr[i][j]==INF)printf(" INF");\
		else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};

bool isDebugMode=true;
//--------------------------------------//
int w;
string s;

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


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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    l = len(str(n))
    r = 0
    for i in range(3,l+1):
        for a in itertools.product(['3','5','7'], repeat=i):
            if '3' not in a or '5' not in a or '7' not in a:
                continue
            if i < l:
                r += 1
                continue
            t = int(''.join(a))
            if t <= n:
                r += 1

    return r


print(main())


Measured memory_bytes: 7880
#include <iostream>

int main(void)
{
    long long int K = 100;
    long long int X;
    long long int i = 0;
    scanf("%Ld", &X);
    while (K < X)
    {
        K += K / 100;
        i++;
    }
    printf("%Ld\n", i);
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+2;
double d;
bool ok(int x,int y){
	return sqrt(pow(x,2)+pow(y,2))<=d;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int ans=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
    	double x,y;
    	cin>>x>>y;
    	if(ok(x,y))ans++;
    }
    cout<<ans;



    
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;

int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    map<string,int> m;
    int cnt = 0;
    rep(i,n){
        string in;
        cin >> in;
        if(m.empty()){
            m.insert(make_pair(in,1));
            cnt++;
        }else{
            if(m.find(in) == m.end()){
                m.insert(make_pair(in,1));
            }else{
                m.at(in) += 1;
            }

        }
    }

    int max = 0;
    for (auto x : m){
        //cout << x.first << " => " << x.second << endl;
        if(max < x.second){
            max = x.second;
        }
    }

    for (auto x : m){
       // cout << x.first << " => " << x.second << endl;
        if(x.second == max){
            cout <<x.first << endl;
        }
    }

    



    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
main(){
  int N;
  cin >> N;
  int max_cnt = 0;
  for(int i=0;i<N;i++){
    int cnt=0;
    int n = N-i;
    while(true){
      if(n%2==0){
      n/=2;
      cnt++;
      max_cnt=max(cnt,max_cnt);
      } else {break;}
    }
  }
  int max_cnt_two=1;
  for(int i=0;i<max_cnt;i++){
    max_cnt_two*=2;
  }
  cout << max_cnt_two << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main()
{
    IOS;
    
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>>dp(n+1, vector<int>(m+1));
    // vector<vector<int>>store(n+1, vector<int>(m+1));
    int mx = 0;
    string str;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		if(s[i-1] == t[j-1]){
    			dp[i][j] = 1 + dp[i-1][j-1];
                // store[i][j] = 1;
    		}
    		else{
    			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    		}
    	}
    }

    int i = n, j=m;
    while(i && j){
        if(s[i-1]==t[j-1]){
            str.insert(str.begin(),s[i-1]);
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else j--;
        }
    }
    // for(int i=1;i<=n;i++)
    // mx = *max_element(dp[i].begin(),dp[i].end());
    // cout<<mx<<endl;
    cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 70784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

int c[2000];
signed main() {
	int a, b; cin >> a >> b;
	for (int d = 0; d < a; d++) {
		scanf("%d", &c[d]);
		c[a + d] = c[d];
	}
	int ans = 0;
	int i = 0;
	while (1) {
		int MIN = 1 << 29, MAX = 0;
		for (int j = 0; j < b; j++) {
			MIN = min(MIN, c[i + j]);
			MAX = max(MAX, c[i + j]);
		}
		ans += MAX - MIN;
		i += b;
		i %= a;
		if (i == 0)break;
	}
	cout << ans << endl;
}

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

int main(){
  int N;
  int Y;
  int a;
  int i;
  int j;
  cin>>N>>Y;
  for(i=0;i<=N;i++){
    int K =N-i;
    for(j=0;j<=K;j++){
      a =10000*i+5000*j+1000*(N-i-j);
      if(Y==a){
        cout<<i<<" "<<j<<" "<<N-i-j<<endl;
        return 0;
      }
    }
  }
  	cout<<"-1 -1 -1"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
vector<int> ver[MAXN];
long long Fdp[MAXN],Sdp[MAXN],m;
int n,fa[MAXN];

void Fdfs(int x){
	vector<int>::iterator it;
	for(it=ver[x].begin();it!=ver[x].end();++it)
		if(*it!=fa[x]) fa[*it]=x,Fdfs(*it),Fdp[x]=Fdp[x]*(Fdp[*it]+1)%m;
	return;
}

void Sdfs(int x){
	int len=ver[x].size();
	long long suf[len+10],pre[len+10];
	pre[0]=1,suf[len+1]=1;
	for(int i=1;i<=len;++i)
		pre[i]=pre[i-1]*(Fdp[ver[x][i-1]]+1)%m,suf[len-i+1]=suf[len-i+2]*(Fdp[ver[x][len-i]]+1)%m;
	for(int i=0;i!=len;++i){
		if(Sdp[ver[x][i]]!=-1) continue;
		int tmp1=Fdp[x],tmp2=Fdp[ver[x][i]];
		fa[ver[x][i]]=-1,fa[x]=ver[x][i];
		Fdp[x]=pre[i]*suf[i+2]%m,Fdp[ver[x][i]]=(Fdp[x]+1)*tmp2%m;
		Sdp[ver[x][i]]=Fdp[ver[x][i]],Sdfs(ver[x][i]);
		fa[x]=-1,fa[ver[x][i]]=x;
		Fdp[x]=tmp1,Fdp[ver[x][i]]=tmp2;
	}
	return;
}

int main(){
	memset(Sdp,-1,sizeof(Sdp));
	cin>>n>>m;
	fill(Fdp+1,Fdp+n+1,1);
	for(int i=1,a,b;i<n;cin>>a>>b,ver[a].push_back(b),ver[b].push_back(a),++i);
	fa[1]=-1,Fdfs(1),Sdp[1]=Fdp[1],Sdfs(1);
	for(int i=1;i<=n;++i) cout<<Sdp[i]<<endl;
	return 0;
}

Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size()/2; i++){
        if(s[i] != s[s.size()-i - 1]) ans++;
    }

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

Measured memory_bytes: 256
import math
N = input()
As =  list(map(int,input().split(" ")))
Bs =  list(map(int,input().split(" ")))
Cs =  list(map(int,input().split(" ")))

ans = 0
for i,a in enumerate(As):

    ans += Bs[a-1]

    if i != 0:
        if a - 1 == As[i-1]:
            ans +=Cs[a - 2]



print(ans)

Measured memory_bytes: 38256