akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> A(1);
  for(ll i=1;i<=9;i++)A.push_back(i);
  for(ll i=1;i<=N;i++){
    if(A.at(i)%10!=0)A.push_back(A.at(i)*10+A.at(i)%10-1);
    A.push_back(A.at(i)*10+A.at(i)%10);
    if(A.at(i)%10!=9)A.push_back(A.at(i)*10+A.at(i)%10+1);
  }
  cout<<A.at(N)<<endl;
}

Measured memory_bytes: 5744
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> x(n),l(n);
    rep(i,n) cin >> x[i] >> l[i];
    priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
    ll ans = 0;
    rep(i,n)pq.push(Pll(x[i]+l[i], x[i]-l[i]));
    ll max_ = -INF;
    while(pq.size()){
        Pll t = pq.top();pq.pop();
        if(max_ <= t.second){
            ans++;
            max_ = t.first;
        }
    }
    cout << ans << endl;
}

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

int N;

int c[30];
int ans[30]={1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3};
int change[4][10]={
    {0,27,1,28,2,29,14,15,18,20},
    {0,23,3,26,6,29,9,20,15,17},
    {6,21,7,22,8,23,12,17,9,11},
    {2,21,5,24,8,27,11,18,12,14},
};

bool isOk(){
    for(int i=0;i<30;i++)if(c[i]!=ans[i])return false;
    return true;
}

void changer(int i){
    for(int j=0;j<5;j++)swap(c[change[i][j*2]],c[change[i][j*2+1]]);
}

int dfs(int cnt=0){
    if(cnt>=8)return 8;
    if(isOk())return cnt;
    int ret=8;
    for(int i=0;i<4;i++){
        changer(i);
        ret=min(ret,dfs(cnt+1));
        changer(i);
    }

    return ret;

}
void solve(){
    for(int i=0;i<30;i++)cin>>c[i];


    cout<<dfs()<<endl;
}

int main(){
    cin>>N;
    while(N--)solve();
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a!=b&&a!=c){
    cout<<a;
   }
   else if(b!=a&&b!=c){
    cout<<b;
   }
   else if(c!=a&&c!=b){
    cout<<c;
   }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define ll long long

int main(){
  float t,x;cin>>t>>x;
  float ans = t/x;
  cout<<ans<<endl;


  return 0;
}




Measured memory_bytes: 888
#include <iostream>

int main(int argc, char** argv) {
  const unsigned long long N {[](){unsigned long long a;std::cin >> a;return a;}()};
  if (N % 2 != 0) std::cout << "0\n";
  else {
    unsigned long long tmp_prime {N/2};
    unsigned long long five_div_count {};
    unsigned long long five_div {5};
    for (;N>five_div;five_div*=5) {
      five_div_count += tmp_prime / five_div;
    }
    std::cout << five_div_count << '\n';
  }
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

 	string a;
 	cin >> a;
 	if(a[a.length() - 1] == 's') a += "es";
 	else a += "s";
 	cout << a << endl;   
    return 0;
}

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

"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def generate_adj_table(_edges):
    for edge in _edges:
        vx, vy = map(int, edge)
        init_adj_table[vx].add(vy)

    return init_adj_table


def graph_dfs(current, matching, visited):
    for adj in range(y_num):
        if (not visited[adj]) and (adj in adj_table[current]):
            visited[adj] = True
            # matching[adj] = -1: adj not assigned to any of x
            # graph_dfs(matching[adj], matching, visited) = True
            # indicates that source in x has been already assigned to another target in y
            if matching[adj] == -1 or graph_dfs(matching[adj], matching, visited):
                matching[adj] = current
                return True
    return False


def mbm():
    matching = [-1] * y_num
    res = 0
    for v in range(x_num):
        visited = [False] * y_num
        if graph_dfs(v, matching, visited):
            res += 1
    # print(matching)
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [set() for _ in range(x_num)]
    adj_table = generate_adj_table(edges)
    print(mbm())

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 60;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    /*
    int t,n;
    cin>>t;
    loop(t1,1,t+1)
    {
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    int n;
    cin>>n;
    LL a[n+1], sm[n+1];
    loop(i,0,n+1)
    {
        cin>>a[i];
        sm[i] = a[i];
        if(i) sm[i] += sm[i-1];
    }

    LL ans = 1, pre = 1, sl;
    if(n == 0)
    {
        if(a[0] > 1) ans = -1;
    }
    else if(a[0]) ans = -1;
    else
    {
        loop(i,1,n)
        {
            sl = sm[n] - sm[i-1];
            if(pre*2 < a[i]) {ans = -1;break;}
            pre = min(pre*2,sl);
            ans += pre;
            pre -= a[i];
        }

        if(ans != -1)
        {
            if((2*pre) < a[n]) ans = -1;
            else ans += a[n];
        }
    }

    cout<<ans<<'\n';

    /*
    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 5196
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


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

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 3e3 + 10;

ll a[N];
ll dp[N][N][2];

ll solve(ll i, ll j, int turn);

int main() {
    fast_io();
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            dp[i][j][0] = dp[i][j][1] = -1;
        }
    }
    cout << solve(0, n - 1, 0) << "\n";
    return 0;
}

ll solve(ll i, ll j, int turn) {
    auto &ans = dp[i][j][turn];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    if (i > j) {
        return ans;
    }
    ans = max(a[i] - solve(i + 1, j, turn ^ 1), a[j] - solve(i, j - 1, turn ^ 1));
    return ans;
}


Measured memory_bytes: 142080
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
    ll divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	ll n;
	cin >> n;
	ll ans = n / 11 * 2;
	ll rest = n - n / 11 * 11;
	while (rest > 0) {
		rest -= 6;
		ans++;
		if (rest <= 0) {
			break;
		}
		else {
			rest -= 5;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n;
        cin>>n;
        int x,y;
        vector<int> v;
        vector<int> u;
        fori(i,n) {
            cin>>x>>y;
            u.pb(x);
            v.pb(y);
        }
        int ans = 0;
        srt(u);
        srt(v);
        if(n%2) {
            ans = v[n/2] - u[n/2] + 1;
        } else {
            ans = v[n/2-1] + v[n/2] - u[n/2-1] - u[n/2] + 1;
        }
        cout<<ans;
    }
    
    return 0;
}

Measured memory_bytes: 6696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int H = ni();
        int W = ni();
        int N = ni();
        int num = Math.max(H,W);
 
        long ans = (N+num-1)/num;
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int upperBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new UpperBoundComparator<Long>());
        return ~i;
    }
    class UpperBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) > 0) ? 1 : -1;
        }
    }
    int lowerBound(ArrayList<Long> list, Long target){
        int i = Collections.binarySearch(list, target, new LowerBoundComparator<Long>());
        return ~i;
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T>{
        public int compare(T x, T y){
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33124
n = int(input())
x = list(map(int, input().split()))
count = 0
maxnum = 0
i = 0

while i < n - 1:
    if x[i] >= x[i + 1]:
        count += 1
    if x[i] < x[i + 1]:
        if maxnum < count:
            maxnum = count
        count = 0
    i+=1

if maxnum < count:
    maxnum = count
print(maxnum)


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

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

    int i = s.size()-1;
    string ans = "YES";
    while(i > 0) {
        if (i >= 5 && (s[i] == 'r' && s[i-1] == 'e')) {
            if (s.substr(i-5, 6) == "eraser") {
                i -= 6;
                continue;
            } else if (s.substr(i-6, 7) == "dreamer") {
                i -= 7;
                continue;
            } else {
                ans = "NO";
                break;
            }
        } else if (i >= 4 && s[i] == 'm') {
            if (s.substr(i-4, 5) == "dream") {
                i -= 5;
                continue;
            } else {
                ans = "NO";
                break;
            }
        } else if (i >= 4 && s[i] == 'e') {
            if (s.substr(i-4, 5) == "erase") {
                i -= 5;
                continue;
            } else {
                ans = "NO";
                break;
            }
        } else {
            ans = "NO";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
int n;
std::pair<int,int> p[100010];
int main(){
    std::cin>>n;
    int x;
    for (int i=1;i<=n;i++){
        std::cin>>x;
        p[i].first=x;
        p[i].second=i;
    }
    std::sort(p+1,p+n+1);
    for (int i=1;i<=n;i++){
        std::cout<<p[i].second<<" ";
    }
    return 0;
}

Measured memory_bytes: 1536
N,Ma,Mb=map(int,input().split())
dp=[[[10**9]*401 for i in range(401)] for i in range(N)]
for i in range(N):
  a,b,c=map(int,input().split())
  if i==0:
    dp[0][a][b]=c
    dp[0][0][0]=0
  else:
    for p in range(401):
      for q in range(401):
        if p>=a and q>=b:
          dp[i][p][q]=min(dp[i-1][p][q],dp[i-1][p-a][q-b]+c)
        else:
          dp[i][p][q]=dp[i-1][p][q]
ans=10**9
for a in range(1,401):
  if Mb*a/Ma<=400 and Mb*a%Ma==0:
    ans=min(ans,dp[N-1][a][Mb*a//Ma])
if ans==10**9:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 95036
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<numeric>
using namespace std;

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

	vector<int> p(N);
	for(int i=0; i<N; i++)
		cin >> p[i];

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

	p[N-1] /= 2;

	cout << accumulate(p.begin(), p.end(), 0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

void dfs(int c_node, vector< vector<int> > &G, vector<int> &Point, vector<bool> &Checked){
    // cout << "Now at " << c_node << endl;
    Checked[c_node] = true;
    if(G[c_node].size()==0){
        return;
    }
    else{
        for(auto n_node : G[c_node]){
            if(Checked[n_node]==false){
                Point[n_node]+=Point[c_node];
                dfs(n_node, G, Point, Checked);
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    vector< vector<int> > G(n, vector<int>(0,0));
    REP(i,n-1){
        int u,v;
        cin >> u  >> v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<bool> Checked(n,false);
    vector<int> Point(n,0);
    REP(i,q){
        int node, x;
        cin >> node >> x;
        node--;
        Point[node]+=x;
    }
    // REP(i,n) cout << Point[i] << " ";
    // cout << endl;
    dfs(0,G,Point, Checked);
    REP(i,n) cout << Point[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 29824
module Main where
-- import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
-- import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad

solve :: [Int] -> [Int] -> Int
solve s t = length (intersect t s)

readLine :: IO [Int]
readLine = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main :: IO() 
main = do
    n <- readLn :: IO Int
    s <- readLine
    q <- readLn :: IO Int
    t <- readLine
    print $ solve s t



Measured memory_bytes: 4268
// BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

using namespace std;

/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
	lli res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%p;
		//y must be even now
		y=y>>1; //y=y/2
		x=(x*x)%p;
	}
	return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b) 
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b) 
{
  if (a < b)
    return a;
  return b;
}
lli bins(lli arr[], lli l, lli r, lli x)
{
  if (r >= l) {
    lli mid = l + (r - l) / 2;
    if (arr[mid] == x)
      return mid;
    if (arr[mid] > x)
      return bins(arr, l, mid - 1, x);
    return bins(arr, mid + 1, r, x);
  }
  return -1;
}
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
const int INF=1e9+5;
int main()
{
 kira;
 lli n,W;
 cin>>n>>W;
 vector<lli>dp(W+1);
 forz(it,n)
 {
   lli w,v;
   cin>>w>>v;
   //cout<<dp[0];
   for(int rem=W-w;rem>=0;rem--)
   {
     dp[rem+w]=max(dp[rem]+v,dp[rem+w]);
   }
 }
 lli a=0;
 for(int i=0;i<=W;i++)
 {
   //p0(dp[i]);
   a=max(a,dp[i]);
 }
 p0(a);
 return 0;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.readline

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

l = [0] * len(A)
r = [0] * len(A)

for i,a in enumerate(A):
    if i - a >= 0:
        l[i - a] += 1
    if i + a < len(A):
        r[i + a] += 1

ans = 0

for x,y in zip(l, r):
    ans += x * y

print(ans)


Measured memory_bytes: 31096
#include <stdio.h>

int main (void)
{
        int A,B,C;
        int tmp;

        scanf("%d %d %d",&A,&B,&C);

        //switch A and B
        tmp = B;
        B = A;
        A = tmp;

        //switch A and C
        tmp = C;
        C = A;
        A = tmp;

        printf("%d\n",A);
        printf("%d\n",B);
        printf("%d\n",C);

        return 0;
}


Measured memory_bytes: 128
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define pair pair<LL,LL>
#define space putchar(' ')
using namespace std;
    
template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    
template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int n;
LL a[1000005];
int k;
int ans;
bool flag1,flag2;
int flag=-1;

int main()
{
	read(n);
	for(RI i=1;i<=n;++i)
		read(a[i]);

	for(RI i=1;i<=n;++i)
	{
		if(flag==-1 && !flag1 && !flag2)
		{
			++ans;
			flag=a[i];
			continue;
		}
		if(flag!=-1 && !flag1 && !flag2)
		{
			if(flag==a[i]) 
				continue;
			if(flag>a[i]) 
				flag1=1;//不上升 
			else if(flag<a[i]) 
				flag2=1;//不下降 
			flag=a[i];
		}
		else if(flag1)//不上升
		{
			if(a[i]<=flag) 
				flag=a[i];
			else 
			{
				flag=-1;
				flag1=0;
				--i;
			}
		}
		else if(flag2)//不下降
		{
			if(a[i]>=flag) 
				flag=a[i];
			else 
			{
				flag=-1;
				flag2=0;
				--i;
			}
		} 
	}
	print(ans);	
	return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            if(N == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

LL comb(LL value, LL cnt);

int main(){
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    REP(i,N)cin>>A[i];

    int count_even = 0;
    int count_odd = 0;
    REP(i,N){
        if(A[i]%2==0){
            count_even++;
        }else{
            count_odd++;
        }
    }

    LL comb_even = 0;
    LL comb_odd = 0;

    for(int i=0; i<=count_even; i++){
        comb_even += comb(count_even, i);
    }

    for(int j=P; j<=count_odd; j+=2){
        comb_odd += comb(count_odd, j);
    }

    cout << comb_even*comb_odd << endl;
    return 0;
}

LL comb(LL value, LL cnt){
    if(cnt==0){return 1;}
    LL ans = 1;
    for(LL i=0; i<cnt; i++){
        ans *= (value-i);
        ans /= (i+1);
    }
    return ans;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
 
#define ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second

#define pq priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define MAX  *max_element
#define MIN  *min_element
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
 
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)
 
#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)
 
#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define INF 1e18
 
const double PI = acos(-1);
 
bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
 
struct hash_pair{ 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
	ll n;
	cin>>n;
	vector<double> p(n+1);
	for(int i=1;i<=n;i++)cin>>p[i];
	double dp[n+1][n+1];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		dp[0][i]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp[i][j] = dp[i-1][j]*(1-p[i]);
			if(j-1>=0){
				dp[i][j]+=(dp[i-1][j-1]*p[i]);
			}
		}
	}
//	rep(i,n+1){
//		rep(j,n+1)cout<<dp[i][j]<<" ";
//		cout<<endl;
//	}
	double ans=0;
	for(int i=(n/2)+1;i<=n;i++){
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 74108
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	int n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a.at(i);
	}
	vector<int> b(n);
	for (int i = 0; i < n-1; ++i)
	{
		b.at(i)=a.at(i+1)-a.at(i);
	}
	b.at(n-1)=a.at(0)+k-a.at(n-1);
	sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
	cout << k-b.at(0) << endl;

}

Measured memory_bytes: 1792
#include<stdio.h>
#include<queue>

std::priority_queue<int> A;
int N, M, a, i;
long sum;

int main(void){
	scanf("%d%d", &N, &M);
	for(i=0; i<N; i++){
		scanf("%d", &a);
		sum += a;
		A.push(a);
	}
	for(i=0; i<M; i++){
		a = A.top();
		A.pop();
		sum -= (a+1)>>1;
		A.push(a>>1);
	}
	printf("%ld\n", sum);
}



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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	vector<int>b(n);
	for (int i = 0; i < n; i++)cin >> b.at(i);
	vector<int>c(n);
	for (int i = 0; i < n; i++)c.at(i) = a.at(i) - b.at(i);
	sort(c.begin(), c.end());
	ll plus = 0;
	ll total = 0;
	ll mc = 0;
	for (int i = 0; i < n; i++) {
		if (c.at(i) > 0)plus += c.at(i);
		else if (c.at(i) < 0)mc += abs(c.at(i)) / 2;
		total += c.at(i);
	}
	if (total>0||mc<plus)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_129
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static void Main(string[] args)
        {
            var L = ReadLine();
            var len = L.Length;
            var dp = new long[len + 1, 2];
            dp[0, 1] = 1;
            long mod = 1000000000 + 7;
            for (var i = 0; i < len; ++i)
            {
                if(L[i]=='1')
                {
                    dp[i + 1, 1] = dp[i, 1] * 2;    //(0,1),(1,0)
                    dp[i + 1, 0] = dp[i, 1];        //(0,0)
                    dp[i + 1, 0] += dp[i, 0] * 3;   //(0,0),(0,1),(1,0)
                }
                else
                {
                    dp[i + 1, 1] = dp[i, 1];        //(0,0)
                    dp[i + 1, 0] = dp[i, 0] * 3;    //(0,0),(0,1),(1,0)
                }
                dp[i + 1, 1] %= mod;
                dp[i + 1, 0] %= mod;
            }
            WriteLine((dp[len, 1] + dp[len, 0]) % mod);
        }
    }
}


Measured memory_bytes: 13140
//#STAY_HOME
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#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 lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
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])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N;
  in(N);
  ull ans=0;
  up(i,1,N){
    if(i%3==0&&i%5==0){}
    else if(i%3==0){}
    else if(i%5==0){}
    else ans+=i;
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

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


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


int main() {
    int n,d;
    cin >> n >> d;
    vector< vector<int>>  x(n,vector<int>(d,0));
    rep(i,n)rep(j,d) cin >> x[i][j];
    int ans = 0;
    vector<int> dist;
    rep(i,n){
        rep(j,n){
            int x_sum = 0;
            rep(k,d){                
                if(i != j && i < j){
                   x_sum += pow(x[i][k] - x[j][k] , 2);
                }
            }
            if(x_sum != 0)dist.push_back(x_sum);
            
        }
    }
    sort(dist.begin(),dist.end());
    vector<int> table(201,0);
    for(int i = 0;i<=200;i++){
        table.at(i) = i*i;
    }
    rep(i,dist.size()){
        rep(j,table.size()){
            if(dist.at(i) == table.at(j)){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

string s[10];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i)
        cin >> s[i];

    int sol = 1e9;
    for (int m = 0; m < (1 << (h - 1)); ++m)
    {
        vi v(h);
        int cnt = 1;
        for (int i = 0; i < h - 1; ++i)
        {
            if (m & (1 << i))
            {
                v[i] = cnt++;
                for (int j = i - 1; j >= 0 && !v[j]; --j)
                    v[j] = v[i];
            }
        }
        for (int j = h - 1; j >= 0 && !v[j]; --j)
            v[j] = cnt;

        vi num(h);
        int current = cnt - 1;
        for (int j = 0; j < w; ++j)
        {
            vi col(h);
            for (int i = 0; i < h; ++i)
                if (s[i][j] == '1')
                    col[v[i] - 1]++;

            for (int i = 0; i < h; ++i)
            {
                if (col[i] > k)
                {
                    current = 1e9;
                    goto brk;
                }
            }

            for (int i = 0; i < h; ++i)
            {
                if (num[i] + col[i] > k)
                {
                    current++;
                    num = col;
                    goto foo;
                }
            }
            for (int i = 0; i < h; ++i)
                num[i] += col[i];
        foo:;
        }
    brk:
        sol = min(sol, current);
    }
    cout << sol;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; cin >> N;

    map< ll, int > mp;
    for(ll i=2; i*i<=N; i++) {
        while(N % i == 0) {
            mp[i]++;
            N /= i;
        }
    }
    if(N > 1) mp[N]++;

    ll ans = 0;
    for(auto e : mp) {
        ll cnt = e.second;
        for(ll i=1; ; i++) {
            if(cnt < i) break;
            ans++;
            cnt -= i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r,a,b,c,d ;
    cin >> W >> H >> x >> y >> r;
    
    a = x + r ;
    b = x - r ;
    c = y + r ;
    d = y - r ;
    
    if(0 <= b && a <= W && 0 <= d && c <= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3116
n=int(input())
arr=list(map(int,input().split()))
if n%2==0:
  ans=-10**18
  dp=[[0]*2 for _ in range(n+10)]
  for i in range(n):
    dp[i+1][0]=dp[i-1][0]+arr[i]
    dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
  ans=max(ans,dp[n-1][0],dp[n][1])
  dp=[[0]*2 for _ in range(n+10)]
  for i in range(1,n):
    dp[i+1][0]=dp[i-1][0]+arr[i]
    dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
  ans=max(ans,dp[n][0])
  print(ans)
else:
  ans=-10**18
  dp=[[0]*3 for _ in range(n+10)]
  for i in range(n):
    dp[i+1][0]=dp[i-1][0]+arr[i]
    dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
    dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
  ans=max(ans,dp[n-2][0],dp[n-1][1],dp[n][2])
  dp=[[0]*3 for _ in range(n+10)]
  for i in range(1,n):
    dp[i+1][0]=dp[i-1][0]+arr[i]
    dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
    dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
  ans=max(ans,dp[n-1][0],dp[n][1])
  dp=[[0]*3 for _ in range(n+10)]
  for i in range(2,n):
    dp[i+1][0]=dp[i-1][0]+arr[i]
    dp[i+1][1]=max(dp[i-1][1]+arr[i],dp[i-2][0]+arr[i])
    dp[i+1][2]=max(dp[i-1][2]+arr[i],dp[i-2][1]+arr[i],dp[i-3][0]+arr[i])
  ans=max(ans,dp[n][0])
  print(ans)

Measured memory_bytes: 86972
#include<cstdio>
#include<iostream> 
using namespace std;
int X;
int main(){
	scanf("%d",&X);
	if(400<=X&&X<600)printf("8");
	else if(X<800)printf("7");
	else if(X<1000)printf("6"); 
	else if(X<1200)printf("5");
	else if(X<1400)printf("4");
	else if(X<1600)printf("3");
	else if(X<1800)printf("2");
	else if(X<2000)printf("1");
	return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
int rand(int s);
int main(){
	 int i,s,j,n;
	 int a[8];
	 scanf("%d",&n);
	 j = n;
	 while(n--){
		 scanf("%d",&s);
		 printf("Case %d:\n",j-n);
		 for(i=0;i<10;i++){
			 s = rand(s);
			 printf("%d\n",s);
		 }
	 }

	 return 0;
}

int rand(int s){
	int i,r=0;
	s *= s;s /= 100;
	for(i=1;i<1001;i*=10){
		r += (s%10)*i;
		s /= 10;
	}
	return r;
}
			
 /* for(i=0;i<8;i++) a[i] = 0;
		 for(i=0;i<8;i++){ 
			 a[i] = s%10;
			 s/=10;
		 }
		 for(i=2;i<6;i++){
			 s += a[i]*j;
			 j*=10;
		 }*/

Measured memory_bytes: 1020
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		int B = sc.nextInt();
		sc.close();
		SimpleDateFormat sdf = new SimpleDateFormat("H");
        Date date = new Date();
        try {
        	date = sdf.parse(A);
        }catch(ParseException e) {
            e.printStackTrace();
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.HOUR, B);
        System.out.println(sdf.format(calendar.getTime()));
	}
}


Measured memory_bytes: 23244
def main():
    s = input()
    ans = 0
    for i in range(2 ** (len(s) - 1)):
        tmp = ""
        for j in range(len(s)):
            tmp += s[j]
            if (i >> j) & 1:
                tmp += "+"
        else:
            ans += eval(tmp)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		int q = scanner.nextInt();
		int[] st = new int[n];
		for (int i = 0; i < n; i++)
			st[i] = scanner.nextInt();
		int[] s = Arrays.copyOf(st, n);
		Arrays.sort(s);
		List<Integer> list = new ArrayList<Integer>();
		while (q-- > 0) {
			char query = scanner.next().charAt(0);
			int x = scanner.nextInt();
			if (query == 'A') {
				list.add(st[x - 1]);
			} else if (query == 'R') {
				list.remove(list.indexOf(st[x - 1]));
			} else {
				Collections.sort(list);
				int r = INF;
				int l = 0;
				while (r != l) {
					int mid = (r + l) / 2;
					int pre = 0;
					int BAN = 0;
					for (int i : list) {
						int p = lower(s, i - mid);
						BAN += Math.max(p - pre, 0);
						pre = upper(s, i);
					}
					BAN += n-pre;
					if (BAN <= x)
						r = mid;
					else
						l = mid + 1;
				}
				System.out.println(l != INF ? l : "NA");
			}
		}
	}

	private int lower(int[] s, int i) {
		int p = Arrays.binarySearch(s, i);
		if (p < 0) {
			p = p * -1 - 1;
		} else {
			for (int j = p - 1; j >= 0; j--) {
				if (s[j] != i)
					break;
				p--;
			}
		}
		return p;
	}

	private int upper(int[] s, int i) {
		int pre = Arrays.binarySearch(s, i);
		for (int j = pre + 1; j < n; j++) {
			if (s[j] != i)
				break;
			pre++;
		}

		return pre + 1;
	}

	int INF = 1000000001;
	int n;
}

Measured memory_bytes: 302220
#include <iostream>
#include <algorithm>
#include <deque>

int main() {
    int N;
    std::cin >> N;
    std::deque<char> S;
    for (auto i=0; i<N; ++i) {
        char temp;
        std::cin >> temp;
        S.push_back(temp);
    }
    int cnt = 0;
    for (auto i = S.rbegin(); i!=S.rend(); ++i) {
        if ((*i)==')') {
            ++cnt;
        } else {
            --cnt;
            if (cnt < 0) {
                S.push_back(')');
                ++cnt;
            }
        }
    }
    for (int i=0; i<cnt; ++i) {
        S.push_front('(');
    }
    for (auto elem : S) {
        std::cout << elem;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int flag = 0;
    scanf("%d",&N);
    for(int i = 0; i <= (int)(N/7); i++)
    {
        if((N-7*i)%4 == 0)
        {
            flag = 1;
            break;
        }
    }
    printf("%s\n",(flag == 1)? "Yes":"No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, k;
    cin >> k >> n;
    if (k == 1) {
        forn(i, 0, (n + 1) / 2) cout << 1 << ' ';
        return 0;
    }
    if (k % 2 == 0) {
        cout << k / 2 << ' ';
        forn(i, 1, n) cout << k << ' ';
    } else {
        if (n % 2) {
            cout << (k + 1) / 2 << ' ';
            --n;
        }
        int cnt = n / 2;
        vector<int> ans(n, (k + 1) / 2);
        while (cnt--) {
            int last = n - 1;
            while (ans[last] == 0)
                --last;
            if (ans[last] >= 2) {
                --ans[last];
                forn(j, last + 1, n)
                    ans[j] = k;
            } else {
                ans[last] = 0;
            }
        }
        for (int x : ans) {
            if (x == 0) break;
            cout << x << ' ';
        }
    }
}


Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	if(n>=30){
		cout<<"Yes";
	} else cout<<"No";
	RE 0;
}




Measured memory_bytes: 3644
if __name__ == '__main__':
    A = input().split()
    stack = []
    for s in A:
        stack.append(s)
        if s == "+":
            stack.pop()
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif s == "-":
            stack.pop()
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif s == "*":
            stack.pop()
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)

    print(stack[0])



Measured memory_bytes: 5600