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

int main(void){

    int A,B; cin>>A>>B;
    int cnt=0;
    for (int i = A; i <= B; ++i) {
        int tmp=i,j=0;
        vector<int> vec(5);
        vector<int> vec2(5);
        while(tmp>0){
            vec[j] = tmp%10;
            tmp /= 10;
            j++;
        }
        for (int k = 0; k < 5; ++k) {
            vec2[k] = vec[k];
        }
        reverse(vec2.begin(), vec2.end());
        bool ok = true;
        if(vec == vec2) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
T = Array.new(N) do
  Array.new(gets.to_i) do
    gets.split.map(&:to_i)
  end
end

def ok?(bistr)
  N.times do |j|
    next if bistr[j] == '0'

    T[j].each do |x, y|
      return false if bistr[x - 1] != y.to_s
    end
  end

  return true
end

count = Array.new(2**N) do |number|
  bistr = number.to_s(2).rjust(N, '0')
  ok?(bistr) ? bistr.count('1') : 0
end.max

puts count


Measured memory_bytes: 2044
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Char (isSpace)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.Vector.Mutable (IOVector, STVector)
import qualified Data.Vector.Mutable as VM

main :: IO ()
main = do
  
  solve <$> readLn <*> f >>= print
  where
    f = readiv B.readInt <$> B.getLine

solve :: Int -> Vector Int -> Int
solve n hv = runST $ do
  h <- V.thaw hv
  cst <- VM.replicate n 0
  h0 <- VM.read h 0
  h1 <- VM.read h 1
  VM.write cst 1 (abs $ h1 - h0)
  forM_ [2 .. n-1] $ \i -> do
    hi_2 <- VM.read h (i - 2)
    hi_1 <- VM.read h (i - 1)
    hi_0 <- VM.read h i
    ci_2 <- VM.read cst (i - 2)
    ci_1 <- VM.read cst (i - 1)
    VM.write cst i (min (ci_2 + (abs $ hi_0 - hi_2)) (ci_1 + (abs $ hi_0 - hi_1)))
  VM.read cst (n - 1)

readiv :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> Vector a
readiv f = V.unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


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

#define INF 1e9
using namespace std;

int main() {

    string S; cin >> S;

    int a = (S[0] - '0') * 10 + S[1] - '0';
    int b = (S[2] - '0') * 10 + S[3] - '0';

    if ((a == 0 && 13 <= b) || (b == 0 && 13 <= a)) {
        cout << "NA" << endl;
        return 0;
    }

    if (1 <= a && a <= 12 && 1 <= b && b<= 12 ) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if (1 <= a && a <= 12) {
        cout << "MMYY" << endl;
        return 0;
    }

    if (1 <= b && b <= 12) {
        cout << "YYMM" << endl;
        return 0;
    }

    cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
//aea ctmr
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//v.erase(unique(v.begin(),v.end()),v.end());
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
 
 
typedef long double ld;
typedef long long ll;
const ll N = 2500;
const ll mod = 1e+9 + 9;
const ld PI = acos(-1);
const ll INF = 1e+18;
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif

int xd[N];

void solve(){
    int n, x, y;
    cin >> n >> x >> y;
    if(x > y) swap(x, y);
    int ans;
    for(int i = 1; i <= x - 1; i++){
        for(int j = i + 1; j <= x - 1; j++){
            ans = j - i; xd[ans]++;
        }
        for(int j = x; j <= y; j++){
            ans = x - i + min(j - x, 1 + y - j); xd[ans]++;
        }
        for(int j = y + 1; j <= n; j++){
            ans = x - i + j - y + 1; xd[ans]++;   
        }
    }
    for(int i = x; i <= y; i++){
        for(int j = i + 1; j <= y; j++){
            ans = min(j - i, 1 + i - x + y - j); xd[ans]++;
        }
        for(int j = y + 1; j <= n; j++){
            ans = j - y + min(y - i, i - x + 1); xd[ans]++;   
        }
    }
    for(int i = y + 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            ans = j - i; xd[ans]++;
        }
    }
    
    for(int i = 1; i < n; i++){
        cout << xd[i] << endl;
    }
}

int main(){
    fastio;
    
    int tc;
    //cin >> tc;
    tc = 1;
    while(tc--) solve();
    
    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++)
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; 

static const long long INF = 1e18;

using lll = __int128_t;

ll popcount(lll x) {
    ll c = 0;
    rep(i, 128) 
        c += !!(x & ((lll)1 << i));
    return c;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, qnum; 
    while (cin >> n >> qnum && n && qnum) {
        vector<ll> a(qnum); 
        rep(i, qnum) rep(j, n) { 
            char c; cin >> c; 
            if (c - '0') 
                a[i] |= 1ll << j; 
        }

        map<lll, ll> memo; // 1 if impossible
        function<ll(lll, ll)> f = [&](lll x, ll counter) -> ll {
            if (popcount(x) == qnum - 1) 
                return 0;
            if (popcount(x) == qnum) 
                return INF;
            if (memo.count(x)) 
                return memo[x];

            ll ret = INF;
            rep(j, n) {
                lll yes, no; yes = no = x; 
                rep(i, qnum) 
                    (a[i] & ((ll)1 << j) ? yes : no) |= (lll)1 << i;

                ll tmp = -1;
                ll yes_ret = INF, no_ret = INF; 
                if (yes != x)
                    yes_ret = f(yes, counter+1);
                if (no != x)
                    no_ret = f(no, counter+1);
                if (yes_ret != INF)
                    chmax(tmp, yes_ret);
                if (no_ret != INF)
                    chmax(tmp, no_ret);
                if (tmp != -1)
                    chmin(ret, tmp + 1);
            }
            return memo[x] = ret;
        };
        cout << f(0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 4588
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int r,c;


int main(){
    cin>>r>>c;
    char maze[r][c];
    queue<P> que;
    int d[r][c];
    for (int i=0;i<r;i++){
        for (int j=0;j<c;j++){
            cin>>maze[i][j];
            if (maze[i][j]=='#'){
                que.push(P(i,j));
                d[i][j]=0;
            } else {
                d[i][j]=1e8;
                //cout<<d[i][j]<<i<<j<<endl;
            }
        }
    }
    int dx[4]={0,-1,0,1};
    int dy[4]={1,0,-1,0};
    int ans=0;
    while(que.size()){
        P p=que.front();
        //cout<<p.first<<p.second<<endl;
        que.pop();
        for (int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            //cout<<nx<<ny;
            if (0<=nx && nx<r && 0<=ny && ny<c && d[nx][ny]==1e8){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
                //cout<<d[nx][ny]<<endl;
                ans=max(ans,d[nx][ny]);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}

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



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

using namespace std;

long long int gcd (long long int a,long long int b){

    if(a==0)return b;
    return gcd(b%a,a);

}


int main()
{
    long long int a,b,p,s;
    cin>>a>>b;
    s=a+b;
    p=(a<b)?a:b;
    cout<<(gcd(p,s-p))<<endl;

    return 0;

}



Measured memory_bytes: 3076
N = int(input())
A = list(map(int, input().split()))

cnt = [0] * 1000001

for i in A:
  if cnt[i] == 1:
    continue 
  if cnt[i] == 2:
    cnt[i] = 1
    continue
  cnt[i] = 2
  for j in range( (i+i),1000001,i):
    cnt[j] = 1
#
ans = 0
for i in range(1000001):
  if cnt[i] == 2:
    ans += 1
#
print(ans)


Measured memory_bytes: 32040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int LEN = 100005;

struct con{
  string name;
  int time;
};

con Q[LEN];
int head, tail;

void enqueue(con x) {
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

con dequeue() {
  con x = Q[head];
  head = (head+1)%LEN;
  return x;
}

int main() {
  int n, q, c, elaps;
  cin >> n >> q;
  rep(i, n) {
    cin >> Q[i].name >> Q[i].time;
  }
  head = 0;
  tail = n;
  con u;
  elaps = 0;
  while (head != tail) {
    u = dequeue();
    c = min(q, u.time);
    u.time -= c;
    elaps += c;
    if (u.time > 0) enqueue(u);
    else {
      cout << u.name <<" " << elaps << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int y,m,d;
  cin >> y;
  cin.ignore();
  cin >> m;
  cin.ignore();
  cin >> d;
  if (y < 2019) cout << "Heisei" << endl;
  else if (y == 2019) {
    if (m < 4) cout << "Heisei" << endl;
    else if(m == 4) {
      if (d <= 30) cout << "Heisei" << endl;
    }
    else cout << "TBD" << endl;
  }
  else cout << "TBD" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * Property Distribution
 */
public class Main {

	static char DISTRIBUTED = '\0';
	static Queue<int[]> queue;
	static int count;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {

			int h = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int w = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			// read in.
			char[][] prop = new char[h + 2][w + 2];
			for (int i = 1; i < h + 1; ++i) {
				line = br.readLine();
				for (int j = 1; j < w + 1; ++j) {
					prop[i][j] = line.charAt(j - 1);
				}
			}

			// solve
			queue = new ArrayDeque<int[]>();
			count = 0;
			for (int i = 1; i < h + 1; ++i) {
				for (int j = 1; j < w + 1; ++j) {
					if (prop[i][j] != DISTRIBUTED) {
						char fruit = prop[i][j];
						queue.offer(new int[] { i, j });
						while (!queue.isEmpty()) {
							distribute(prop, fruit);
						}
						++count;
					}
				}
			}
			// print
			System.out.println(count);
		}
	}

	static void distribute(char[][] prop, char fruit) {

		final int V[] = { 1, -1, 0, 0 };
		final int H[] = { 0, 0, 1, -1 };

		int xy[] = queue.poll();
		int x = xy[0];
		int y = xy[1];

		if (prop[x][y] == fruit) {

			// prop[x][y] = DISTRIBUTED;
			prop[x][y] ^= prop[x][y];

			for (int i = 0; i < 4; ++i) {
				int xv, yh;
				xv = x + V[i];
				yh = y + H[i];
				if (prop[xv][yh] == fruit) {
					queue.offer(new int[] { xv, yh });
				}
			}
		}
	}
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<typename F, typename G, typename H, typename T, typename S>
struct lazy_segment_tree {
    size_t offset, height;
    vector<T> data, lazy;

    const F f_;
    const G g_;
    const H h_;
    const T unit_;
    const S lazy_unit_;

    lazy_segment_tree(
        size_t size,
        const F f, const G g, const H h,
        const T unit, const S lazy_unit):
        f_(f), g_(g), h_(h), unit_(unit), lazy_unit_(lazy_unit) {
        offset = 1, height = 0;
        while (offset < size) offset <<= 1, height++;
        data.assign(offset << 1, unit);
        lazy.assign(offset << 1, lazy_unit);
        offset--;
    }

    void propagate(size_t i) {
        if (lazy[i] == lazy_unit_) return;
        lazy[i << 1 | 0] = h_(lazy[i << 1 | 0], lazy[i]);
        lazy[i << 1 | 1] = h_(lazy[i << 1 | 1], lazy[i]);
        data[i] = reflect(i);
        lazy[i] = lazy_unit_;
    }

    void thrust(size_t i) {
        for (size_t j = height; j > 0; j--) propagate(i >> j);
    }

    T reflect(size_t i) {
        return lazy[i] == lazy_unit_ ? data[i] : g_(data[i], lazy[i]);
    }

    void recalc(size_t i) {
        while (i >>= 1) data[i] = f_(reflect(i << 1 | 0), reflect(i << 1 | 1));
    }

    void update(size_t l, size_t r, const T x) {
        thrust(l += offset);
        thrust(r += offset - 1);
        for (size_t li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) {
            if (li & 1) lazy[li] = h_(lazy[li], x), li++;
            if (ri & 1) ri--, lazy[ri] = h_(lazy[ri], x);
        }
        recalc(l);
        recalc(r);
    }

    T query(size_t l, size_t r) {
        thrust(l += offset);
        thrust(r += offset - 1);
        T lv = unit_, rv = unit_;
        for (size_t li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) {
            if (li & 1) lv = f_(lv, reflect(li)), li++;
            if (ri & 1) ri--, rv = f_(reflect(ri), rv);
        }
        return f_(lv, rv);
    }
};

void solve() {
    i64 n, m;
    cin >> n >> m;

    vector<vector<p64>> p(n + 1);
    for (i64 i = 0; i < m; i++) {
        i64 l, r, a;
        cin >> l >> r >> a;
        p[r].emplace_back(l, a);
    }

    auto f = [&](i64 a, i64 b) { return max(a, b); };
    lazy_segment_tree dp(n, f, plus(), plus(), 0l, 0l);
    for (i64 i = 1; i <= n; i++) {
        dp.update(i, i + 1, dp.query(0, i));
        for (auto [ l, a ] : p[i]) dp.update(l, i + 1, a);
    }
    cout << dp.query(1, n + 1) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 22348
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) (a).begin(), (a).end()
#define pw(x) (1ll<<(x))
#define lb(x) ((x) & -(x))
#define endl "\n"
#define FI(x) freopen(#x".in","r",stdin)
#define FO(x) freopen(#x".out","w",stdout)
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
//typedef uniform_int_distribution<ll> RR;
const int P = 1e9 + 7;
//ll rnd(ll l, ll r) { mt19937 gen(rand()); RR dis(l, r); return dis(gen); }
int add(int a, int b) {if((a += b) >= P) a -= P; return a < 0 ? a + P : a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----

const int N = 3e5 + 7;
int f[N], p, n, m, ans, u, v; 
vi g[N]; 
void dfs(int u) {
	vi tmp;
	for (auto v : g[u]) {
		dfs(v);
		tmp.pb(f[v]);
	}
	sort(all(tmp));
	if (sz(tmp) == 0) f[u] = 0;
	else {
		int t = 1;
		per(i, 0, sz(tmp)) f[u] = max(f[u], tmp[i] + t), t++;
	}
	
}

int main() {
	//FI(a);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	cin >> n;
	rep(i, 2, n+1) {
		cin >> u;
		g[u].pb(i);
	}
	dfs(1);
	cout << f[1] << endl;
	return 0;
}



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

using namespace std;


int main(void)
{
    string S;
    cin >> S;

    if(S == "Sunny") cout << "Cloudy" << endl;
    else if(S == "Cloudy") cout << "Rainy" << endl;
    else if(S == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[500000],num=0;
int l[250005],r[250005];

void merg(int s,int e){
    int mid=(s+e)/2;
    int n1=mid-s+1,n2=e-mid;
    int i;
    for(i=0;i<n1;i++){
        l[i]=a[s+i];
    }
    for(i=0;i<n2;i++){
        r[i]=a[mid+i+1];
    }
    int m1=0,m2=0;
    for(i=0;i<e-s+1;i++){
        l[n1]=r[n2]=1000000005;
        if(l[m1]<=r[m2])a[s+i]=l[m1++];
        else a[s+i]=r[m2++];
    }
    num+=(e-s+1);
}

void mergesort(int s,int e){
    if(s==e)return;
    int mid=(s+e)/2;
    mergesort(s,mid);
    mergesort(mid+1,e);
    merg(s,e);
}

int main()
{
    int n;
    cin>>n;
    int i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    mergesort(0,n-1);
    for(i=0;i<n;i++){
        cout<<a[i];
        if(i!=n-1)cout<<" ";
    }
    cout<<endl;
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 6996
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

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

  int size = s.size();
  bool flag = 0;

  for(int i = 0; i < size; i++){
    if(s[i] != t[i]) flag = 1;
  }

  if(flag) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	long long px=1,py=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int t,a;
		scanf("%d%d",&t,&a);
		long long now=max((px+t-1)/t,(py+a-1)/a);
		px=now*t;
		py=now*a;
	}
	printf("%lld\n",px+py);
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

def solve(N, As):
    c = Counter(As)
    c.update([a + 1 for a in As])
    c.update([a - 1 for a in As])
    return max([v for v in c.values()])

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))



Measured memory_bytes: 22104
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readLongList()
    val aList = readLongList()

    var divCount = 0L
    for (a in aList) {
        val count = countDiv(a, 2)
        when {
            divCount == 0L -> divCount = count
            divCount != count -> {
                println(0)
                return
            }
        }
    }

    if (divCount == 0L) {
        println(0)
        return
    }

    var t = aList.first() / 2
    for (a in aList) {
        t = lcm(t, a / 2)
    }

    println((m / t + 1) / 2)
}


/** O(log(n)) */
tailrec fun countDiv(n: Long, divisor: Long, count: Long = 0L): Long =
    if (n % divisor == 0L) countDiv(n / divisor, divisor, count + 1) else count

/** O(log(n)): n = min(a, b) */
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

/** O(log(n)): n = min(a, b) */
fun lcm(a: Long, b: Long) = a / gcd(a, b) * b

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

int main() {
  int X=0,max_X=0,N;
  cin >> N;
  string S;
  cin >> S;
  for(int i=0;i<N;i++){
    if(S.at(i)=='I'){
      X++;
    }
    else{
      X--;
    }
    max_X=max(max_X,X);
  }
  cout << max_X << endl;
}

Measured memory_bytes: 3588
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n - 2):
  if (p[i] < p[i + 1] and p[i + 1] < p[i + 2]) or (p[i] > p[i + 1] and p[i + 1] > p[i + 2]):
    count += 1
print(count)

Measured memory_bytes: 3064
import sys
inp = lambda t: t(sys.stdin.readline().strip())
inpm = lambda t: map(t, sys.stdin.readline().split())
inpl = lambda t: list(map(t, sys.stdin.readline().split()))

n = inp(int)
l = inpl(int)

s = set()

a = 0
b = 0

for i in l:
	if i in s:
		if i > a and a < b:
			a = i
		elif i > b:
			b = i
		s.remove(i)
	else:
		s.add(i)

print(a * b)

Measured memory_bytes: 14344
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    inf = 2 * 10**9
    L = [inf, inf, inf]
    R = [-inf, -inf, -inf]
    U = [-inf, -inf, -inf]
    D = [inf, inf, inf]
    for _ in range(N):
        x, y, d = input().split()
        x = int(x) * 2
        y = int(y) * 2
        if d == 'L':
            L[0] = min(L[0], x)
            R[1] = max(R[1], x)
            U[2] = max(U[2], y)
            D[2] = min(D[2], y)
        elif d == 'R':
            L[1] = min(L[1], x)
            R[0] = max(R[0], x)
            U[2] = max(U[2], y)
            D[2] = min(D[2], y)
        elif d == 'U':
            L[2] = min(L[2], x)
            R[2] = max(R[2], x)
            U[0] = max(U[0], y)
            D[1] = min(D[1], y)
        else:
            L[2] = min(L[2], x)
            R[2] = max(R[2], x)
            U[1] = max(U[1], y)
            D[0] = min(D[0], y)

    def calc(t):
        if t < 0:
            return 10**20
        xmin = min(L[0] - t, L[1] + t, L[2])
        xmax = max(R[0] + t, R[1] - t, R[2])
        ymax = max(U[0] + t, U[1] - t, U[2])
        ymin = min(D[0] - t, D[1] + t, D[2])
        return (xmax - xmin) * (ymax - ymin)

    ans = calc(0)
    ans = min(ans, calc((L[0] - L[1]) // 2), calc(L[0] - L[2]), calc(L[2] - L[1]))
    ans = min(ans, calc((R[1] - R[0]) // 2), calc(R[2] - R[0]), calc(R[1] - R[2]))
    ans = min(ans, calc((U[1] - U[0]) // 2), calc(U[2] - U[0]), calc(U[1] - U[2]))
    ans = min(ans, calc((D[0] - D[1]) // 2), calc(D[0] - D[2]), calc(D[2] - D[1]))
    print(ans / 4)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42604
#include <iostream>
#include <vector>
#include <fstream>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

#define ll long long

ll myabs(ll x)
{
	return (x > 0 ? x : -x);
}

int main()
{
	int n = 0;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a.begin(), a.end());
	int ix = n / 2;
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		//cout << a[i] << " " << a[ix] << endl;
		ans += myabs(a[i] - a[ix]);
	}
	cout << ans << endl;
}


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

typedef long long ll;
const int maxn = 1e5 + 20;
int n, m;
std::set<int> G[maxn], P[maxn];

int fa[maxn];
int getFa(int u) {
    if(fa[u] == u)
        return u;
    return fa[u] = getFa(fa[u]);
}

void uniFa(int u, int v) {
    u = getFa(u);
    v = getFa(v);
    fa[u] = v;
}

int epl;

void addEdge(int u, int v) {
    G[u].insert(v);
    G[v].insert(u);
}
void delEdge(int u, int v) {
    G[u].erase(v);
    G[v].erase(u);
}

bool ins[maxn];
int labl, lab[maxn], S[maxn];

std::vector<int> hash(int l, int r) {
    std::vector<int> v;
    int mn = 0, mi = -1;
    for(int i = l; i < r; ++i) {
        if(S[i] > mn) {
            mi = i;
            mn = S[i];
        }
    }
    for(int i = mi; i < r; ++i) {
        v.push_back(S[i]);
    }
    for(int i = l; i < mi; ++i) {
        v.push_back(S[i]);
    }
    return v;
}

std::set<std::vector<int> > loop;

void dfs(int u, int f) {
    lab[u] = labl;
    ins[u] = true;
    S[labl] = u;
    ++labl;

    for(const auto &v : G[u])
    if(v != f) {
        if(ins[v]) {
            loop.insert(hash(lab[v], labl));
        } else {
            dfs(v, u);
        }
    }

    ins[u] = false;
    --labl;
}

int main() {
    scanf("%d%d", &n, &m);
    if(n <= 1 || m <= n - 1) {
        puts("0");
        return 0;
    }
    if(m == n) {
        puts("1");
        return 0;
    }
    for(int i = 0, u, v; i < m; ++i) {
        scanf("%d%d", &u, &v);
        addEdge(u, v);
    }
    for(int i = 1; i <= n; ++i) {
        fa[i] = i;
    }
    std::queue<int> q;
    for(int i = 1; i <= n; ++i) {
        if(G[i].size() == 1)
            q.push(i);
    }
    while(!q.empty()) {
        int u = q.front(); q.pop();
        // fprintf(stderr, "%d\n", u);
        int v = *G[u].begin();
        delEdge(u, v);
        if(G[v].size() == 1)
            q.push(v);
    }
    for(int i = 1; i <= n; ++i) {
        if(G[i].size() == 2) {
            auto iter = G[i].begin();
            int u = *iter++, v = *iter++;
            if(G[u].size() == 2 && G[u].find(v) == G[u].end() && G[v].size() == 2 && G[v].find(u) == G[v].end()) {
                delEdge(u, i);
                delEdge(v, i);
                addEdge(u, v);
                // fprintf(stderr, "u, i, v %d %d %d\n", u, i, v);
            }
        }
    }
    // fprintf(stderr, "aA\n");
    // for(int i = 1; i <= n; ++i) {
    //     int u = getFa(i);
    //     for(const auto &vp : G[i]) {
    //         int v = getFa(vp);
    //         if(u == v)
    //             continue;
    //         P[u].insert(v);
    //         fprintf(stderr, "%d %d\n", u, v);
    //     }
    // }
    for(int i = 1; i <= n; ++i) {
        int u = getFa(i);
        if(!G[u].empty()) {
            dfs(u, 0);
            break;
        }
    }
    printf("%d\n", loop.size() / 2);
    return 0;
}





Measured memory_bytes: 39948
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    if i % 2 == 0 and A[i] % 2 == 1:
        ans += 1

print(ans)



Measured memory_bytes: 9068
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) //cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    str s;
    cin >> s;
    bool h1 = false;
    bool h2 = false;
    fi(0, 3) {
        h1 |= s[i] == 'A';
        h2 |= s[i] == 'B';
    }
    cout << (h1 && h2 ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int k, s;
    int count = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int mayz  = s - x - y;
            if (0 <= mayz && mayz <= k) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 210000;
const int Ln = 22;
int n;
int a[MAXN];
int r[MAXN];
ll ans;
vector<int> g;

int main() {
	read(n);
	rep(i, 1, n) read(a[i]);
	rep(i, 1, n) r[i] = n;
	rep(k, 0, Ln - 1) {
		g.clear();
		rep(i, 1, n) {
			if ((a[i] & (1 << k))) {
				g.push_back(i);
			}
		}
		rep(i, 0, (int)g.size() - 1) {
			if (i != (int)g.size() - 1) {
				r[g[i]] = min(r[g[i]], g[i + 1] - 1);
			}
		}
	}
	for (int i = n - 1; i >= 1; --i) {
		r[i] = min(r[i], r[i + 1]);
	}
	ans = 0;
	rep(i, 1, n) {
		ans += (ll)r[i] - i + 1;
	}
	cout << ans << "\n";
	return 0;
} 


Measured memory_bytes: 2428
#include <iostream>
#include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
#define EPS 1e-10
#define EQ(a,b) (abs(a - b) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))

using namespace std;

typedef complex<double> P;

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

bool cmp_x (const P& p, const P& q) {
    if (p.real() != q.real()) return p.real() < q.real();
    else return p.imag() < q.imag();
}

vector<P> convex_hull (vector<P> ps) {
    int n = ps.size(), k = 0;
    vector<P> qs (n * 2);
    sort(ps.begin(), ps.end(), cmp_x);
    for (int i = 0; i < n; i++) {
        while (k > 1 && cross (qs[k-1] - qs[k-2], ps[i] - qs[k-1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--) {
        while (k > t && cross (qs[k-1] - qs[k-2], ps[i] - qs[k-1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k-1);
    return qs;
}

int main ()
{
    int n;
    while (cin >> n, n) {
        vector<P> ps;
        for (int i = 0; i < n; i++) {
            double a, b;
            scanf("%lf,%lf", &a, &b);
            ps.push_back(P(a,b));
        }

        vector<P> qs = convex_hull (ps);
        cout << (ps.size() - qs.size()) << endl;
    }

    return 0;
}

Measured memory_bytes: 1272
#include<stdio.h>
int main(void)
{
	int i,j,n,m,a[101],ten[101],x[100];
	scanf("%d",&n);
	scanf("%d",&m);
	for(i=0;i<m;i++)  scanf("%d",&x[i]);
	for(j=1;j<=n;j++)  ten[j]=0;
	for(i=0;i<m;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&a[j]);
			if(a[j]==x[i]){
				ten[j]=ten[j]+1;
			}
			else{
				ten[x[i]]=ten[x[i]]+1;
			}
		}
	}
	for(j=1;j<=n;j++) printf("%d\n",ten[j]);
	
	
	return 0;
	
}



Measured memory_bytes: 2716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  string s;
  cin >> s;
  vector<char> v1, v2;
  int sw = 0;
  int q;
  cin >> q;
  while(q--){
    int t;
    cin>> t;
    if(t == 1){
      sw ^= 1;
    }
    else{
      int c;
      cin >> c;
      char k;
      cin >> k;
      if(sw){
        if(c == 1) v2.push_back(k);
        else v1.push_back(k); 
      } 
      else{
        if(c == 1) v1.push_back(k);
        else v2.push_back(k);
      }
    }
  }
  if(sw){
    reverse(all(v2));
    reverse(all(s));
    for(char c : v2) cout << c;
    cout << s;
    for(char c : v1) cout << c;
  }
  else{
    reverse(all(v1));
    for(char c : v1) cout << c;
    cout << s;
    for(char c : v2) cout << c;
  }
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int MOD = 1000000007;
const int MAX = 1e6;

ll fact[MAX], fact_inv[MAX], inv[MAX];

void combInit(int SIZE) {
  // fact.resize(SIZE + 5);
  // fact_inv.resize(SIZE + 5);
  // inv.resize(SIZE + 5);
  fact[0] = fact[1] = 1;
  fact_inv[0] = fact_inv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < SIZE + 5; i++) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }
}

ll comb(int n, int k) {
  // assert(!(n < k));
  // assert(!(n < 0 || k < 0));
  return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main() {
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  int n = (2 * y - x) / 3;
  int m = (2 * x - y) / 3;
  // cout << n <<", "<< m << endl;
  combInit(n + m);
  ll ans = comb(n + m, n);
  cout << ans << endl;

  return 0;
}

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

int main(void)
{
	int dice[7];
	char str_o[6][7] = {"North", "East", "West", "South", "Right", "Left"};
	char str[7];
	int order;
	int num;
	int sum;
	int dice_n;
	int i;
	
	while (1){
		scanf("%d", &num);
		if (num == 0){
			break;
		}
		
		for (i = 0; i <= 6; i++){
			dice[i] = i;
		}
		
		sum = dice[1];
		while (num){
			scanf("%s", str);
			
			for (i = 0; i < 6; i++){
				if (!strcmp(str_o[i], str)){
					order = i + 1;
					break;
				}
			}
			
			switch (order){
				case 1:
				dice[0] = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				dice[6] = dice[5];
				dice[5] = dice[0];
				break;
				
				case 2:
				dice[0] = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[6];
				dice[6] = dice[3];
				dice[3] = dice[0];
				break;
				
				case 3:
				dice[0] = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[6] = dice[4];
				dice[4] = dice[0];
				break;
				
				case 4:
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[6];
				dice[6] = dice[2];
				dice[2] = dice[0];
				break;
				
				case 5:
				dice[0] = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[4];
				dice[4] = dice[0];
				break;
				
				case 6:
				dice[0] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[3];
				dice[3] = dice[0];
				break;
			}
			
			sum += dice[1];
			
			num--;
		}
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 1040
s = input()
n = len(s)
flg = True
if s == s[::-1]:
    if s[:(n-1) // 2] == s[:(n-1) // 2][::-1]:
        if s[(n+3) //2 - 1:] == s[(n+3) //2 - 1:][::-1]:
            flg = False
            print("Yes")
if flg:
    print("No")


Measured memory_bytes: 2940
require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a
end

N=gets.chomp.to_i
ret=0
divisors(N).each do |d|
    r=d-1
    next if r==0
    ret+=r if N/r==N%r
end
puts ret


Measured memory_bytes: 14392
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 200001
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};

main(){
    int n=in();
    int ans=0;
    rep(i,1<<18){
        int res=0;
        int t=i;
        bool flag[3]={};
        int dig=1;
        int flagg=1;
        while(t){
            if(t%4==1){
                flag[0]=1;
                res+=7*dig;
            }
            if(t%4==2){
                flag[1]=1;
                res+=5*dig;
            }
            if(t%4==3){
                flag[2]=1;
                res+=3*dig;
            }
                        if(flagg==0&&t%4)flagg=2;
            if(flagg!=2&&t%4==0)flagg=0;
            t/=4;
            dig*=10;

        }
        if(flagg==2)continue;
        if(flag[0]&&flag[1]&&flag[2]&&res<=n){
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    x = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    t = 100
    for i in range(10**10):
        t = t*1.01//1
        if t >= x:
            print(i+1)
            exit()


main()


Measured memory_bytes: 9136
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
           
            int H1 = sc.nextInt();
            int M1 = sc.nextInt();
            int H2 = sc.nextInt();
            int M2 = sc.nextInt();
            int K = sc.nextInt();
    
            int study = (H2-H1)*60 + M2-M1-K;
            System.out.println(study);
        
    }
}


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


typedef pair<string,int> p;
vector <p> ls(0);


int find(string s){
  for(int i=0; i<(int)ls.size(); i++){
    if(s==ls[i].first){
      return i;
    }
  }
  return -1;
}

int main(){

  string in;
  int max=0,indx=0;
  string maxs="";

  while(cin>>in){
    int tmp=find(in);
    if(tmp==-1){
      ls.push_back(p(in,1));
      if(in.size()>maxs.size()){ maxs = in;}
    }
    else{
      ls[tmp].second++;
      if(ls[tmp].second>max){
        max=ls[tmp].second;
        indx = tmp;
      }
    }

/*
    for(int i=0; i<(int)ls.size(); i++)
      cout << ls[i].first << " ";
      cout << endl;
    for(int i=0; i<(int)ls.size(); i++)
      cout << ls[i].second << " ";
      cout << endl;
*/
  }

  cout << ls[indx].first << " " << maxs << endl;

  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, K, R, S, P; string T; cin >> N >> K >> R >> S >> P >> T;
  int ans = 0;
  REP(i, K){
    int pos = i; char pre = 'z';
    while(pos < N){
      if(T[pos] == 'r'){
        if(pre == 'p') pre = 'z';
        else {
          ans += P; pre = 'p';
        }
      } else if(T[pos] == 's'){
        if(pre == 'r') pre = 'z';
        else {
          ans += R; pre = 'r';
        }
      } else {
        if(pre == 's') pre = 'z';
        else {
          ans += S; pre = 's';
        }
      }
      pos += K;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
using System;

namespace abc106A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = (A - 1) * (B - 1);
            Console.WriteLine(C);
        }
    }
}


Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}
	L := make([]int, N+1)
	R := make([]int, N+1)
	L[0] = 0
	R[N] = 0
	for i := 0; i < N; i++ {
		L[i+1] = gcd(A[i], L[i])
		R[N-1-i] = gcd(A[N-1-i], R[N-i])
	}
	res := 0
	for i := 0; i < N; i++ {
		if res < gcd(L[i], R[i+1]) {
			res = gcd(L[i], R[i+1])
		}
	}
	fmt.Println(res)
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	} else {
		return gcd(y, x%y)
	}
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	long long N; std::cin >> N;
	long long ans = N + 1 - 2;
	for (long long i = 1; i * i <= N; ++i)
		if (N % i == 0)
			ans = std::min(ans, i + (N / i) - 2);

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,a,b,c,d,x=0,y=200;
int main()
{
  cin>>n>>m>>a>>b;
  a+=100;b+=100;
  for(;i<n;i++)cin>>c,x=max(x,c+100);
  for(i=0;i<m;i++)cin>>d,y=min(y,d+100);
  if(min(y,b)-max(x,a)>0)cout<<"No War";
  else cout<<"War";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int k;
string s;
ll a[500][500];
void init() {
	a[0][0] = 1;
	for (int i = 1; i <= 101; i++) {
		a[i][0] = 1;
		for (int j = 1; j <=101; j++) {
			a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
		}
	}
}
ll dfs(string s1, int k1) {
	int n = s1.length();
 if(k1==0) return 1;
	//if(s1[0]=='9') return pow(9,k1)*a[n][k1];
	if(n==1) return s1[0]-'0';
	string s2=s1.substr(1,n-1);
	if(s1[0]=='0') return dfs(s2,k1);
	//ll d = n - 1;
	ll c = pow(9,k1);
	ll ans =a[n-1][k1] * c;
	ll t = s1[0] - '0' - 1;
	ll d=pow(9,k1-1);
	ans = ans + t * a[n-1][k1-1]*d ;
	return ans+dfs(s2,k1-1);
}
	int main() {
		cin >> s >> k;
		init();
		if (k > s.length()) cout << 0 << '\n';
		else
	cout << dfs(s, k);
}


Measured memory_bytes: 640
# 解説を参考に作成

def solve():
    X = int(input())
    A, B = 0, 0
    # A と B の差が最も小さい時(A - B = 1)に, ans < 10**9 となるのは
    # -118 <= A <= 119, -119 <= B <= 118 の場合となる.
    # A - B > 1 の場合でも同じ範囲だけ見れば十分となる.
    # A - B < 1 の場合は答えが負になるので, X >= 1 の制約から検討不要.
    for a in range(-118, 119 + 1):
        for b in range(-119, 118 + 1):
            if a ** 5 - b ** 5 == X:
                A, B = a, b
                break
    print(A, B)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9176
N, M = map(int, input().split())

penalty = 0
nums = [0] * N
isACs = [False] * N
for _ in range(M):
    p, ss = input().split()
    p = int(p) - 1
    if ss == 'WA':
        nums[p] += 1
    else:
        if not isACs[p]:
            penalty += nums[p]
        isACs[p] = True

numAC = isACs.count(True)
print(numAC, penalty)


Measured memory_bytes: 4596