akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
LL z = 1;
int read(){
	int x, f = 1;
	char ch;
	while(ch = getchar(), ch < '0' || ch > '9') if(ch == '-') f = -1;
	x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = x * 10 + ch - 48;
	return x * f;
}
int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
char s[5];
int main(){
	int i, j, n, m;
	scanf("%s", s + 1);
	for(i = 1; i <= strlen(s + 1); i++){
		if(s[i] == '9') printf("1");
		else if(s[i] == '1') printf("9");
		else printf("%c", s[i]);
	}
	return 0;
}

Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#define MOD 1000000007
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
 int main(){
    int n,cnt;
  while(cin >> n){
    cnt=0;
    vector<bool>m(n+1,true);
    for(int i=2;i*i<=n;i++)
         if(m[i]) for(int j=i+i;j<=n;j+=i)  m[j]=false;        
    for(int i=2;i<=n;i++)
            if(m[i]) cnt++;
    cout << cnt << endl;  
  } 
  return 0;
}

Measured memory_bytes: 1320
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt(scanner)

	ans := 0
	for i := 0; i < n; i++ {
		h := getNextInt(scanner)
		if h >= k {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

using namespace std;

int main()
{
    long long a, b; cin >> a >> b;
    long long g = __gcd(a, b);

    int s = sqrt(g);

    int cnt = !(g % 2);
    while (g % 2 == 0)
        g /= 2;

    for (int i = 3; i <= s; i+=2)
    {
        bool bb = false;
        while (g % i == 0)
            g /= i, bb = true;
        cnt += bb;
    }

    cout << cnt + (g > 1) + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    ll ans = 0, count1 = 0, count2 = 0, sum2 = 0;

    for (int i = 0; i < S.size(); ++i)
    {
        if (S[i] == '<')
        {
            if (count2 != 0)
            {
                if (count1 < count2)
                {
                    ans += sum2;
                }
                else
                {
                    ans += (count1 + sum2 - count2);
                }
                count1 = 0;
            }
            ans += count1;
            ++count1;
            count2 = 0;
            sum2 = 0;
        }
        else
        {
            ++count2;
            sum2 += count2;
        }
    }
    if (count2 != -1)
    {
        if (count1 < count2)
        {
            ans += sum2;
        }
        else
        {
            ans += (count1 + sum2 - count2);
        }
        count1 = 0;
    }
    cout << ans << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N+1);
    for(int i = 1; i < N+1; i++)
    {
        cin >> a.at(i);
    }
    
    int ans = -1;
    int nowpos = 1;
    int count = 0;
    for(int i = 0; i < N; i++)
    {   
        nowpos = a.at(nowpos);
        count++;
        if(nowpos == 2)
        {
            ans = count;
            break;
        }
        
    }

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

Measured memory_bytes: 640
// author mochi_yassy
// https://atcoder.jp/contests/dwacon6th-prelims/submissions/9424896
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;

using ll = long long;

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n != 0) {
    if (n&1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;

	cin >> N;

	long long mod = pow(10, 9) + 7;

	long long re_x;

	long long base = 1;

	for(long long i = 2; i < N; i++) {
		base *= i;
		base %= mod;
	}

	long long plus = base;

	long long count = 0;

	cin >> re_x;

	for(long long i = 1; i < N; i++) {
		long long x;
		cin >> x;

		long long dis = x - re_x;

		re_x = x;

		count += (base * dis) % mod;
		count %= mod;

		plus *= modpow(i + 1, mod-2, mod);
    plus %= mod;
		plus *= i;
    plus %= mod;

		base += plus;
		base %= mod;
	}

	count %= mod;

	cout << count << endl;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ABC61-D Score Attack
    ll N,M;
    cin >> N >> M;
    ll a[2010], b[2010], c[2010];
    rep(i,0,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        c[i] *= -1;
    }
    ll dist[1010] = {};
    rep(i,1,N) dist[i] = INF;
    // 更新
    rep(loop,0,N-1){
        rep(i,0,M){
            if(dist[a[i]] == INF) continue;
            if(dist[b[i]] > dist[a[i]] + c[i]){
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    bool negative[1010];
    rep(i,0,N) negative[i] = false;
    rep(loop,0,N){
        rep(i,0,M){
            if(dist[a[i]] == INF) continue;
            if(dist[b[i]] > dist[a[i]] + c[i]){
                dist[b[i]] = dist[a[i]] + c[i];
                negative[b[i]] = true;
            }
            if(negative[a[i]]) negative[b[i]] = true;
        }
    }
    
    if(negative[N-1]){
        print("inf");
    }else{
        print(-1 * dist[N-1]);
    }


    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INFL = (1LL << 60);
   const int INFI = (1 << 30);

   int main() {
     double A, B, H, M; cin >> A >> B >> H >> M;
     double rad, pi = 3.1415926535897932384626433;
     rad = H * 0.16666666666666666 - 11.0 * M / 360.0;
     cout << fixed << setprecision(15) << sqrt(A * A + B * B - 2.0 * A * B * cos(rad * pi)) << endl;

   }


Measured memory_bytes: 4216
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int a, b, c;
  scan(a, b, c);
  print(a ^ b ^ c);
  return 0;
}


Measured memory_bytes: 256
s = str(input())

test0 = [x%2 for x in range(len(s))]
test1 = [x%2 for x in range(len(s) - 1)]
test1.insert(0, 1)

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1

print(min(cnt0, cnt1))

Measured memory_bytes: 4724
n,q=map(int,input().split())
L=[[] for i in range(n+1)]
S=[0 for i in range(n+1)]
V=[0 for i in range(n+1)]

for _ in range(n-1):
    a,b=map(int,input().split())
    L[a].append(b)   
    L[b].append(a)

for _ in range(q):
    p,x=map(int,input().split())
    S[p]+=x


que=[1]
head=0
V[1]=1
while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex]==0:
            V[nex]=1
            que.append(nex)
            S[nex]+=S[now]

print(" ".join([str(i) for i in S[1:]]))

Measured memory_bytes: 72744
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
//ll MOD = 1e9 + 7;
ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  int N; cin >> N;
  char S[N][N];
  rep(i, N)rep(j, N) cin >> S[i][j];

  int ans = 0;
  rep(z, N){
    bool l = 1;
    rep(x, N){
      rep(y, N){
        if(S[(0+x)%N][(z+y)%N] != S[(0+y)%N][(z+x)%N]) l = 0;
      }
    }
    if(l) ans += N;
  }
  printf("%d\n", ans);



}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
long input(){
  long x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}



int main() {
  int N,M,K;
  cin>>N>>M>>K;
  int tate=0;
  int yoko=0;
  int sum=0;
  bool ok=false;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      sum=i*(M-j)+j*(N-i);
      
      if(sum==K){
        ok=true;

      }

    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }






  
  
}

 



Measured memory_bytes: 256
import math

def main():

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

    a_l = A / 0.08
    a_m = (A + 1) / 0.08

    b_l = B / 0.1
    b_m = (B + 1) / 0.1

    l = max(a_l, b_l)
    m = min(a_m, b_m)

    c = math.ceil(l)

    if c < m:
        print(int(c))
    else:
        print(-1)


if __name__ == '__main__':
    main()


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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> h(N+1);
    for(int i=1; i<=N; i++) cin >> h[i];

    vector<int> dp(N+1);
    dp[1] = 0;
    for(int i=2; i<=N; i++) dp[i] = 1e9;

    for(int i=2; i<=N; i++){
        for(int j=1; j<=min(K,i-1); j++){
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[N] << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i = 0; i < N-2; i++){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
      ans++;
    }
  } 

  cout << ans << endl;

  return 0;
}


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

/**
 * The Number of Island
 */
public class Main {

	final static int SEA = 0;
	final static int LAND = 1;
	final static int VISITED = -1;

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

	static LinkedList<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[][] map = new int[12][12];

		while (true) {
			// load map
			xs = new LinkedList<Integer>();
			ys = new LinkedList<Integer>();
			for (int i = 0; i < 12; i++) {
				line = br.readLine();
				for (int j = 0; j < 12; j++) {
					map[i][j] = line.charAt(j) - '0';
				}
			}

			// solve
			count = 0;
			for (int i = 0; i < 12; i++) {
				for (int j = 0; j < 12; j++) {
					if (map[i][j] == LAND) {
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							visit(map);
						}
						count++;
					}
				}
			}

			// output.
			System.out.println(count);

			// next
			line = br.readLine();
			if (line == null) {
				break;
			} else {
				continue;
			}
		}
		//
	}

	public static void visit(int[][] map) {

		int x, y;
		x = xs.remove();
		y = ys.remove();

		map[x][y] = VISITED;

		// next choices
		for (int i = 0; i < 4; i++) {
			int xv, yh;
			xv = x + V[i];
			yh = y + H[i];
			if (xv >= 0 && xv < 12 && yh >= 0 && yh < 12
					&& map[xv][yh] != VISITED && map[xv][yh] != SEA) {
				xs.add(xv);
				ys.add(yh);
			}
		}
	}
}

Measured memory_bytes: 121756
n, m = map(int, input().split())
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append([a,b])
ab.sort()

ans = 0
lmax = 0
rmin = 10**9
for x in ab:
    a = x[0]
    b = x[1]
    if rmin <= a:
        ans += 1
        lmax = 0
        rmin = 10 ** 9
    if lmax < a:
        lmax = a
    if b < rmin:
        rmin = b
print(ans+1)

Measured memory_bytes: 59788
#include<iostream>

#define ll long long

using namespace std;

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

  ll arr[n+1];
  ll presum[n+1];
  presum[0] = 0;

  for(int i = 1 ; i<=n ; i++)
  {
    cin>>arr[i];
    presum[i] = presum[i-1] + arr[i];
  }

  ll dp[n+1][n+1];

  for(int i = 0 ; i<=n ; i++)
    dp[i][i] = 0;

  for(int d = 1 ; d<= n-1 ; d++)
  {
    for(int i = 1 ; i+d <= n ; i++)
    {
      int j = i+d;
      dp[i][j] = dp[i][i] + dp[i+1][j] + (presum[j] - presum[i-1]);
      for(int k = i+1 ; k<j ; k++)
      {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + (presum[j] - presum[i-1]));
      }
    }
  }

  cout<<dp[1][n];
  
  return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}

string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}

int main(){
    vecll a(5);
    ll n=lin(),m= 10000000000000000;
    rep(i,5){
        ll a=lin();
        if(a<m)m=a;
    }
    cout<<4+(n+m-1)/m<<endl;
}

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

int main(){
  int a;
  cin >> a;
  int count;
  count = 0;
    for(int i=0; i<3; i++){
    	if (a % 10 == 1){
      		count++;
      		a = (a-1)/10;
    	}
    	else if(a == 0){
     		break;
    	}
    	else{
     		a = a/10;
    	}
    }
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int i,j,n,m,p,q,b,r,d,x,temp;

    int flag=0;
    string s;
    cin>>n>>m;
    long long int a[n];
    for(i=0; i<n; ++i){
        cin>>a[i];
    }
    sort(a,a+n);
    int maxc=0;
    int maisuu=0;
    int hajimari=0;
    long long int goukei=0;
    vector<pair<long long int,long long int>> pairs(m);
    for(i=0; i<m; ++i){
        cin>>r>>b;
        pairs[i]=make_pair(b,r);
    }
    sort(pairs.begin(),pairs.end());
    temp=m-1;
    int tenpu;
    tenpu=pairs[temp].second;
    for(i=0; i<n; ++i){
        if (a[i] < pairs[temp].first){a[i]=pairs[temp].first;}
        else{break;}
        --tenpu;
        if(tenpu==0){
            --temp;
            if(temp==-1){break;}
            tenpu=pairs[temp].second;
        }

    }
    for(i=0; i<n; ++i){
        goukei=goukei+a[i];
    }
    cout<<goukei;


    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ld n, m, d;std::cin >> n >> m >> d;
  // 2*n-2
  ld ans = 2.0;
  ans *= (m-(ld)1.0)*(n-d);
  ans /= n*n;
  if(d==0) ans/=2.0;

  std::cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main(){
    int s, w;
    cin >> s >> w;

    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

void printLCS(vector < vector <ll> > &dp, string &s, string &t, int i, int j)
{
    if (i==0 || j==0) return;
    if (s[i-1] == t[j-1]) {
        printLCS(dp, s,t, i-1, j-1);
        cout << s[i-1];
        return;
    }
    else if (dp[i][j] == dp[i][j-1]) {
        printLCS(dp, s,t, i, j-1);
    }
    else printLCS(dp, s,t, i-1, j);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    ll n=s.length();
    ll m=t.length();
    vector < vector <ll> > dp(n+1, vector <ll> (m+1));
    loop(i,0,n+1) dp[i][0]=0;
    loop(j,0,m+1) dp[0][j]=0;
    loop(i,1, n+1)
    {
        loop(j,1,m+1)
        {
            if (s[i-1]==t[j-1]) {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    } 
    printLCS(dp, s, t, n, m);
    cout << "\n";
    return 0;
}

Measured memory_bytes: 71040
#include <iostream>

using namespace std;

//There is a set A consisting of N integers 1 <= n <= 100
// there are k stones 1 <= k <= 1e5
const int MAXN = 1E5 + 2, MAXS = 1E2 + 2;
bool ans[MAXN];
int stone[MAXS];

int main () {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i ++)
		cin >> stone[i];
	ans[0] = false;
	for (int i = 1; i <= k; i ++) {
		for (int j = 0; j < n; j ++) {
			if (i >= stone[j] && ans[i - stone[j]] == false)
				ans[i] = true; 
		}
	}
	if (ans[k] == true) {
		cout << "First" << endl;
		return 0;
	}
	cout << "Second" << endl;
	return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
//	freopen("1.txt","r",stdin);
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}




Measured memory_bytes: 3600
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://atcoder.jp/contests/dp/tasks/dp_e
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(int i=1;i<=n;i++)
#define fok(i,k,n)      for(int i=k;i<=n;i++)
#define rfo(i,n)        for(int i=n;i>=0;i--)
#define rfo1(i,n)       for(int i=n-1;i>=0;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define M               (int)1e6+6
#define inf             1e18
using namespace std;

int n,m,k,x,y,z,a1,b,c,d,i,j,l,r;
int val[105],wt[105];


void knapsack1(int w)
{
    int dp[n+1][w+1];//max val considering wight upto i having knapsack of size j
    
    for(int i=0;i<=n;i++) 
    {
        for(int j=0;j<=w;j++)
        { if(i==0 || j==0)dp[i][j]=0; 
          else if(wt[i-1]>j)dp[i][j]=dp[i-1][j];//no way to take current weight
          else dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);//either choose or not
        }
    }
    
    cout<<dp[n][w]<<endl;


}

void knapsack2(int w)
{
    int sum=0;
    fo(i,n)sum+=val[i];
    int dp[n+1][sum+1];//minmum weight required to get value v

    fo(i,n+1)fo(j,sum+1){if(j==0)dp[i][j]=0;else dp[i][j]=inf;}


    fo1(i,n)
    {
        fo1(j,sum)
        {
            if(val[i-1]>j)dp[i][j]=dp[i-1][j];//no way to include
            else  dp[i][j]=min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
            
            
        }
    }
   
    int mx;
    rfo(i,sum)
    {
        if(dp[n][i]<=w){mx=i;break;}
    }
    cout<<mx<<endl;
}







void sol()
{   int w;
    cin>>n>>w;
    fo(i,n)cin>>wt[i]>>val[i];

    
    knapsack1(w);
    // knapsack2(w);
    
    // cout<<  <<endl;
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 79104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
void aiko(){
    for(int i = 0; i < 5; i++){
        cout << 3 << endl;
    }
}
int main(){

	while(1){
	    int a[10] = {0};
	    short flg = 0;
        short aiko1=0,aiko2=0,aiko3=0;
        for(int i = 0; i < 5; i++){
            cin >> a[i];
            if(i != 0){
                if(a[i-1] == a[i])flg++;
            }
            else{
                if(a[i] == 0)goto end;
                else flg++;
            }
            if(a[i] == 1)aiko1++;
            if(a[i] == 2)aiko2++;
            if(a[i] == 3)aiko3++;
        }
        //あいこの出力
        if(flg == 5) aiko();
        else if(aiko1 != 0 && aiko2 != 0 && aiko3!= 0) aiko();
        else if(aiko1 == 0){
            for(int i = 0; i < 5; i++){
                if(a[i] == 2) cout << 1 << endl;
                else cout << 2 << endl;
            }
        }
        else if(aiko2 == 0){
            for(int i = 0; i < 5; i++){
                if(a[i] == 3) cout << 1 << endl;
                else cout << 2 << endl;
            }
        }
        else if(aiko3 == 0){
            for(int i = 0; i < 5; i++){
                if(a[i] == 1) cout << 1 << endl;
                else cout << 2 << endl;
            }
        }
	}
    end:
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

class UnionFind {
    vector<int> par;
    vector<int> sizes;
public:
    UnionFind(int n) : par(n), sizes(n, 1) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
       if (x == par[x]) return x;
       return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sizes[find(x)];
    }
};

void solve(int n, int m, vector< pair<int, int> > e) {
    int ret = 0;
    for (int i = 0; i < m; i++) {
        UnionFind U(n);
        for (int j = 0; j < m; j++) {
            if (j == i) {
                continue;
            }
            U.unite(e[j].first-1, e[j].second-1);
        }
        bool flag = true;
        for (int j = 1; j < n; j++) {
            if (!U.same(0, j)) {
                flag = false;
            }
        }
        if (!flag) {
            ret++;
        }
    }
    std::cout << ret << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n, m;

    gettimeofday(&start,NULL);

    std::cin >> n >> m;
    vector< pair<int, int> > e(m);
    for (int i = 0; i < m; i++) {
        std::cin >> e[i].first >> e[i].second;
    }
    solve(n, m, e);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

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

  map<int, int> mp;

  for (ll i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    mp[tmp] ^= 1LL;
  }

  ll even = 0;
  ll odd = 0;
  for (auto kv : mp) {
    ll v = kv.second;
    if (v == 0)
      even++;
    else
      odd++;
  }
  ll ans = even + odd;
  if (even % 2 == 1) ans--;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
/***************************************************************
	File name: E.cpp
	Author: huhao
	Create time: Mon 08 Jun 2020 03:55:44 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=3010;
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1;
	for(;b;b>>=1,a=a*a%p) if(b&1) r=r*a%p;
	return r;
}
i64 n,mod,ans,s[N][N],c[N][N];
i64 &Add(i64 &a,i64 b){ return a=(a+b)%mod; }
int main()
{
	n=read(); mod=read();
	s[0][0]=1; c[0][0]=1;
	fr(i,1,n+1) c[i][0]=1;
	fr(i,1,n+1) fr(j,1,i){ s[i][j]=(s[i-1][j]*j+s[i-1][j-1])%mod; c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod; }
	fr(i,0,n)
	{
		i64 v=power(2,power(2,n-i,mod-1),mod);
		fr(k,0,i) Add(ans,(i&1?mod-1:1)*c[n][i]%mod*s[i+1][k+1]%mod*power(2,(n-i)*k,mod)%mod*v);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 139904
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n,k = map(int, input().split())
    t = 1
    for i in range(100):
        t *= k
        if n < t:
            print(i+1)
            return
        
   

main()


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2*1e9

int main()
{
    lli n,m;
    cin >> n >> m;
    lli sum=0;
    for(lli i=0;i<m;i++)
    {
        lli x;
        cin >> x;
        sum+=x;
    }
    lli d=n-sum;
    if(d<0)
        cout << "-1" << endl;
    else
        cout << d << endl;
}

Measured memory_bytes: 3636
N,*AS = $stdin.read.split.map(&:to_i)
visited = Array.new(N)
i = 1
n = 0
N.times do
  i = AS[i-1]
  n += 1
  if i == 2
    p n; exit
  end
  break if visited[i-1]
end
p -1


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

int main(){

    int n;
    cin>>n;
    vector<int> cnt(n);
    for(int i=0;i<n-1;i++){
        int x;
        cin>>x;
        cnt[x-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<cnt[i]<<endl;
    }


    return 0;
}

Measured memory_bytes: 4044
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll a[5];
    for (int i = 0; i < 5; i++) {
        std::cin >> a[i];
    }
    ll k;
    std::cin >> k;
    sort(a,a+5);
    if(a[4]-a[0] > k){
        std::cout << ":(" << std::endl;
    }else{
        std::cout << "Yay!" << std::endl;
    }
}


Measured memory_bytes: 256
while 1:
	M,T,P,R = map(int,raw_input().split())
	if M == 0: break
	S = [[-1]*P for i in range(T)]
	PN = [[0]*P for i in range(T)]
	for i in range(R):
		m,t,p,j = map(int,raw_input().split())
		if j == 0:
			S[t-1][p-1] = m + PN[t-1][p-1]
		else:
			PN[t-1][p-1] += 20
	A = [[t+1,P-S[t].count(-1),sum(S[t])] for t in range(T)]
	A = sorted(sorted(sorted(A, reverse = True), key = lambda x:x[2]), key = lambda x:x[1], reverse = True)
	ans = str(A[0][0])
	for i in range(1,T):
		if A[i-1][1] == A[i][1] and A[i-1][2] == A[i][2]:
			ans += "=" + str(A[i][0])
		else:
			ans += "," + str(A[i][0])
	print ans

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<double>vec(N);
  for (int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  sort(vec.begin(), vec.end());
  double M=vec.at(0);
  for (int X=1;X<N;X++){
    M+=vec.at(X);
    M/=2;
  }
  cout << M << endl;
}

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

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    int n; cin >> n;
    int a = 0;
    {
        int k; cin >> k;
        rep(i, k) {
            int x; cin >> x;
            a |= 1 << x;
        }
    }
    rep(b, a+1) {
        if ((a | b) == a) {
            cout << b << ":";
            rep(i, n) {
                if ((b >> i) & 1) cout << " " << i;
            }
            cout << endl;
        } 
    }
}


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

int main() {
	long long int n;
	cin>>n;
	long long int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	long long int m=0;
	long long int sum=0;
	for(int i=0;i<n;i++){
	    if(arr[i]>m){
	        m=arr[i];
	    }else{
	        sum+=(m-arr[i]);
	    }
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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 x, y;
    cin >> x >> y;

    ll ans = 1;
    ll v = x;
    while(v <= y){
        v *= 2;
        if(v <= y){
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var h = sc.ArrayInt(N);
        var f = new int[N];
        var ans = 0;
        for (int i = 1; i < N; i++) {
            if (h[i] < h[i-1]) {
                ans += h[i - 1] - h[i];
            }
        }
        WriteLine(ans + h[N - 1]);
    }


}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11092
from collections import defaultdict,deque
import math
def main():
    n = int(input())
    res = 0
    a=[int(i) for i in input().split()]
    if(n<3):
        print(0)
        exit()
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if(a[i]!=a[j] and a[i]!=a[k] and a[j]!=a[k] and (a[i]+a[j] > a[k] and a[j]+a[k]>a[i] and a[i]+a[k]>a[j])):
                    res+=1
    print(res)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9488
<?php

// 単一行
//$single_line_input = fgets(STDIN);
//$input = explode(" ", $single_line_input);

// 複数行
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}
foreach ($tmp as $key => $value) {
    $input[] = explode(" ", $value);
}

// --- ↓ ここから

$N = $input[0][0];
$S = $input[1][0];
$x = 0;
$max_x = 0;

for($i = 0; $i <= $N; $i++){
    if(substr($S, $i, 1) == I){
        $x ++;
    }else{
        $x --;
    }
    $max_x = bigger($x, $max_x);
}

echo $max_x;

function bigger($a, $b){
    if($a > $b){
        return $a;
    }else{
        return $b;
    }
}

Measured memory_bytes: 16328
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int i, n;
	short a[101];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	if (n >= 1) printf("%d", a[n - 1]);
	for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define de_x(x) cout<<"debug_val: "<<x<<endl;
#define de_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
std::mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x ; }
const ll mod=1000000007;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int _;
/***********************/

void run(){
}
int main(){
//	for(scanf("%d",&_); _;_--) run();	
	int n ,r,cnt =0;
    cin>> n >>r;
    while(n){
        n/=r;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let x: i64 = read();
    if x == 3 || x == 5 || x == 7 {
        println!("{}", "YES")
    } else {
        println!("{}", "NO")
    }
}


Measured memory_bytes: 4352
import java.util.*;
import java.lang.*;

public class Main{
	static Tree tree;
	static boolean[] visited;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		tree = new Tree(n);
		for (int i = 0; i < n - 1; i++) {
			tree.union(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		for (int i = 0; i < q; i++) {
			tree.node[sc.nextInt() - 1].value += sc.nextInt();
		}
		visited = new boolean[n];
		visited[0] = true;
		dfs(0);
		for (int i = 0; i < n - 1; i++) {
			System.out.print(tree.node[i].value + " ");
		}
		System.out.println(tree.node[n - 1].value);
	}
	static void dfs(int n) {
		visited[n] = true;
		for (int key : tree.node[n].list) {
			if (!visited[key]) {
				visited[key] = true;
				tree.node[key].value += tree.node[n].value;
				dfs(key);
			}
		}
	}
}

class Node {
	ArrayList<Integer> list;
	int value;
	Node() {
		list = new ArrayList<>();
		value = 0;
	}
}

class Tree {
	Node[] node;
	Tree(int n) {
		node = new Node[n];
		for (int i = 0; i < n; i++) {
			node[i] = new Node();
		}
	}
	void union(int n, int m) {
		node[n].list.add(m);
		node[m].list.add(n);
	}
}


Measured memory_bytes: 236492
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (X, t) = Read2Longs();
            return X - t > 0 ? X - t : 0;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28064
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math


n = int(input())
li = []
for i in range(8):
    li.append(2**i)

for i in range(1,len(li)):
    if li[i-1] <= n and n < li[i]:
        break
print(li[i-1])

Measured memory_bytes: 12504