akhauriyash/Code-Regression huggingface dataset:
/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}
const int _ = 1000010;
const int __ = 2000010;
typedef pair < int, int > pii;

int tot, head[_], nxt[__], ver[__], w[__];
inline void Add_edge(int u, int v, int d)
{ nxt[++tot] = head[u], head[u] = tot, ver[tot] = v, w[tot] = d; }
inline void link(int u, int v, int d) { Add_edge(u, v, d), Add_edge(v, u, d); }

int n, m, num, dis[_], vis[_];
priority_queue < pii > q;
map < int, int > _map[_];

inline int Dijkstra() {
	memset(dis, 0x3f, sizeof dis);
	dis[1] = 0, q.push(make_pair(0, 1));
	while (!q.empty()) {
		pii x = q.top(); q.pop();
		int u = x.second;
		if (vis[u]) continue; vis[u] = 1;
		for (rg int i = head[u]; i; i = nxt[i]) {
			int v = ver[i];
			if (dis[v] > dis[u] + w[i])
				dis[v] = dis[u] + w[i], q.push(make_pair(-dis[v], v));
		}
	}
	return dis[n] == 0x3f3f3f3f ? -1 : dis[n] >> 1;
}

inline int node(int u, int x)
{ if (!_map[u][x]) _map[u][x] = ++num; return _map[u][x]; }

int main() {
	read(n), read(m), num = n;
	for (rg int x, y, k, i = 1; i <= m; ++i) {
		read(x), read(y), read(k);
		int xx = node(x, k), yy = node(y, k);
		link(x, xx, 1), link(xx, yy, 0), link(y, yy, 1);
	}
	printf("%d\n", Dijkstra());
	return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int sub(vi w){
	int n=int(w.size())-1;
	vi a(n),b(n),c(n),d(n);
	for(int i=n-1;i>=0;i--){
		a[i]=b[i]=w[i+1];
		if(i+1<n){
			a[i]+=a[i+1];
			b[i]+=b[i+1];
			b[i]+=a[i+1]*2;
		}
	}
	REP(i,n){
		if(i>0){
			c[i]=c[i-1]+w[i-1];
			d[i]=d[i-1]+c[i]*2;
		}
	}
	int res=0;
	REP(i,n){
		int p=(n-i)*2-1,q=i*2;
		int v=b[i]+d[i];
		if(p>q+1){
			int j=n-(p-(q+1))/2;
			v-=a[j]+b[j];
		}else if(p+1<q){
			int j=(q-(p+1))/2;
			v-=d[j];
		}
		chmax(res,v);
	}
	return res;
}

signed main(){
	int l=read(),n=read();
	int last=0;
	vi w;
	REP(i,n){
		int x=read();
		w.PB(x-last);
		last=x;
	}
	w.PB(l-last);
	int ans=sub(w);
	reverse(ALL(w));
	chmax(ans,sub(w));
	print(ans);
}


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

Measured memory_bytes: 3628
N = int(input())
S = input()


total = S.count('R') * S.count('G') * S.count('B')


for gap in range(1, N//2+1):
    for i in range(N - 2 * gap):
        j = i + gap
        k = j + gap
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            total -= 1

print(total)


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

int main() {
  vector<bool> prime(100001, true);
  prime.at(0) = false;
  prime.at(1) = false;
  for (int i = 2; i < 400; i++) {
    if (prime.at(i) == true) {
      for (int j = 2; i * j <= 100000; j++) {
        prime.at(i * j) = false;
      }
    }
  }
  
  vector<bool> like2017(100001, false);
  for (int i = 3; i < 100001; i += 2) {
    if (prime.at(i) && prime.at((i + 1) / 2)) {
      like2017.at(i) = true;
    }
  }
  
  vector<int> L(100001);
  L.at(0) = 0;
  for (int i = 1; i < 100001; i++) {
    if (like2017.at(i)) L.at(i) = L.at(i - 1) + 1;
    else L.at(i) = L.at(i - 1);
  }
  
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << L.at(r) - L.at(l - 1) << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    rep(i, m) cin >> a[i];
    ll sum = 0;
    rep(i, m) sum += a[i];

    cout << max((int)-1, (int)n - (int)sum);
}


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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    long long ans;
    if (a == 0) ans = b / x + 1;
    else ans = b / x - (a - 1) / x;
    cout << ans << endl;
}


Measured memory_bytes: 3592
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    mod = 7 + 10 ** 9

    res = 0
    for k in range(K, N + 2):
        res += ((k * (2 * N - k + 1) / 2) - (k * (k - 1) / 2) + 1)
        res %= mod
    print(int(res))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
  int n;
  cin >> n;
  ll h[n];
  for(int i=0; i<n; i++) cin >> h[i];
  ll dp[n];
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for(int i=2; i<n; i++){
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }

//  for(int i=0; i<n; i++) cout << dp[i] << " ";
//  cout << endl;
  cout << dp[n-1];
  return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()

def resolve():
    n, p = map(int, input().split())
    
    base = [list(map(int, input().split())) for _ in range(n)]
    dp = [[(i == j) + 0 for j in range(n)] for i in range(n)]
    while p:
        if p & 1:
            dp = [[sum(dp[i][k] * base[k][j] for k in range(n)) % MOD for j in range(n)] for i in range(n)]
        base = [[sum(base[i][k] * base[k][j] for k in range(n)) % MOD for j in range(n)] for i in range(n)]
        p >>= 1

    print(sum(dp[i][j] for i in range(n) for j in range(n)) % MOD)
resolve()

Measured memory_bytes: 75280
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


enum type {
    TYPE_WEST,
    TYPE_EAST,
    TYPE_ALL,
};

int main(void) {
    int num;
    cin >> num;
    string str;
    cin >> str;

    vector<char> table(256);
    table['W'] = TYPE_WEST; table['E'] = TYPE_EAST;

    vector<vector<int>> cum(num+2, vector<int>(2));
    vector<vector<int>> rcum(num+2, vector<int>(2));

    for(int i = 1; i <= num; i++) {
        char ch = table[str[i-1]];
        for(int k = 0; k < TYPE_ALL; k++) {
            cum[i+1][k] = cum[i][k] + (ch == k);
        }
    }

    for(int i = num; i >= 1; i--) {
        char ch = table[str[i-1]];
        for(int k = 0; k < TYPE_ALL; k++) {
            rcum[i-1][k] = rcum[i][k] + (ch == k);
        }
    }

    int ans = 0;
    for(int i = 1; i <= num; i++) {
        // [1, i), (i, num]
        debug("%d %d\n", cum[i][TYPE_EAST], rcum[i][TYPE_WEST]);
        // EEE[*]WWW
        ans = max(ans, cum[i][TYPE_EAST]+rcum[i][TYPE_WEST]);
    }
    cout << (num-1)-ans << endl;
    return 0;
}

Measured memory_bytes: 36516
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;

int main()
{
    int n, t, x, y;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> t >> x >> y;
        int a = t - (x+y);
        if (a < 0 || a % 2) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
d = defaultdict(int)
cur = N
for a in A[::-1]:
    ans += d[cur + a]
    if cur - a > 0:
        d[cur - a] += 1
    cur -= 1
print(ans)

Measured memory_bytes: 42080
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd

N, X, D = map(int, read().split())

if D == 0:
    if X == 0:
        print(1)
    else:
        print(N+1)
    exit()

g = gcd(X, D)
X //= g; D //= g
if D < 0:
    X, D = -X, -D

def F(d):
    event = []
    for n in range(d, N+1, D):
        
        low = X * n // D + n * (n-1) // 2 # 右の項は総和の式から
        high = X * n // D + n * (N+N-n-1) // 2
        event.append((low, 0))
        event.append((high, 1))
    event.sort()
    overlap = 0
    cnt = 0
    for x, t in event:
        if not t:
            if not overlap:
                left_end = x
            overlap += 1
        else:
            overlap -= 1
            if not overlap:
                cnt += x - left_end + 1
    return cnt

answer = sum(F(d) for d in range(min(D,N+1)))
print(answer)



Measured memory_bytes: 49752
import java.io.BufferedReader;
    import java.io.InputStreamReader;
     
    public class Main {
        public static void main(String[] args) {
            Main main = new Main();
            main.solve(args);
        }
        public void solve(String[] args) {
            MyScanner scanner = new MyScanner();
            int a = scanner.nextInt();
          	int b = scanner.nextInt();
          	int c = scanner.nextInt();
          	int max = Math.max(a, Math.max(b,c));     
          	if(max == a){
              System.out.println(b*c/2);
            }else if(max==b){
              System.out.println(a*c/2);
            }else{
              System.out.println(a*b/2);
        	}
        }
          private class MyScanner {
            String[] s;
            int i;
            BufferedReader br;
            String reg = " ";
            MyScanner () {
                s = new String[0];
                i = 0;
                br = new BufferedReader(new InputStreamReader(System.in));
            }
            public String next() {
                try {
                    if (i < s.length) return s[i++];
                    String line = br.readLine();
                    while (line.equals("")) {line = br.readLine();}
                    s = line.split(reg, 0);
                    i = 0;return s[i++];
                } catch (Exception e) {e.printStackTrace();}
                return null;
            }
            public int nextInt() {
                try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
                return -1;
            }
            public double nextDouble() {
                try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
                return -1;
            }
            public long nextLong()  {
                try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
                return -1;
            }
        }
    }

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) {
                continue;
            }
            int v = a[i];
            while (v % 2 == 0) {
                v /= 2;
                sum++;
            }
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 34256
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 2010;
int n, m, q;
char s[N][N];
int a[N][N], b[N][N], c[N][N];

void sumup(int a[][N]) {
	rep(i,1,n) rep(j,1,m) a[i][j] += a[i][j - 1];
	rep(i,1,n) rep(j,1,m) a[i][j] += a[i - 1][j];
}

int sum(int a[][N], int x1, int y1, int x2, int y2) {
	if (x1 > x2 || y1 > y2) return 0;
	return a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1];
}

int main() {
	scanf("%d%d%d",&n,&m,&q);
	rep(i,1,n) scanf("%s", s[i] + 1);
	rep(i,1,n) rep(j,1,m) a[i][j] = (s[i][j] == '1');
	sumup(a);
	rep(i,1,n) rep(j,1,m) {
		if (i - 1 && s[i - 1][j] == s[i][j] && s[i][j] == '1') 
			b[i][j]++;
		if (j - 1 && s[i][j - 1] == s[i][j] && s[i][j] == '1') 
			c[i][j]++;
	}
	sumup(b), sumup(c);
	rep(i,1,q) {
		int x1, y1, x2, y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int ans = sum(a, x1, y1, x2, y2);
		ans -= sum(b, x1 + 1, y1, x2, y2);
		ans -= sum(c, x1, y1 + 1, x2, y2);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 53120
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll X;
    cin >>X;
    ll ans=0;

    ans += (X/500)*1000;
    ans -= (X/500)*500;
    ans += (X/5)*5;

    cout << ans <<endl;


    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){
    
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++){
        cin >> S[i];
    }
    int blacknum = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '#')blacknum++;
        }
    }
    queue<pair<int, int>> pos;
    pos.push(mpair(0, 0));
    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[0][0] = 1;
    while(!pos.empty()){
        int possize = pos.size();
        pair<int, int> nowpos;
        for(int i = 0; i < possize; i++){
            nowpos = pos.front();
            pos.pop();
            if(nowpos.first != 0){
                if(S[nowpos.first - 1][nowpos.second] == '.' && dist[nowpos.first - 1][nowpos.second] == -1){
                    dist[nowpos.first - 1][nowpos.second] = dist[nowpos.first][nowpos.second] + 1;
                    pos.push(mpair(nowpos.first - 1, nowpos.second));
                }
            }
            if(nowpos.first != H - 1){
                if(S[nowpos.first + 1][nowpos.second] == '.' && dist[nowpos.first + 1][nowpos.second] == -1){
                    dist[nowpos.first + 1][nowpos.second] = dist[nowpos.first][nowpos.second] + 1;
                    pos.push(mpair(nowpos.first + 1, nowpos.second));
                }
            }
            if(nowpos.second != 0){
                if(S[nowpos.first][nowpos.second - 1] == '.' && dist[nowpos.first][nowpos.second - 1] == -1){
                    dist[nowpos.first][nowpos.second - 1] = dist[nowpos.first][nowpos.second] + 1;
                    pos.push(mpair(nowpos.first, nowpos.second - 1));
                }
            }
            if(nowpos.second != W - 1){
                if(S[nowpos.first][nowpos.second + 1] == '.' && dist[nowpos.first][nowpos.second + 1] == -1){
                    dist[nowpos.first][nowpos.second + 1] = dist[nowpos.first][nowpos.second] + 1;
                    pos.push(mpair(nowpos.first, nowpos.second + 1));
                }
            }
        }
    }
    if(dist[H - 1][W - 1] == -1)cout << "-1" << endl;
    else cout << H * W - dist[H - 1][W - 1] - blacknum << endl;

    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = []
valmax = int(1e5)
INF = int(1e10)
for _ in range(N+1):
    dp.append([INF] * (valmax+1))
dp[0][0] = 0

for i in range(N):
    for v in range(valmax+1):
        dp[i+1][v] = min(dp[i][v], dp[i][v - wv[i][1]] + wv[i][0])

maxval = 0
for k, l in enumerate(dp[N]):
    if l <= W:
        maxval = max(maxval, k)
    else:
        continue
print(maxval)

Measured memory_bytes: 119916
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


long long H;

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

	cin >> H;

	if(H == 1){
		printf("1\n");
		return 0;
	}

	long long h = H;
	long long ans = 0;
	long long monster = 1;
	while(true){
		h = h / 2;
		if(h == 0){
			break;
		}
		monster = (2 * monster) + 1;
	}
	printf("%lld\n", monster);
	return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A[3],B[3];
    int D[4];int count=0;
    for(int i=0;i<3;i++){
        cin>>A[i]>>B[i];
        D[A[i]-1]++;
        D[B[i]-1]++;
    }for(int j=0;j<4;j++){
        if(D[j]%2==1){
            count++;
        }
    }if(count==0||count==2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main(){
   int n;cin>>n;
   int ans=-1;
   for(int i=1;i<=9;i++){
       for(int j=1;j<=9;j++){
           if(n==i*j){
               ans=1;
               break;
           }
       }
       if(ans==1)break;
   }
   if(ans==-1)cout<<"No";
   else cout<<"Yes";
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

ll dp[20];

ll rec(string s){
	int n = s.size();
	if(dp[n]) return dp[n];
	if(n == 1) return dp[1] = s[0]-'0';
	if(n == 0) return dp[0] = 0;
	ll res = 0, t = 0;
	for(int i = 1; i <= n; i++){
		t *= 10;
		t += (s[i-1]-'0');
		res += (t<<(i==n?0:n-i-1)) + rec(s.substr(i));
	}
	return dp[n] = res;
}

int main(){
	string s;
	cin>>s;
	int n = s.size();
	cout<<rec(s)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> t(n + 1), x(n + 1), y(n + 1);
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	int dt, dx, dy;
	for (int i = 1; i < n + 1; i++) {
		dt = t[i] - t[i - 1];
		dx = x[i] - x[i - 1];
		dy = y[i] - y[i - 1];

		if (abs(dx) + abs(dy) - dt > 0) {
			cout << "No" << endl;
			return 0;
		}
		else if ((dt - abs(dx) + abs(dy)) % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	string str;
	string part[4] = { "maerd","remaerd","esare","resare" };
	cin >> str;
	reverse(str.begin(),str.end());

	int pos = 0;
	bool flag = true;
	while (pos < str.size()) {
		if (str.substr(pos,7)==part[1])pos += 7;
		else if (str.substr(pos, 6) == part[3])pos += 6;
		else if (str.substr(pos, 5) == part[0] || str.substr(pos, 5) == part[2]) pos += 5;
		else { flag = false; break; }
	}

	cout << ((flag) ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2088
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(key = lambda x:x[0])

pt,money = 0,0
while M > 0 and pt < N:
    if M > AB[pt][1]:
        money += AB[pt][0] * AB[pt][1]
        M -= AB[pt][1]
    else:
        money += AB[pt][0] * M
        M = 0
    pt += 1

print(money)


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

using namespace std;

int main()
{
    string s;
    int n,l;
    vector<string>v;
    cin>>n>>l;
    while(n--){
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(auto p:v)cout<<p;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
  int n,mod=1e9+7;
ll fact[N],inv[N],arr[N];
 ll fp( ll base,ll exp){
 if(exp==0)
 return 1;
 ll ans=fp(base,exp/2);
 ans=(ans*ans)%mod;
 if(exp%2!=0){
    ans=(ans*(base%mod))%mod;
 }
    return ans;
 }
ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
int main()
{
  //cout<< fp(5,2);

     fact[0]=1;
     inv[0]=1;
   for(int i=1;i<=1e5+5;i++){
    fact[i]=(fact[i-1]*i)%mod;
    inv[i] = fp(fact[i], mod - 2);

   }

   ll ans=0;
   int k;
   cin>>n>>k;
   for(int i=0;i<n;i++){
    cin>>arr[i];
   }
   sort(arr,arr+n);
   for(int i=0;i<n;i++){
        if(n-i-1>=k-1&&k-1!=0){
            ans-=(ncr(n-i-1,k-1)*arr[i])%mod;
            ans%=mod;
        }

    if(i>=k-1&&k-1!=0){
         ans+=(ncr(i,k-1)*arr[i])%mod;
         ans%=mod;
    }


   }
cout<<ans;

   return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;
const ll TREE_SIZE = 200200;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);

class Unionfind {
    public:
        vector<ll> par, siz, rank;
        Unionfind();
        ll root(ll x);
        void merge(ll x, ll y);
        bool issame(ll x, ll y);
        ll size(ll x);
};

int main() {
    ll n, m; cin >> n >> m;
    Unionfind t;
    rep(i, m) {
        ll a, b; cin >> a >> b;
        a--; b--;
        t.merge(a, b);
    }
    ll ans = 1;
    rep(i, n) {
        if(t.size(i) >= ans) ans = t.size(i);
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}

Unionfind::Unionfind() {
    par.resize(TREE_SIZE);
    siz.resize(TREE_SIZE);
    rank.resize(TREE_SIZE);
    rep(i, TREE_SIZE) {
        par[i] = i;
        siz[i] = 1;
        rank[i] = 0;
    }
}
ll Unionfind::root(ll x) {
    if(par[x] == x) return x;
    else {
        return par[x] = root(par[x]);
    }
}
void Unionfind::merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
        par[x] = y;
        siz[y] += siz[x];
    }
    else {
        par[y] = x;
        siz[x] += siz[y];
        if(rank[x] == rank[y]) rank[x]++;
    }
}
bool Unionfind::issame(ll x, ll y) {
    return root(x) == root(y);
}
ll Unionfind::size(ll x) {
    return siz[root(x)];
}

Measured memory_bytes: 8008
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


N = II()
a = acinput()

x = 0

h = a[0]
for i in range(1, N):
    x += max(0, h-a[i])
    h = max(h, a[i])

print(x)


Measured memory_bytes: 50576
s = input()

if len(s) == 2:
    if s[0] == s[1]:
        print("1 2")
    else:
        print("-1 -1")
else:
    for i in range(len(s) - 2):
        t = s[i:i + 3]
        if t.count(t[0]) > 1 or t.count(t[1]) > 1:
            print(i + 1, i + 3)
            exit()

    print("-1 -1")

Measured memory_bytes: 3188
using System;

namespace Exawizards_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int countR = 0;
            int countB = 0;

            for (int i = 0; i < N; i++)
            {
                if (s[i] == 'R')
                {
                    countR++;
                }
                else
                {
                    countB++;
                }
            }

            if (countR > countB)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double money = 100.00;
		for(int i=0; i<n; i++){
			money = money*1.05;
			BigDecimal tmp = new BigDecimal(money);
			money = tmp.setScale(0,BigDecimal.ROUND_UP).doubleValue();
		}
		System.out.println((int)money*1000);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
int n,a[N];
double ans;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=1;i<=n;++i) ans+=1.0/a[i];
	printf("%lf",1.0/ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char str[1000];
	int i;

	while(gets(str)){
		i = 0;
		while(str[i] != '\0'){
			if(str[i] == 'a' && str[i+1] == 'p' && str[i+2] == 'p' && str[i+3] == 'l' && str[i+4] == 'e'){
				str[i] = 'p';
				str[i+1] = 'e';
				str[i+2] = 'a';
				str[i+3] = 'c';
				str[i+4] = 'h';
			}else if(str[i] == 'p' && str[i+1] == 'e' && str[i+2] == 'a' && str[i+3] == 'c' && str[i+4] == 'h'){
				str[i] = 'a';
				str[i+1] = 'p';
				str[i+2] = 'p';
				str[i+3] = 'l';
				str[i+4] = 'e';
			}

			i++;
		}

		puts(str);
	}
	
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define db double
#define pi 3.14159265358979323846
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    map<string,int> mp;
    for (int i=0;i<n;i++)
    {
        string a;
        cin>>a;
        mp[a]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
}

Measured memory_bytes: 3588
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
#define pb push_back
// to floor a/b you can do a/b and to ceiling a/b you can do (a+b-1)/b
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=(r*x);
        x=(x*x);
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=(c[j]%mod + c[j-1]%mod)%mod;
    }
    return c[k];
}

bool prime[1000001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}
//Start of Matrix Exponentiation Code
void mat_mul(ll F[2][2],ll M[2][2]) {
   ll a = ((F[0][0]%mod * M[0][0]%mod)%mod + (F[0][1]%mod * M[1][0]%mod)%mod)%mod;
   ll b = ((F[0][0]%mod * M[0][1]%mod)%mod + (F[0][1]%mod * M[1][1]%mod)%mod)%mod;
   ll c = ((F[1][0]%mod * M[0][0]%mod)%mod + (F[1][1]%mod * M[1][0]%mod)%mod)%mod;
   ll d = ((F[1][0]%mod * M[0][1]%mod)%mod + (F[1][1]%mod * M[1][1]%mod)%mod)%mod;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void mpower(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   mpower(F, n / 2);
   mat_mul(F, F);
   if (n % 2 != 0)
      mat_mul(F, M);
}
ll fib_mat(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   mpower(F, n - 1);
   return F[0][0]%mod;
}
//End of Matrix Exponentiation
/*
Segment Tree
ll ar[200005];
ll st[800005];
void build(ll si,ll ss,ll se)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return ;
    }
    ll mid=(ss+se)/2;
    build(2*si,ss,mid);
    build(2*si+1,mid+1,se);
    st[si]=(st[2*si]+st[2*si+1]);
}
ll query(ll si,ll ss,ll se,ll l,ll r)
{

   if(l<=ss && se<=r)
     return st[si];
   if(l>se || r<ss)
    return 0;
   ll mid=(ss+se)/2;
   ll x=query(2*si,ss,mid,l,r);
   ll y=query(2*si+1,mid+1,se,l,r);
   return x+y;
}
void update(ll si,ll ss,ll se,ll qi)
{
    if(ss==se)
    {
        st[si]=ar[ss];
        return;
    }
    ll mid=(ss+se)/2;
    if(qi<=mid)
        update(2*si,ss,mid,qi);
    else
        update(2*si+1,mid+1,se,qi);
    st[si]=st[2*si]+st[2*si+1];
}
*/

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll r,g,b,k;
    cin>>r>>g>>b>>k;
    while(g<=r && k>0)
    {
        g=g*2;
        k--;
    }
    while(b<=g && k>0)
    {
        b=b*2;
        k--;
    }
    if(r<g && g<b)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}





Measured memory_bytes: 3604
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    L = list(prime_fact(N).values())
    ans = 0
    for l in L:
        if 1 <= l < 3:
            ans += 1
        elif 3 <= l < 6:
            ans += 2
        elif 6 <= l < 10:
            ans += 3
        elif 10 <= l < 15:
            ans += 4
        elif 15 <= l < 21:
            ans += 5
        elif 21 <= l < 28:
            ans += 6
        elif 28 <= l < 36:
            ans += 7
        elif 36 <= l:
            ans += 8
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9504
x, y = list(map(int, input().split()))
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
if (x in A and y in A)  or (x in B and y in B) or x == y == 2 :
  print("Yes")
else :
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	auto E = abs(B - A);

	auto ans = "NO";
	for (auto i = 0; i < N - 1; i += 2)
	{
		auto minE = (-D + C) * i / 2 + (N - 1 - i) * C;
		auto maxE = (D - C) * i / 2 + (N - 1 - i) * D;
		if (minE <= E && E <= maxE)
		{
			ans = "YES";
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	//读入数据
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	//迷宫描述
	char maze[h][w];
	//距离描述
	int dis[h][w];
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			scanf(" %c", &maze[i][j]);
			dis[i][j] = INT_MAX;
		}
	}
 
	//数据处理
	//由于我们是从0开始
	x1--;
	y1--;
	x2--;
	y2--;
 
	const int dir[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};//方向定义次序无所谓
	queue<pair<int, int> > q;
	//插入起点
	dis[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		//获取队首数据
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
 
		//按照规定方向移动
		for (int i=0; i<4; i++) {
			//新坐标和距离 
			int nx = x;
			int ny = y;
			int nd = dis[x][y]+1;
			//1 ~ k步
			for (int j=1; j<=k; j++) {
				//计算新的坐标
				nx += dir[i][0];
				ny += dir[i][1];
 
				//合法性判断
				if (nx<0 || nx>=h || ny<0 || ny>=w || '@'==maze[nx][ny] || dis[nx][ny]<nd) {
					break;
				}
				if (dis[nx][ny]>nd) {
					dis[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}
 
	int ans = dis[x2][y2];
	printf("%d\n", (INT_MAX==ans ? -1 : ans));
 
	return 0;
}


Measured memory_bytes: 9132
#!/usr/bin/env python3
import sys


def solve(N: int, D: int):
    print(-(-N // (2 * D + 1)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, D)


if __name__ == '__main__':
    main()


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

int main() {
    int X, A, B; cin >> X >> A >> B;
    if (A >= B) {
        cout << "delicious" << endl;
    } else if (A + X >= B) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;

        ans_int = (int1-1) * (int2-1);

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        
        int max = 0;
        int max_index = 0;
        for(int i = 0; i < n; i++) {
            int li = sc.nextInt();
            if(max < li) {
                max = li;
                max_index = i;
            }
            l[i] = li;
        }
        
        int sum = 0;
        for(int i = 0; i < n; i++) {
            if(i != max_index) {
                sum += l[i];
            }
        }
        
        if(max < sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }           
}

Measured memory_bytes: 23636
#include<vector>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	bool era[10010]={false};
	for(int i=2;i<105;i++)if(!era[i])for(int j=i*i;j<10010;j+=i)era[j]=true;

	vector<int> p;
	for(int i=2;i<10010;i++)if(!era[i])p.push_back(i);

	for(int n;scanf("%d",&n),n;){
		int pos=distance(p.begin(),--upper_bound(p.begin(),p.end(),n));
		for(int i=pos;;i--){
			if(p[i]-p[i-1]==2){
				cout<<p[i-1]<<' '<<p[i]<<endl;
				break;
			}
		}
	}

	return 0;
}

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

int main(void){
    //int A,B,C,D;
    string temp;
    cin >> temp;
    /*
    A = temp[0] - '0';
    B = temp[1] - '0';
    C = temp[2] - '0';
    D = temp[3] - '0';
    */
    char op[3];
    rep(i,8){
        int sum = temp[0] - '0';
        
        rep(j,3){
            if(i & (1 << j)){
                op[j] = '+';
                sum += temp[j+1] - '0';
            }else{
                op[j] = '-';
                sum -= temp[j+1] -'0';
            }
        }
        if(sum == 7) break;
    }
    string ans;
    
    rep(i,3){
        cout << temp[i] << op[i] ;
    }
    //ans = temp[3];
    
    cout << temp[3] << "=7"<< endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000000

int main(){

	lli n;

	lli dp[100010];
	cin>>n;
	REP(i,100010)dp[i]=0;
	lli ans = 0;
	REP(i,n){
		lli tmpA;
		cin>>tmpA;
		dp[tmpA]++;
		if(dp[tmpA]>=2)ans++;
	}
	/*

	lli left = 0;
	lli right = n;

	while(1){
		if(left>right)break;
		while(dp[left]<=1 )left++;
		while(dp[right]<=1)right--;
		if(left>right)break;
		if(left==right){
			right++;
			while(dp[right]==0)right++;
		}
		if(DEBUG)cout<<"left="<<left<<" right="<<right<<endl;
		dp[left]--;
		dp[right]--;
	}
	*/
	if(ans%2)ans++;
	cout<<n-ans<<endl;

	return 0;
}
 

Measured memory_bytes: 1024
s = input()
operator_count = len(s) - 1
operands = list(map(int, s))

# 適当にEnumを作る
add = 0
sub = 1

for bit in range(1 << operator_count):
  result = operands[0]
  operators = []
  for i in range(operator_count):
    if bit & (1 << i):
      # +を挿入
      result += operands[i+1]
      operators.append(add)
    else:
      # -を挿入
      result -= operands[i+1]
      operators.append(sub)
  if result == 7:
    break

for idx,op in enumerate(operators):
  if op == add:
    print("{}+".format(operands[idx]),end='')
  else:
    print("{}-".format(operands[idx]),end='')
print("{}=7".format(operands[-1]))

Measured memory_bytes: 3064