akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
inline void solve(void){
  long N,K,R,S,P;
  in(N,K,R,S,P);
  string T;in(T);
  long score=0;
  map<char,long>m;
  m['r']=P;
  m['s']=R;
  m['p']=S;
  for(int i=0;i<K;i++){
    score+=m[T[i]];
    bool f=false;
    for(int j=i+K;j<N;j+=K){
      if(f)f=false;
      else if(T[j-K]==T[j]){
        f=true;
        continue;
      }
      score+=m[T[j]];
    }
  }
  out(score);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 512
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
sum = 0
c = collections.Counter(prime_factorize(n))
index = 1
for i in c.values():
    tmp = i
    # print(str(tmp) + " tmp")
    for j in range(i):
        if j+1 > tmp:
            break
        tmp -= j+1
        sum += 1
print(sum)
# print(c)


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int N;
  cin >> N;
  int n = (1 << N);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  multiset<int> st(a.begin(), a.end());
  sort(a.begin(), a.end());
  dump(a);
  vector<int> s;
  s.push_back(a.back());
  st.erase(a.back());
  dump(s);
  dump(st);
  rep(i, N) {
    vector<int> p = s;
    sort(p.begin(), p.end());
    dump(p);
    // while (p.size() > 0 && st.size() > 0) {
    while (p.size() > 0) {
      auto it = st.lower_bound(p.back());
      if (it == st.begin()) break;
      // auto it = st.lower_bound(p.back() - 1);
      // if (it == st.end()) it--;
      // if (p.back() <= *it) break;
      it--;
      s.push_back(*it);
      st.erase(it);
      p.pop_back();
    }
    dump(s);
    dump(st);
    if (p.size() > 0) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 15220
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.List             (transpose, zipWith4)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, c] <- readInts <$> BC.getLine
  xvs <- map readInts . BC.lines <$> BC.getContents
  print $ solve n c xvs

solve :: Int -> Int -> [[Int]] -> Int
solve n c xvs = max (maximum lhs) (maximum rhs)
  where [xs, vs] = transpose xvs
        ys = 0 : xs
        ys' = map (c -) (xs ++ [c])
        ls = scanl (+) 0 vs
        rs = scanr (+) 0 vs
        lfs = zipWith (-) ls ys
        lgs = scanl1 max lfs
        rfs = zipWith (-) rs ys'
        rgs = scanr1 max rfs
        lhs = zipWith4 (\l r xa xb -> l + r - min xa xb) lfs rgs ys ys'
        rhs = zipWith4 (\l r xa xb -> l + r - min xa xb) lgs rfs ys ys'

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt

readInts :: BC.ByteString -> [Int]
readInts = map readInt . BC.words


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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////


int main() {

	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];

	int maxl = 0;
	rep(i, N-1) {
		if (A[i + 1] - A[i] > maxl)maxl = A[i + 1] - A[i];
	}
	if ((K - A[N-1]) + A[0] > maxl)maxl = (K - A[N - 1]) + A[0];

	cout << K - maxl << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

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

void solve()
{
    int n;
    ll x;
    cin >> n >> x;
    
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ll t;
        cin >> t;
        if(i == 0)
        {
            ans = abs(x - t);
        }
        else
        {
            ans = gcd(ans, abs(x - t));
        }
    }
    
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h> 
int main()
{
	int a[100010];
	int i,j,b4,b2,b,n;
	while(~scanf("%d",&n))
	{
		b=0;b4=0;b2=0;j=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]%4==0)
			{
				b4++;
			}
			else if(a[i]%2==0)
			{
				b2++;
				j=1;
			}
			else b++;
		}
		if(b4>=b2+b-1)
		{
			printf("Yes\n");
		}
		else {
			if(j==1&&b4>=b)
			printf("Yes\n");
			else printf("No\n");
		}
	}
 } 

Measured memory_bytes: 512
n = int(input())
tree = list(map(int, input().split()))

def main() :
    createHeap(n)
    print('', ' '.join(map(str, tree)))

def createHeap(x):
    for i in range((x - 1) // 2, -1, -1) :
        maxHeap(i)

def maxHeap(i) :
    if i * 2 + 1 >= n:
        return

    tmp = i * 2 + 1

    if i * 2 + 2 < n :
        if tree[i * 2 + 1] < tree[i * 2 + 2] :
            tmp = i * 2 + 2

    if tree[i] < tree[tmp] :
        tree[i], tree[tmp] = tree[tmp], tree[i]
        maxHeap(tmp)

if __name__ == '__main__':
    main()



Measured memory_bytes: 63700
n = int(input())
a = list(map(int, input().split()))

s_1 = 0
s_2 = 0
m = 10 ** 9 + 7
for i in range(n):
    s_1 += a[i] % m
    s_2 += (a[i] ** 2) % m
s = (s_1 * s_1 - s_2) * pow(2, -1, m) % m
print(s)

Measured memory_bytes: 31548
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
cnt=0
for i in range(N):
    am=0
    A=list(map(int,input().split()))
    for j in range(M):
        am+=B[j]*A[j]
    if am+C>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 62208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
int c[16][16];
int dp[1<<15][15];
int cost[1<<15];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v,w;scanf("%d%d%d",&u,&v,&w);
        u--,v--;
        c[u][v]=c[v][u]=w;
    }
    for(int s=0;s<(1<<n);s++){
        for(int i=0;i<n;i++){
            if((s>>i&1)==0)continue;
            for(int j=i+1;j<n;j++){
                if((s>>j&1)==0)continue;
                cost[s]+=c[i][j];
            }
        }
    }
    for(int s=0;s<(1<<n);s++){
        for(int u=0;u<n;u++)dp[s][u]=-1;
    }
    for(int s=0;s<(1<<n);s++)if(s&1)dp[s][0]=cost[s];
    for(int s=0;s<(1<<n);s++){
        for(int u=0;u<n;u++){
            if(dp[s][u]==-1)continue;
            int mask=(1<<n)-1-s;
            for(int ns=mask;ns;ns=(ns-1)&mask){
                for(int v=0;v<n;v++){
                    if((ns>>v&1)&&c[u][v])dp[s|ns][v]=max(dp[s|ns][v],dp[s][u]+c[u][v]+cost[ns]);
                }
            }
        }
    }
    printf("%d\n",cost[(1<<n)-1]-dp[(1<<n)-1][n-1]);
    return 0;
}

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

int main(){
    int x,n;
    cin >> x >> n;
    ve<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans, sa = 100000;
    for(int i = 101; i>=-1; i--){
        if(!count(p.begin(), p.end(),i)){
            if(abs(x-i)<=sa){
                sa = abs(x-i);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a >= k) ans = k;
    else{
        ans = a;
        k -= a;
        if(b >= k) ;
        else{
            k -= b;
            ans -= k;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define allof(c) c.begin(), c.end()
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> vevector<T> readjag(int n) { vevector<T> v; REP(i,n) v.push_back(read<T>(read<int>())); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

template <class T> string toString(const T &t) { stringstream ss; ss << t; return ss.str(); }

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define countof(a) (sizeof(a)/sizeof(a[0]))
#define COMPARISON(t,a,b) [](const t & a, const t & b) -> bool

// primes //
vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n + 1)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}

// iota iterator //
struct iotait
{
	int n;
	iotait(int n = 0) : n(n) { }
	iotait &operator ++() { ++n; return *this; }
	int operator *() { return n; }
};

// start up //
void solve();
int main() { solve(); return 0; }


/// template end ///

void solve()
{
	READ(int, testcases);
	REP (testcase, testcases)
	{
		READ(int, k);
		int count = 0;
		REP(xxx, INF)
		{
			if (k < 10) { break; }
			
			int next = 0;
			auto s = to_string(k);
			FOR(i, 1, s.size())
				next = max(next, stoi(s.substr(0, i)) * stoi(s.substr(i)));
			k = next;
			count++;
		}
		write(count);
	}
}

Measured memory_bytes: 1240
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        long d = Long.parseLong(line[1]);
        d *= d;
        int ans = 0;
        for(int i = 0; i < n; i++){
            line = br.readLine().split(" ");
            long x = Long.parseLong(line[0]);
            long y = Long.parseLong(line[1]);
            ans += x*x+y*y <= d ? 1 : 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 54884
raw_input('').split()
A = [int(x) for x in raw_input('').split()]
max = 0
count = 0
pl = 0
msp = A[0]
for i in range(1,len(A)):
  pl_t = pl + A[i] - A[i-1]
  if pl_t <= 0:
    pl = 0
  else:
    pl = pl_t
    if max < pl_t:
      max = pl_t
      count = 1
    elif max == pl_t:
      count += 1
print count

Measured memory_bytes: 11832
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

long long N;
string s; 
void solve(){
    bool flag=true;
    long long ans=0;
    while(N>9){
        ans +=9;
        if(N%10!=9) flag=false;
        
        N/=10;
    }
    if(flag)ans+=N;
    else ans += N-1;
    
    cout << ans << endl;
}
int main() {
    cin >> N;
    solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  long long int ans=1000000000000;
  for(long long int i=0; i<s.size(); i++){
    char use=s[i];
    long long int pre=0;
    string t=s;
    while(true){
      bool all=true;
      string hoge;
      for(long long int j=0; j<t.size(); j++){
        if(t[j]!=use) all=false;
        if(j==t.size()-1) continue;
        if(t[j+1]==use){
          hoge+=use;
        }else if(t[j]==use){
          hoge+=use;
        }else{
          hoge+=t[j];
        }
      }
      t=hoge;
      if(all){
        break;
      }else{
        pre++;
      }
    }
    ans=min(ans,pre);
  }
  cout<<ans<<endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;


int32_t main(){
    boost;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt" , "r" , stdin); 
    // freopen("output.txt" , "w", stdout);
    // #endif
    
    int n;
    cin >> n;

    cout << 3 * n * n *1LL;    
    
    return 0;
}

Measured memory_bytes: 256
# Python 3+
#-------------------------------------------------------------------------------
import sys

#ff = open("test.txt", "r")
ff = sys.stdin

while True :
    a, b = map(int, ff.readline().split())
    if (a == 0) & (b == 0) :
        break

    if a < b : print(a, b)
    else : print(b, a)

exit()

Measured memory_bytes: 6732
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
int check(ll n)
{
  ll s=sqrt(n);
  if(s*s==n)
    return 1;
  else
    return 0;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   //freopen("error.txt", "w", stderr); 
  freopen("output.txt", "w", stdout); 
#endif 
   
 ll T = 1 ;
 //cin>>T;
 for(ll t=1;t<=T;t++)
 {
  ll d,n,count = 0;
  cin>>n>>d;
  for(ll i=0;i<n;i++)
  {
      ll x,y;
      cin>>x>>y;
      ll s = x*x + y*y;
      if(s<=d*d)
      count++;
  }
  cout<<count;
 }

  return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int N;
map<long long, int> sisuu;

long long rec(map<long long, int>::iterator p, long long mul) {
    if (p == sisuu.end()) {
        if (mul == 1) return 1;
        else return 0;
    }
    long long res = 0;
    for (int i = 0; i < p->second + 1; ++i) {
        if (mul % (i+1) != 0) continue;
        res += rec(++p, mul / (i+1));
        --p;
    }
    return res;
}

int main() {
    cin >> N;
    for (int i = 2; i <= N; ++i) {
        auto ps = prime_factorize(i);
        for (auto it : ps) sisuu[it.first] += it.second;
    }
    cout << rec(sisuu.begin(), 75) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>


int main()
{
	char s[81];
	while (fgets(s, 81, stdin) != NULL)
	{
		for (int i = 0; i < 26; ++i)
		{
			char decoded[81];
			for (int j = 0; s[j] != '\0'; ++j)
				decoded[j] = islower(s[j]) ? 'a'+(s[j]-'a'+i)%26 : s[j];
			decoded[strlen(s)-1] = '\0';
			if (strstr(decoded, "the")
				|| strstr(decoded, "this")
				|| strstr(decoded, "that"))
			{
				puts(decoded);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
n=int(input())
s=0
if n >100000:
  print(error)
elif n<10:
  s=n
elif n>=10 and n<100:
  s=9
elif n>=100 and n<1000:
  s=9+n-100+1
elif n>=1000 and n<10000:
  s=9+900
elif n>=10000 and n<100000:
  s=9+900+n-10000+1
else:
  s=9+900+90000
print(s)
      

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  string s;
  int c;
  cin >> s;
  if(s[0]=='R'){
    if(s[1]=='R'){
      if(s[2]=='R'){
        c=3;
      }else{
        c=2;
      }
    }else{
      c=1;
    }
  }else{
    if(s[1]=='R'){
      if(s[2]=='R'){
        c=2;
      }else{
        c=1;
      }
    }else{
      if(s[2]=='R'){
        c=1;
      }else{
        c=0;
      }
    }
  }
  cout << c;
    
}

Measured memory_bytes: 3556
i=61,f[],y,m,s;main(c){for(--c;s?++f[y*12+*f+"=>?2J13IK<@V&"[--s]]:~scanf("%d,%d,%d",f,&y,&s)?s=s*4+1:++i<180?i%12>1?m=fmax(m,y=f[i]),y||++c:1:!printf("%d\n%d\n",c,m););}

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

int main(){

  int N;
  cin >> N;
  string S;
  bool check = false;
  
  for(int i = 0; i < N; ++i){
    
    cin >> S;
    if(S == "Y"){
    
      check = true;
    
    }
  
  }
  
  if(check){
  
    cout << "Four" << endl;
  
  }else{
  
    cout << "Three" << endl;
  
  }
  
  return 0;
  
}

Measured memory_bytes: 256
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    ll n,a[1000],b[200],c[200],i,j,s=0;
    cin>>n;
    f(i,n)
    {
        cin>>a[i];
    }
    f(i,n)
    {
        cin>>b[i];
    }
    f(i,(n-1))
    {
        cin>>c[i];
    }
    for(i=n-1;i>0;i--)
    {
        if(a[i]-a[i-1]==1)
        {
            s=s+b[a[i]-1]+c[a[i]-2];
        }
        else{
            s=s+b[a[i]-1];
        }
    }
    s=s+b[a[0]-1];
    cout<<s<<endl;

    return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int dis = 0;
      for (int k = 0; k < D; k++) {
        int dif = abs(X[i][k]-X[j][k]);
        dis += dif * dif;
      }
      for (int k = 0; k <= dis; k++) {
        if (k*k == dis) ans++;
      }
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int hour_diff = h2-h1;
    int min_diff = m2-m1;
    int total = hour_diff*60+min_diff-k;
    cout << total <<endl;
    return 0;
    
}

    

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
const int mod = 1e9 + 7;
int sumXOR(int arr[], int n) { 
   int sum = 0; 
   for (int i = 0; i < 61; i++) { 
      // Count of zeros and ones 
      int zc = 0, oc = 0; 
      // Individual sum at each bit position 
      int idsum = 0; 
      for (int j = 0; j < n; j++) { 
         if (arr[j] % 2 == 0) 
            zc++; 
         else
            oc++; 
         arr[j] /= 2; 
      } 
      // calculating individual bit sum 
      idsum = ((oc * zc % mod) * ((1LL << i) % mod)) % mod; 
      // final sum    
      sum += idsum; 
      sum %= mod;
   } 
   return sum; 
} 
int32_t main() { 
   int n;
   cin >> n;
   int arr[n];
   int sum = 0; 
   for (int i = 0; i < n; ++i){
      cin >> arr[i];
   }
   sum = sumXOR(arr, n); 
   cout << sum; 
   return 0; 
} 


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#define ll long long
using namespace std;

int main(){
  double N;cin>>N;
  int t=1;
  for(int i=1;i<=50000;i++){
    if(floor((double)i*1.08)==N){
      cout<<i<<endl;
      t=0;
      break;
    }
  }
    if(t==1)cout<<":(";
}


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

bool is_palindrome(string s) {
    bool res = true;
    for (int i = 0; i < (s.size()/2); i++) {
        if (s.at(i) != s.at(s.size()-1-i)) res = false;
    }
    return res;
}

int main() {
    string s;
    cin >> s;
    
    if (is_palindrome(s)
            && is_palindrome(s.substr(0, ((s.size()-1)/2)))
            && is_palindrome(s.substr(((s.size()+1)/2), ((s.size()-1)/2)))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		   Scanner sc = new Scanner(System.in);
		   
		   int n= sc.nextInt();
		   int k = sc.nextInt();
		   int q = sc.nextInt();
		   
		   int []a = new int [q];
		   int []p = new int [n];
		   
		  
		   for(int i = 0; i < n; i++) {
			   p[i] = k - q;
		   }
		   for(int i = 0 ; i < q ; i++) {
			   a[i] = sc.nextInt();
			   p[a[i] - 1]++;
		   }
		   
		   for(int i = 0 ; i < n ; i++) {
			  if(p[i] <= 0) {
				  System.out.println("No");
			  }
			  if(p[i] > 0) {
				  System.out.println("Yes");
			  }
		   }

	}

}


Measured memory_bytes: 80772
#include <stdio.h>

int main() {
	int a = 0;
	int b = 0;
	int c = 0;

	scanf("%d %d %d", &a, &b, &c);

	int count = 0;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) { count++; }
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1816
#include<iostream>
using namespace std;int h,w,m,D[1401][1401]={m=0},f,i;main(){cin>>h>>w;for(i=0;i<h*w;i++){cin>>f;m=max(m,D[i/w+1][i%w+1]=(min(D[i/w][i%w],min(D[i/w+1][i%w],D[i/w][i%w+1]))+1)*(!f));}cout<<m*m<<endl;}


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

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

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

const long long INF = 1LL << 60;

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

    set<int> D;
    rep(i, N) {
        int d;
        cin >> d;
        D.insert(d);
    }

    cout << D.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import math
h, w, a, b = [int(i) for i in input().split()]

MOD = 10**9 + 7
N = h + w

fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD

def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % MOD

tmp = []
for i in range(b, w):
    tmp.append(comb(i+h-a-1, i))

ans = 0
cnt = 0
for i in range(w-b-1, -1, -1):
    t = comb(i + a - 1, a - 1)
    ans += t * tmp[cnt]
    cnt += 1
print(ans%MOD)

Measured memory_bytes: 89460
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll n,d;
    int ans=0;
    cin>>n>>d;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
lis=list(map(int,input().split()))
A=lis[0]
B=lis[1]
C=lis[2]
D=lis[3]
sum=B-A+1

times=C*D//gcd(C,D)
restac=A%C
restbc=B%C
restad=A%D
restbd=B%D
restat=A%times
restbt=B%times
x=int((B-restbc)//C)-int((A-restac)//C)
y=int((B-restbd)//D)-int((A-restad)//D)
z=int((B-restbt)//times)-int((A-restat)//times)
if restac==0:
  x+=1
if restad==0:
  y+=1
if(restat==0):
  z+=1
print(sum-x-y+z)

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

long long n;
vector<long long> a;

long long solve();
long long myabs(long long x) { return max(x, -x); }

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, now = 0;
  for(int i = 0; i < n; ++i) {
    ans += myabs(a[i] - a[n / 2]);
    if(n / 2 - 1 >= 0) now += myabs(a[i] - a[n / 2 - 1]);
  }
  if(n / 2 - 1 < 0) return ans;
  return min(ans, now);
}

Measured memory_bytes: 1792
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>

using namespace std;


//polygon의 중심 좌표를 구한다.
//중심 좌표로부터 
int main(void)
{
	int count5=0,count7=0;
	int a;
	for (int i = 0; i < 3; i++)
	{
		cin >> a;
		if (a == 5)
		{
			count5++;
		}

		if (a == 7)
		{
			count7++;
		}
	}

	if (count5 == 2 && count7 == 1)
	{
		cout << "YES" << endl;
	}

	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll h;
    string ans = "Yes";
    vector <ll> hs;
    REP(i, n){
        cin >> h;
        hs.push_back(h);
    }
    hs.push_back(1e10);
    REP(i, n){
        ll old_h = hs[n-i];
        h = hs[n-i-1];
        if (old_h+1 < h){
            ans ="No";
            break;
        }
        if (old_h < h){
            hs[n-i-1]--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
import sys
m,d = map(int,input().split())
if d<21:
    print(0)
    sys.exit()
cnt=0
for i in range(1,m+1):
    for j in range(22,d+1):
        d10,d1=divmod(j, 10)
        if d1>=2 and i==d1*d10:
            cnt = cnt+1
print(cnt)

Measured memory_bytes: 3060
from sys import stdin, exit
from fractions import gcd


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

# List if length of 2 or shorter
if len(A) <= 2:
    print(max(A))
    exit()

# Left Side = [A0, 0, 0, 0, 0]
left_side = [0 for _ in range(N)]
left_side[0] = A[0]

# Right Side = [0, 0, 0, 0, An]
right_side = [0 for _ in range(N)]
right_side[-1] = A[-1]

for i in range(N - 1):  # DP: L1 = gcd(L0, A1); Maximum GCD on very RIGHT of list  (Dir -->)
    left_side[i + 1] = gcd(left_side[i], A[i + 1])

for i in range(1, N):   # DP: Rn-2 = gcd(An-2, Rn-1); Maximum GCD on very LEFT of list  (Dir <--)
    right_side[-1 * (i+1)] = gcd(A[-1*(i+1)], right_side[-1*i])

max_gcd = 1

# Left
max_gcd = max(max_gcd, right_side[1])
# Max of Right and Left
max_gcd = max(max_gcd, left_side[-2])

for i in range(1, N - 1):
    left = left_side[i - 1]
    # We exclude the number at i here, and compare whether new gcd is greater than previous
    right = right_side[i + 1]

    max_gcd = max(max_gcd, gcd(left, right))

print(max_gcd)

Measured memory_bytes: 16152
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f?-x:x;
}

const int N = 1e6 + 10,inf = 1e9 + 7;
int n,f[N];
int main()
{
	n = read();
	f[0] = 1;
	for(int i = 1;i <= n;i++) {
		for(int j = 3;j <= i;j++) {
			(f[i]+=f[i-j])%=inf;
		}
	}
	cout << f[n] << endl;
}

Measured memory_bytes: 3632
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9184
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

class UnionFind {
public:
	vector<int> Parent;

	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0)return A;
		return Parent[A] = root(Parent[A]);
	}

	int size(int A) {
		return -Parent[root(A)];
	}

	bool unite(int A, int B) {
		A = root(A);
		B = root(B);
		if (A == B)
			return false;

		if (size(A) < size(B))
			swap(A, B);

		Parent[A] += Parent[B];
		Parent[B] = A;

		return true;
	}

	bool same(int A, int B) {
		if (root(A) == root(B))
			return true;
		else
			return false;
	}
};

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

	int N, M;
	cin >> N >> M;
	map<int, bool> mp;
	UnionFind uni(N);
	REP(i, M) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		uni.unite(x, y);
	}
	int ans = 0;
	REP(i, N) {
		if (!mp[uni.root(i)]) {
			mp[uni.root(i)] = true;
			ans++;
		}
	}

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



Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL toLL(string s)
{
    stringstream ss;
    LL l;
    ss<<s;
    ss>>l;
    return l;
}
int main()
{
    string S; cin>>S;
    if(S.size()==1) {cout<<S<<endl; return 0;}
    int B = 1<<(S.size()-1);
    //cout<<B<<endl;
    LL ans = 0;
    for(int i = 0; i<B; i++)
    {
        string T = S;
        int M = i;
        int len = 1;
        while(M>0)
        {
            if(M%2 == 0) len++;
            if(M%2 == 1)
            {
                ans += toLL(T.substr(0,len)); //cout<<T.substr(0,len)<<"+";
                T = T.substr(len);
                len = 1;
            }
            M/=2;
        }
        //cout<<T<<endl;
        ans += toLL(T);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var A = inputArray[0];
			var B = inputArray[1];
			var K = inputArray[2];

			if(A >= K) {
				var takahashi = A - K;
				Console.WriteLine($"{takahashi} {B}");
				return;
			}

			if ((A+B)>=K) {
				var aoki = B + A - K;
				Console.WriteLine($"{0} {aoki}");
				return;

			}
			Console.WriteLine($"{0} {0}");
			return;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13396
#!/usr/bin/env python
# coding: utf-8

# In[4]:


A,B,C = map(int, input().split())
K = int(input())


# In[5]:


cnt = 0
a,b,c = A,B,C
while a >= b:
    b *= 2
    cnt += 1
while b >= c:
    c *= 2
    cnt += 1
if cnt <= K:
    print("Yes")
else:
    print("No")


# In[ ]:






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

s = input()
cnt = 0
if 'N' in s and 'S' in s:
    cnt += 1
elif 'N' not in s and 'S' not in s:
    cnt += 1
if 'W' in s and 'E' in s:
    cnt += 1
elif 'W' not in s and 'E' not in s:
    cnt += 1
if cnt == 2:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

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

int minorinn(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, K;
int h[114514];

int main(void) {
	int i;
	int dachaann = 1111111111;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &h[i]) != 1) return 1;
	}
	qsort(h, N, sizeof(*h), minorinn);
	for (i = K - 1; i < N; i++) {
		int emirinn = h[i] - h[i - (K - 1)];
		if (emirinn < dachaann) dachaann = emirinn;
	}
	printf("%d\n", dachaann);
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish
{
    ll time;
    ll taste;
};

int main()
{
    ll N;
    cin >> N;
    vector<char> str;

    ll i = 1;
    while (N > 0)
    {
        str.push_back('a' + (N - 1) % 26);
        N = (N - 1) / 26;
    }

    for (ll i = 0; i < str.size(); i++)
    {
        cout << str[str.size() - 1 - i];
    }
    cout << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],h[n+1];
	for(int i=1;i<=n;i++)
	cin>>h[i];
	a[n]=0;
	a[n-1]=abs(h[n]-h[n-1]);
	for(int i=n-2;i>=1;i--)
	{
		a[i]=min(abs(h[i]-h[i+1])+a[i+1],abs(h[i]-h[i+2])+a[i+2]);
	}
	cout<<a[1];
	return 0;
}

Measured memory_bytes: 1024
fn main() {
    let v = read_vec::<i64>();
    let (t1, t2) = (v[0], v[1]);
    let v = read_vec::<i64>();
    let (a1, a2) = (v[0], v[1]);
    let v = read_vec::<i64>();
    let (b1, b2) = (v[0], v[1]);

    let mut c1 = (a1 - b1) * t1;
    let mut c2 = (a2 - b2) * t2;
    if c1 < 0 {
        c1 *= -1;
        c2 *= -1;
    }
    if c2 > -c1 {
        println!("0");
        return;
    }
    if c1 == -c2 {
        println!("infinity");
        return;
    }
    let rev_num = c1 / (-c1 - c2);
    if c1 % (-c1 - c2) == 0 {
        println!("{}", 2 * rev_num);
        return;
    }
    println!("{}", 2 * rev_num + 1);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;


int main(){
    llint N,A,B;
    cin>>N>>A>>B;
    llint count;
    llint amari;
    if(A==0) {cout<<0<<endl;}
    else if(B==0) {cout<<N<<endl;}
    else{
        count=( (N/(A+B)) )*A;
        amari=N%(A+B);
        if (amari>A) count+=A;
        else count+=amari;
        cout<<count<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = ((res % m) * (x % m)) % m;
        x = ((x % m) * (x % m)) % m;
        p >>= 1;
    }
    return res % m;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm(int a, int b){
    return a / gcd(a, b) * b;
}
const ll P = 1e9 + 9;
const int N = 15 * 1e6 + 1, NN = 4e3 + 5;
int ans, n;
bool vst[NN];
int p[NN], idx;
void seive(){
    for(int i = 2; i < NN; ++i){
        if(vst[i])
            continue;
        p[idx++] = i;
        for(int j = i * i; j < NN; j += i)
            vst[j] = 1;
        
    }
}
inline int getInt(){
    char c;
    int ret = 0;
    while (isdigit(c = getchar())) {
        if(c == '\n')
            break;
        ret = (ret << 3) + ret + ret;
        ret += (c - '0');
    }
    return ret;
}
int main(){
    FastInputOutput();
    string s;
    cin >> s;
    set<string> st;
    int k;
    cin >> k;
    for(int i = 0; i < s.size(); ++i){
        string t;
        for(int j = i; j < s.size() && j <= i + 5; ++j){
            t.push_back(s[j]);
            st.insert(t);
        }
    }
    
    --k;
    vector<string> v(st.begin(), st.end());
    cout << v[k] << endl;
}


Measured memory_bytes: 2304
import sys 
def input():return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
H,W=map(int,input().split())
A=[[int(x) for x in input().split()] for _ in range(H)]
B=[[int(x) for x in input().split()] for _ in range(H)]
C=[[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j]=abs(A[i][j]-B[i][j])
center=80 * (H + W)
dp=[[0]*W for _ in range(H)]
dp[0][0]=(1<<(center - C[0][0]))|(1<<(center+C[0][0]))
for i in range(H):
    for j in range(W):
        if i:
            dp[i][j]|=dp[i-1][j]<<C[i][j]
            dp[i][j]|=dp[i-1][j]>>C[i][j]
        if j:
            dp[i][j]|=dp[i][j-1]<<C[i][j]
            dp[i][j]|=dp[i][j-1]>>C[i][j]            
ans=center*2
for i in range(center*2):
    if (dp[H-1][W-1]>>i)&1:
        ans=min(ans,abs(i-center))
print(ans)

Measured memory_bytes: 20340
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>

using namespace std;

string d[3] = {"3","5","7"};

int dfs(string s, ll N) {
    if (stoll(s) > N) return 0;
    ll ret;
    ret = 0;
    bool flag3,flag5,flag7;
    flag3 = flag5 = flag7 = false;
    for (int i = 0; i < s.size(); i++) {
        if (s[i]=='3') flag3 = true;
        if (s[i]=='5') flag5 = true;
        if (s[i]=='7') flag7 = true;
    }
    if (flag3 && flag5 && flag7) ret++;
    for (int i = 0; i < 3; i++) ret += dfs(s+d[i],N);
    return ret;
}

int main(){
    ll N;
    cin >> N;
    ll ans = dfs("0",N);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

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

    bool flag = false;
    rep(i, s.size()) {
        if (strncmp(&s[i], &t[0], t.size()) == 0) {
            flag = true;
            break;
        }
    }

    flag ? cout << "Yes" : cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 10010
#define ll long long
#define P 998244353
using namespace std;
int n,m;
ll q[N],ni[N],nq[N];
int f[N][N];
char a[N],b[N];
ll C(int n,int m)
{
	return q[n]*nq[m]%P*nq[n-m]%P;
}
int main()
{
	q[0]=ni[1]=nq[0]=1;
	for(int i=1;i<N;i++) q[i]=q[i-1]*i%P;
	for(int i=2;i<N;i++) ni[i]=(P-P/i)*ni[P%i]%P;
	for(int i=1;i<N;i++) nq[i]=nq[i-1]*ni[i]%P;
	scanf("%s%s",a,b);
	for(int i=0;a[i];i++)
	if(a[i]=='1')
	{
		if(b[i]=='1') n++;
		else m++;
	}
	f[0][0]=1;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=m;j++)
	if(i||j)
	{
		ll o=0;
		if(j) o+=(ll)j*j*f[i][j-1];
		if(i) o+=(ll)i*j*f[i-1][j];
		f[i][j]=o%P;
	}
	ll ans=0;
	for(int i=0;i<=n;i++) ans+=f[i][m]*C(n,i)%P*C(n+m,i+m)%P*q[n-i]%P*q[n-i]%P;
	ans%=P;
	cout<<ans;
}

Measured memory_bytes: 389888
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a,b = inpl()
if a*b%2:
    print('Odd')
else:
    print('Even')

Measured memory_bytes: 3948