akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>
#include <sstream>

using namespace std;

class apc001_e {
private:
    void dfs(int u, const vector<vector<int>> &g, vector<int> &vis,
            vector<int> &dp)
    {
        vis[u] = 1;
        dp[u] = 0;
        int num_zero = 0;
        for (int v : g[u]) {
            if (!vis[v]) {
                dfs(v, g, vis, dp);
                dp[u] += dp[v];
                num_zero += (dp[v] == 0);
            }
        }
        if (num_zero > 1) {
            dp[u] += num_zero - 1;
        }
    }
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<vector<int>> g(N);
        for (int i = 0; i < N - 1; ++i) {
            int a, b;
            in >> a >> b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        int root = 0;
        for (int u = 0; u < N; ++u) {
            if (g[u].size() > 2U) {
                root = u;
                break;
            }
        }
        if (g[root].size() <= 2U) { // path
            out << 1 << "\n";
            return;
        }
        vector<int> vis(N, 0), dp(N, 0);
        dfs(root, g, vis, dp);
        out << dp[root] << "\n";
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	apc001_e solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll MOD;

const int SZ = 5005;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

const int MAX_N = 5010;
ll dp[MAX_N][MAX_N];

ll ways(int N, int i) {

  ll tni = 1;
  ll tni1 = mod_pow(2, N-i, MOD);
  ll res = 0;
  for (int j = 0; j <= i; j++) {
    res += dp[i][j] * tni;
    res %= MOD;
    (tni *= tni1) %= MOD;
    // cout << "ways2(" << j << ")" << res << endl;
  }

  ll mm = 1;
  REP(p, N-i) mm = (mm * 2) % (MOD - 1);
  res *= mod_pow(2, mm, MOD);
  res %= MOD;

  // cout << "ways(" << N << "," << i << ")=" << res << endl;
  return res;
}

int main2() {
  int N; cin >> N;
  cin >> MOD;

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

  CLR(dp, 0);
  for (int i = 0; i <= N; i++) dp[i][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = ((j+1) * dp[i-1][j] + dp[i-1][j-1]) % MOD;
    }
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    ll sub_i = choose(N, i) * ways(N, i);
    ans += (i % 2 == 0 ? +1 : -1) * sub_i;
    ans = (ans % MOD + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

a,b,c,d = map(int, input().split())
x = (b//c - (a - 1)//c)
y = (b//d - (a - 1)//d)
z = (b//((c * d)//fractions.gcd(c,d)) - (a - 1)//((c * d)//fractions.gcd(c,d)))

print(int((b - a + 1) - (x + y - z)))


Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int kaibun(string s, int n, int m) {
    int ans = 1;
    // for (int i = n; i <= m; i++) {
    //     cout << s[i];
    // }
    // cout << endl;
    for (int i = 0; i * 2 < m - n; i++) {
        // cout << "s[" << n + i << "]=" << s[n + i] << " s[" << m - i
        //      << "]=" << s[m - i] << endl;
        if (s[n + i] != s[m - i]) {
            ans = 0;
            break;
        }
    }
    return ans;
}

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

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        int max = 0;
        sc.close();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A' || s.charAt(i)=='C' || s.charAt(i)=='G' || s.charAt(i)=='T') {
                count++;
                if(max<count){
                    max = count;
                }
            }else{
                count = 0;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23380
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Comparator;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    System.out.println((A>B)?A+A-1:(A==B)?A+B:B+B-1);
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  string result = "Yes";
  if (S.length()%2==1) result = "No";
  else {
    rep(i,S.length()) {
      if (i%2==0&&S[i]!='h') result = "No";
      else if (i%2==1&&S[i]!='i') result = "No";
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N, K = (int(x) for x in input().split())

result = 0
count = 0
for n in reversed(range(1, N + 1)):
	while(True):
		if n >= K:
			result += (1 / N) * (0.5 ** count)
			break
	
		K /= 2
		count += 1

print(result)

Measured memory_bytes: 3060
package main

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

const MAX = 50

type INT int64

func main() {
	solve()
}

func solve() {
	N, A, x := input()
	dp := dim3forINT(MAX*N+1, N+1, N+1)
	dp[0][0][0] = 1
	x = append([]INT{0}, x...)
	for j := 1; j < N+1; j++ {
		for k := 0; k < N+1; k++ {
			for s := 0; s < MAX*N+1; s++ {
				if INT(s) < x[j] {
					dp[j][k][s] = dp[j-1][k][s]
				} else if x[j] <= INT(s) && k >= 1 && j >= 1 {
					dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][INT(s)-x[j]]
				}
			}
		}
	}
	var re INT
	for i := 1; i < N+1; i++ {
		re += dp[N][i][A*i]
	}
	fmt.Println(re)
}

func input() (N, A int, x []INT) {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	N, _ = strconv.Atoi(strings.Split(sc.Text(), " ")[0])
	A, _ = strconv.Atoi(strings.Split(sc.Text(), " ")[1])

	sc.Scan()
	for _, v := range strings.Split(sc.Text(), " ") {
		t, _ := strconv.Atoi(string(v))
		x = append(x, INT(t))
	}

	return N, A, x
}

func dim2forint(n, m int) [][]int {
	d1 := make([]int, n, n)
	d2 := make([][]int, m)
	for i := 0; i < m; i++ {
		d2[i] = append([]int{}, d1...)
	}
	return d2
}

func dim2forINT(n, m int) [][]INT {
	d1 := make([]INT, n, n)
	d2 := make([][]INT, m)
	for i := 0; i < m; i++ {
		d2[i] = append([]INT{}, d1...)
	}
	return d2
}

func dim3forint(n, m, l int) [][][]int {
	d3 := make([][][]int, l)
	for i := 0; i < l; i++ {
		d1 := make([]int, n, n)
		d2 := make([][]int, m)
		for j := 0; j < m; j++ {
			d2[i] = append([]int{}, d1...)
		}
		d3 = append(d3, d2)
	}
	return d3
}

func dim3forINT(n, m, l int) [][][]INT {
	d3 := make([][][]INT, l)
	for i := 0; i < l; i++ {
		d1 := make([]INT, n, n)
		d2 := make([][]INT, m)
		for j := 0; j < m; j++ {
			d2[j] = append([]INT{}, d1...)
		}
		d3[i] = d2
	}
	return d3
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  string S; int K; cin >> S >> K;
  int N = S.size();
  if (S[0] != S[N - 1]) {
    ll ans = 0;
    rep(i, N) {
      if (S[i] == S[i + 1]) {
        ans++;
        i++;
      }
    }
    cout << ans * K << endl;
  }
  else {
    int first_cnt = 1;
    int findex = -1;
    REP(i, 1, N) {
      if (S[i - 1] != S[i]) {
        findex = i;
        break;
      }
      first_cnt++;
    }
    int last_cnt = 1;
    int lindex = -1;
    for (int i = N - 2; i >= 0; i--) {
      if (S[i] != S[i + 1]) {
        lindex = i;
        break;
      }
      last_cnt++;
    }
    if (findex == -1) {
      cout << (ll)N * K / 2 << endl;
      return 0;
    }
    ll center_ans = 0;
    REP(k, findex, lindex) {
      if (S[k] == S[k + 1]) {
        center_ans++;
        k++;
      }
    }
    cout << center_ans * K + first_cnt / 2 + last_cnt / 2 + (ll)(first_cnt + last_cnt) / 2 * (K - 1) << endl;
  }
}


Measured memory_bytes: 256
l = [int(input()) for _ in range(4)]

cnt = 0
for c500 in range(l[0]+1):
  sum = c500 * 500
  if sum == l[3]:
    cnt += 1
    next
  elif sum > l[3]:
    break
  else:
    for c100 in range(l[1]+1):
      sum = c500 * 500 + c100 * 100
      if sum == l[3]:
        cnt += 1
        next
      elif sum > l[3]:
        break
      else:
        for c50 in range(l[2]+1):
          sum = c500 * 500 + c100 * 100 + c50 * 50
          if sum == l[3]:
            cnt += 1
            next
          elif sum > l[3]:
            break

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    char c;
    cin>>c;
    if (c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
        cout<<"vowel"<<endl;
    } else {
        cout<<"consonant"<<endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;
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);
		while (true) {
			int b = scanner.nextInt();
			int r = scanner.nextInt();
			int g = scanner.nextInt();
			int c = scanner.nextInt();
			int s = scanner.nextInt();
			int t = scanner.nextInt();
			if (t == 0)
				break;
			int br = (b + r) * 15;
			int big = (b * 5 + r * 3) * 16;
			int ans = br + big + g * 7 + c * 2;
			ans = ans + 100 - (t - s)*3;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20784
# AGC024B - Backfront
def main():
    N, *P = map(int, open(0).read().split())
    # dp[i] := length of a monotonically increasing subsequence which i comes at the end
    dp = [0] * (N + 1)
    for i in P:
        dp[i] = dp[i - 1] + 1
    ans = N - max(dp)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25116
N, X, Y = map(int, input().split())

X -= 1
Y -= 1
distances = [0]*N
for i in range(N):
    for j in range(i+1,N):
        d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
        distances[d] += 1

for i in range(1,N):
    print(distances[i])

Measured memory_bytes: 47964
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

#define MAXN (100000)
#define MOD (1000000007)

int main(void)
{
    int m,d,cnt;
    scanf("%d %d",&m, &d);

    cnt = 0;
    for(int i=1;i<=m;i++) for(int j=1;j<=d;j++)
    {
        int d1 = j % 10;
        int d2 = j / 10;
        if(d1 >=2 && d2 >=2 &&(d1*d2==i))
        {
            cnt++;
        }
        
    }
    printf("%d\n",cnt);

    return 0;
}





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


int main()
{
  ll n,i,j;
  cin>>n;
  ll a[n+1][4],dp[n+1][4];

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

for(i=0;i<=3;i++)
{
    a[0][i]=0;
    dp[0][i]=0;
}
 
 for(i=1;i<=n;i++)
 {
     for(j=1;j<=3;j++)
     cin>>a[i][j];
 }
  
 for(j=1;j<=3;j++)
{
    dp[1][j]=a[1][j];
}

for(ll k=2;k<=n;k++)
{
    ll mx=-1,ind,m;
    for(m=1;m<=3;m++)
    {
        if(dp[k-1][m]>mx)
        {
            mx=dp[k-1][m];
            ind=m;
        }
    }
    for(ll h=1;h<=3;h++)
    {
        if(h!=ind)
        dp[k][h]=a[k][h]+mx;
        else
        {
           ll mxx=-1;
            for(ll u=1;u<=3;u++)
            {
                if(u!=ind&&dp[k-1][u]>mxx)
                mxx=dp[k-1][u];
            }
            dp[k][h]=a[k][h]+mxx;
        }
    }
}
  ll c=max(dp[n][1],dp[n][2]);
  c=max(c,dp[n][3]);
  cout<<c;
  
  return 0;
  
}

Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
  unsigned long long a,b,c;

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

  if(a%2 && b%2 && c%2){
    if(a>=b && a>=c){
      printf("%llu\n",b*c);
    }else if(b>=a && b>=c){
      printf("%llu\n",a*c);
    }else{
      printf("%llu\n",b*a);
    }
  }else{
    puts("0");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		String result = "No";
		if(n/100 == n%10) result = "Yes";

		// 出力
		System.out.println(result);
	}
}




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

using namespace std;

long long int d(long long int x,long long int y){
    long long int a,b,c,w,h,ans=1000000000;
    for(int i=1;i<=y;i++){
        h = (y-i)/2;
        w = x/2;
        a = x*i;
        b = x*h;
        c = x*(y-i-h);
        ans = min(ans,max({a,b,c})-min({a,b,c}));
        b = (y-i)*w;
        c = (y-i)*(x-w);
        ans = min(ans,max({a,b,c})-min({a,b,c}));
    }
    return ans;
}

int main(){
    long long int H,W;
    cin >> H >> W;
    cout << min(d(H,W),d(W,H)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll INF = 1e9;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            for(int k = 0; k < 10; k++)
            {
                bool iflag = false;
                bool jflag = false;
                bool kflag = false;
                for(int x = 0; x < n; x++)
                {
                    if(!iflag && s[x] - 48 == i)
                    {
                        iflag = true;
                        continue;
                    }
                    if(!jflag && iflag && s[x] - 48 == j)
                    {
                        jflag = true;
                        continue;
                    }
                    if(jflag && s[x] - 48 == k) kflag = true;
                }
                if(kflag){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
data class Testify(val x: Int, val y: Boolean)
fun main(args: Array<String>) {
    val N = nextInt()
    val A = Array(N) { mutableListOf<Testify>() }
    repeat(N) {
        val a = it
        val n = nextInt()
        repeat(n) {
            val (x, y) = listOfInt()
            A[a].add(Testify(x - 1, y == 1))
        }
    }
    var ans = 0
    var bit = 0
    while (bit < (1 shl N)) {
        val v = BooleanArray(N)
        for (b in 0 until N) {
            v[b] = (bit and (1 shl b)) != 0
        }
        var ok = true
        for (n in 0 until N) {
            if (!v[n]) continue //★
            for (t in A[n]) {
                if (v[t.x] xor t.y) ok = false
            }
        }
        if (ok) ans = Math.max(ans, v.count { it })
        bit += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 44772
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str = br.readLine();
        
        while(str != null){
            String[] line = str.split("\\s");
            int H = Integer.parseInt(line[0]);
            int W = Integer.parseInt(line[1]);
            //System.out.println(H);
            //System.out.println(W);

            if(H ==0 && W == 0){
                break;
            }else{
                String TB = createTB(W);
                String IW = createIW(W);
                
                System.out.println(TB);
                for(int i=0;i<H-2;i++){
                    System.out.println(IW);
                }
                System.out.println(TB);
                System.out.println("");
            }
            str =br.readLine();
        }
        br.close();
    }

    public static String createTB(int W){
        String temp ="";
        for(int i =0;i<W;i++){
            temp +="#";
        }
        return temp;
    }
    
    public static String createIW(int W){
        StringBuilder temp = new StringBuilder();
            temp.append("#");
            for(int i=0;i<W-2;i++){
                temp.append(".");
            }
                temp.append("#");
                return temp.toString();
        }
}

Measured memory_bytes: 25500
s = input()

if s == 'SAT':
    print(1)
elif s == 'FRI':
    print(2)
elif s == 'THU':
    print(3)
elif s == 'WED':
    print(4)
elif s == 'TUE':
    print(5)
elif s == 'MON':
    print(6)
elif s == 'SUN':
    print(7)


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

using namespace std;

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

    ll X;  cin >> X;

    ll cur = 100, Ans = 0;
    while (cur < X) {
        cur += cur / 100;
        Ans++;
    }

    cout << Ans << '\n';
    return 0;
}


Measured memory_bytes: 3644
n=int(input())
s=input()

def l(s):
    return s.count("(")

def r(s):
    return s.count(")")

prev = ""
while prev != s:
    prev = s
    pt = 0
    while True:
        #print(pt)
        if pt>=len(s):
            break
        char = s[pt]
        #print("  ".join([s[:pt],char, s[pt+1:]]))
        if char=="(" and l(s[pt+1:]) >= r(s[pt+1:]):
            s = s+")"
        if char==")" and l(s[:pt]) <= r(s[:pt]):
            s = "("+s
            pt+=1
        pt+=1

print(s)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, ans;

void dfs(string s) {
    ll num = stoll(s);
    if (num > N) return;

    if (s.find('7') != string::npos &&
        s.find('5') != string::npos &&
        s.find('3') != string::npos) ans++;

    dfs(s + '7');
    dfs(s + '5');
    dfs(s + '3');
}

int main() {
    cin >> N;
    dfs("7");
    dfs("5");
    dfs("3");
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string s, t; cin >> s >> t;
    int dp[s.length()+1][t.length()+1];
    memset(dp, 0, sizeof(dp));
    REP(i, s.length())
    {
        REP(j, t.length())
        {
            if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string ans = "";
    int i = s.length(), j = t.length();
    while(i > 0 && j > 0)
    {
        if(dp[i][j] == dp[i-1][j]) --i;
        else if(dp[i][j] == dp[i][j-1]) --j;
        else
        {
            ans = s[i-1]+ans;
            --i, --j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;

bool check(int m){
	vector<string> v;
	set<string> U;
	REP(i,S.size()-m+1){
		v.push_back(S.substr(i,m));
	}
	sort(v.begin(),v.end());
	REP(i,v.size()-1){
		if(v[i]==v[i+1]&&U.find(v[i])==U.end()){
			int p=S.find(v[i]);
			int q=S.rfind(v[i]);
			if(p==string::npos)continue;
			if(q==string::npos)continue;
			p+=m-1;
			if(p<q){
				U.insert(v[i]);
				return true;
			}
		}
	}
	return false;
}

signed main(){
	cin>>N>>S;
	int ok=-1,ng=N-1;
	while(abs(ok-ng)>1){
		int mid=(ok+ng)/2;
		if(check(mid)){
			ok=mid;
		}
		else{
			ng=mid;
		}
	}
	cout<<ok<<endl;
	return 0;
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    
    scanf("%d", &n);
    
    for (int i=n; i<1000; i++) {
        if (i/100==i%10&&i/100==(i-(i/100)*100)/10) {
            printf("%d", i);
            return 0;
        }
    }
    
    return 0;
}


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

void solve(long long A, long long P){
	cout << (A*3+P)/2 << endl;
}

int main(){	
	long long A;
	long long P;
	scanf("%lld",&A);
	scanf("%lld",&P);
	solve(A, P);
	return 0;
}



Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0 for _ in range(n)]
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(n):
    if i>=2:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int n,t[55][26]={};
	string s,ans="",alpha="abcdefghijklmnopqrstuvwxyz";
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		for(int j=0;j<s.length();j++)
		{
			t[i][s[j]-'a']++;
		}
		for(int j=0;j<26;j++)
		{
			if(i)t[i][j]=min(t[i][j],t[i-1][j]);
		}
	}
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<t[n-1][i];j++)
		{
			ans+=alpha[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int K,S;
  cin>>K>>S;
  int count=0;
  for(int i=0;i<=K;i++){
      for(int j=0;j<=K;j++){
          if(0<=S-i-j){
              if(S-i-j<=K)
              count+=1;
          }
      }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long



int main()
{
	while (1)
	{
		int n;
		cin >> n; if (n == 0) return 0;
		vector<pair<int, int>> v;
		for (int i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			v.push_back(make_pair(b, a));
		}
		sort(begin(v), end(v));
		int w = 0;
		for (int i = 0; i < n; i++)
		{
			w += v[i].second;
			if (w > v[i].first)
			{
				cout << "No" << endl;
				goto next;
			}
		}
		cout << "Yes" << endl;
	next:;
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define maxn 105
char s[maxn];
int main(){
	scanf("%s",s);int n=strlen(s),ans=0;
	for(int i=0;s[i];i++)if(s[i]!=s[n-i-1])ans++;
	printf("%d",ans/2);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
#define d(a) cerr<<#a<<":"<<a<<endl
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    int n,m;
    cin>>n>>m;
    int k=(m+n-1)/n;
    while(true){
        if(m%k==0){
            cout<<k<<endl;
            break;
        }
        k--;
    }

    return 0;
}


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

#define rep(i,n) for(i=0;i<n;i++)

int n,A[30];
bool res;

bool solve(int i,int m){
    if(m==0) return true;
    if(i>=n) return false;
    res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(){
    int i;
    scanf("%d",&n);
    rep(i,n) scanf("%d",&A[i]);
    int q,tmp;
    scanf("%d",&q);
    rep(i,q){
        scanf("%d",&tmp);
        if(solve(0,tmp)) printf("yes\n");
        else printf("no\n");
    }
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int prime[1000000];
bool is_prime[1000000+1];

int sieve(int n){
	int p = 0;
	for (int i = 0; i <= n; i++)is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
		for (int i = 2; i <= n; i++){
		if (is_prime[i]){
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = 0;
		}
	}
	return p;
}

int n;

int main(){
	cin >> n;
	sieve(55555);
	rep(i,55555+1){
		if(is_prime[i]){
			if(i%5==1){
				cout<<i;
				n--;
				if(!n){
					cout<<endl;
					break;
				}
				else cout<<" ";
			}
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,a,b;cin>>n>>a>>b;
    int buf=b-a-1;
    if(buf%2==1)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
}

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

int main(void) {
  char buf[1200];
  char c;
  int i;
  int answer[26];
  memset(answer, 0, sizeof(answer));
  while(fgets(buf, sizeof(buf), stdin) != NULL) {
    for(i = 0; buf[i] != '\0'; i++) {
      if(buf[i] >= 'A' && buf[i] <= 'Z')
        buf[i] = buf[i] + 'a' - 'A';
      answer[buf[i] - 'a'] += 1;
    }
  }
  for(c = 'a', i = 0; c <= 'z'; c++, i++)
    printf("%c : %d\n", c, answer[i]);
  return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> nums(n + 1);
	for (int i = 0; i < n; ++i)
		cin >> nums[i];
	long long tot = 1000, cnt = 0;
	bool chk = false;
	for (int i = 0; i + 1 <= n; ++i)
	{
		if (chk)
		{
			tot += cnt * nums[i];
			chk = false;
			cnt = 0;
		}
		if (nums[i] < nums[i + 1])
		{
			cnt = (tot / nums[i]);
			tot -= cnt * nums[i];
			chk = true;
		}
	}
	cout << tot;
}

Measured memory_bytes: 3660
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	p = 10^9+7
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = readline() |> split |> parseMap
	c = zeros(Int,n)
	d = zeros(Int,n)
	for i in 1:n-1
		c[i]=a[i]$a[i+1]
		d[i]=b[i]$b[i+1]
	end
	c[n]=a[1]$a[n]
	d[n]=b[1]$b[n]
	z = 101
	zz = 103
	za = zeros(Int,n+1)
	zb = zeros(Int,n+1)
	za[1]=1
	zb[1]=1
	for i in 2:n+1
		za[i]=za[i-1]*z%p
		zb[i]=zb[i-1]*zz%p
	end
	rhc=c[1]*za[n]%p
	rhcc=c[1]*zb[n]%p
	rhd=d[1]*za[n]%p
	rhdd=d[1]*zb[n]%p
	for i in 2:n
		rhc=(rhc+(c[i]*za[n-i+1])%p)%p
		rhcc=(rhcc+(c[i]*zb[n-i+1])%p)%p
		rhd=(rhd+(d[i]*za[n-i+1])%p)%p
		rhdd=(rhdd+(d[i]*zb[n-i+1])%p)%p
	end
	hash = rhc
	hashh = rhcc
	if hash==rhd&&hashh==rhdd
		println("0"," ",a[1]$b[1])
	end
	for i in 1:n-1
		hash = (mod(hash-za[n]*c[i],p)*z%p+c[i])%p
		hashh = (mod(hashh-zb[n]*c[i],p)*zz%p+c[i])%p
		if hash==rhd&&hashh==rhdd
			println(i," ",a[i%n+1]$b[1])
		end
	end
end

main()

Measured memory_bytes: 170508
#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    char c;
    int alpha[26] = {};
    while (cin >> c) {
        if (isalpha(c)) {
            c = tolower(c);
            alpha[c - 'a']++;
        }
    }

    for (int i = 0; i < 26; i++) {
        cout << (char)(i + 'a') << " : " << alpha[i] << endl;
    }
}


Measured memory_bytes: 3100
N,K = map(int,input().split())
A = list(map(int,input().split()))
ok = 1000000000
ng = 0

while ok-ng>1:
    count = 0
    mid = (ok+ng)//2
    for a in A:
        if a%mid==0:
            count += -1+a//mid
        else:
            count += a//mid

    if count <= K:
        ok = mid
    else:
        ng = mid
print(ok)
    

Measured memory_bytes: 103976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e6 + 10; 
const double pi = acos(-1.0);

inline ll read()
{
    ll kk=0,f=1;
    char cc=getchar();
    while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
    while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
    return kk*f;
}

char s[10];
int main(void)
{
	ll x,ans=0;
	x=read();

	ll tp;
	tp = x/500;
	ans+=tp*1000;
	x-=tp*500;
	tp = x/5;
	ans+=tp*5;

	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};


int main() {
  int N;
  cin >> N;
  vpint red(N), blue(N);
  int rx,ry,bx,by;
  rep(i,N){
    cin >> rx >> ry;
    red[i] = mp(rx,ry);
  }
  rep(i,N){
    cin >> rx >> ry;
    blue[i] = mp(rx,ry);
  }

  vsort(red);
  sort(blue.begin(), blue.end(), [](auto &left, auto&right){
    return left.se < right.se;
  });
  bool redb[N], blueb[N];
  rep(i,N){
    redb[i]=false;
    blueb[i]=false;
  }
  int ans = 0;
  repr(i, N){
    rep(j,N){
      if(blueb[j]) continue;
      // cout << red[i].fi << red[i].se << blue[j].fi << blue[j].se << endl;

      if(red[i].fi < blue[j].fi && red[i].se < blue[j].se){
        blueb[j] = true;
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;


}

















//


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d",&a);
	scanf("%d",&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
import sys
A=[35.5,37.5,40,43,50,55,70,1e6]
B=[71,77,83,89,105,116,148,1e6]
C=["AAA","AA","A","B","C","D","E","NA"]

for s in sys.stdin:
  t1,t2=map(float,s.split(" "))
  c=0
  for e1,e2 in zip(A,B):
    if t1<e1 and t2<e2: break
    c+=1
  print C[c]

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int A;
  int T = 0;
  for (int i = 0; i < N; i++){
    cin >> A;
    if (A < X) T++;
  }
  cout << min(T,M - T);
}

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int n = nxt(), a = nxt(), b = nxt();
	if ((b - a) % 2) {
		puts("Borys");
	} else {
		puts("Alice");
	}

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
g = defaultdict(int)
h,w,m = map(int, input().split())
d = [0]*(3*10**5+1)
e = [0]*(3*10**5+1)
for i in range(m):
  h,w = map(int, input().split())
  g[h*(3*10**5+1)+w]+=1
  d[h]+=1
  e[w]+=1
h1=max(d)
w1=max(e)
ans=h1+w1
h = []
l = []
for i in range(3*10**5+1):
  if d[i] == h1:
    h.append(i)
  if e[i] == w1:
    l.append(i)
for i in h:
  for j in l:
    if g[i*(3*10**5+1)+j]==0:
      print(ans)
      exit()
print(ans-1)

Measured memory_bytes: 166492
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(ll i=0;i<ll(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

ll num(ll A, ll B){
	if(A > B){
		ll tmp = A;
		A = B;
		B = tmp;
	}
	if(A == B || A + 1 == B){
		return 2 * A - 2;
	}
	ll C = sqrt(A * B);
	if(C * C == A * B){
		C--;
	}
	if(C * (C + 1) >= A * B){
		return 2 * C - 2;
	}
	return 2 * C - 1;
}

void solve(){
	int Q;
	cin >> Q;
	int A[105], B[105];
	rep(i, Q){
		cin >> A[i] >> B[i];
	}

	rep(i, Q){
		cout << num(A[i], B[i]) << endl;
	}
}

int main(){
	solve();
	return 0;
}

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

using namespace std;

int a, b;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

int a, b, nim, c, d;
long long ans;
scanf ("%d %d %d %d %d", &a, &b, &nim, &c, &d);
ans = (long long) 2LL * (a / 2) + b + 2LL * (c / 2 + d / 2) + 3LL * (c % 2 == 1 && d % 2 == 1 && a % 2 == 1);
if (a >= 1 && c >= 1 && d >= 1) ans = max (ans, (long long) 2LL * ((a - 1) / 2) + b + 2LL * ((c - 1) / 2 + (d - 1) / 2) + 3LL);
printf ("%lld\n", ans);

return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    public Main(){
        int N,A;
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        for(int i=0;i<N;i++){
            A = scanner.nextInt();
            if((A & 1) == 0){
                if(A%5 != 0 & A%3!=0){
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
  fastio;
	ll n,i,j,w,flag;
	cin>>n>>w;
	ll weights[n],values[n];
	
	for(i = 0;i<n;i++)	cin>>weights[i]>>values[i];
	
	ll dp[2][w+1];
	memset(dp,0,sizeof(dp));
	
	flag = 1;
	
	for(i = 1;i<=n;i++)
	{
		for(j = 0;j<=w;j++)
		{
			dp[flag][j] = dp[flag^1][j];
			
			if(j>=weights[i-1])
			{
				dp[flag][j] = max(dp[flag][j],dp[flag^1][j-weights[i-1]]+values[i-1]);
			}
			
		}
		
		flag ^= 1;		
	}
	
	ll ans = -1;
	for(i = 0;i<=w;i++)
	ans = max(ans,dp[flag^1][i]);
	
	cout<<ans<<endl;
	
	
	
}

Measured memory_bytes: 1792
//求一个图的关节点，即图论中的割点 
#include <iostream>
#include <vector>
#include <set>

using namespace std;

vector<int> *Graph; //图的邻接表
int n; //图的点数
bool *visited; //标记点的访问状态

int *parent; //将图构建成一棵树
int *prenum,*lowest;
int v_time = 0; //当前时间

int dfs(int current,int prev) { //深度优先搜索 
	visited[current] = true;
	prenum[current] = lowest[current] = ++v_time; //记录时间
	parent[current] = prev; //构建树 
	
	vector<int> n_points = Graph[current];
	
	int next;
	for(int i = 0;i<n_points.size();i++) {
		next = n_points[i];
		if (!visited[next]) { //该点还没被访问 
			dfs(next,current);
			lowest[current] = min(lowest[current],lowest[next]);
		} else if (next != prev) {
			//如果在prev之前还有点可以到达current，则更新lowest[current] 为 prenum[next]，更新后，如果next是在prev的前面，则会有lowest[current] < prenum[prev]，则prev将不会是关节点 
			lowest[current] = min(lowest[current],prenum[next]);
		}
	}
} 

void solve() {
	//用set去重，且默认可以从小到到排序 
	set<int> ans;
	
	for (int i=0;i<n;i++) {
		visited[i] = false;
	}
	dfs(0,-1);
	int np = 0;
	for (int i=1;i<n;i++) {
		int p = parent[i];
		if (p == 0) {
			np++;
		} else if (prenum[p] <= lowest[i]) { 	//说明在p之前没有路径到达i，则p是关节点 
			ans.insert(p);
		}
	}
	//最高父节点0有多个分支，则0是关节点 
	if (np > 1) {
		ans.insert(0);
	}
	
	for (set<int>::iterator it = ans.begin();it!=ans.end();it++) {
		cout << *it << endl;
	}
}

int main() {
	int e;
	cin >> n >> e;
	Graph = new vector<int>[n];
	visited = new bool[n];
	parent = new int[n];
	prenum = new int[n];
	lowest = new int[n];
	
	for (int i=0;i<e;i++) {
		int s,t;
		cin >> s >> t;
		Graph[s].push_back(t);
		Graph[t].push_back(s);
	}
	
	solve();
	delete[] Graph;
	delete[] visited;
	delete[] parent;
	delete[] prenum;
	delete[] lowest;
	
	return 0;
}


Measured memory_bytes: 4916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,ans=1e9,a[405],sum[405][405],dp[405][405];
int main(){
	n=read();
	for(int i=0;i<n;i++)
		a[i]=read(),sum[0][i+1]=sum[0][i]+a[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			dp[i][j]=i==j?0:1e18,sum[i+1][j+1]=sum[i][j+1]-a[i];
	for(int j=0;j<n;j++)
		for(int i=0;i<n-j;i++)
			for(int k=0;k<j;k++)
				dp[i][i+j]=min(dp[i][i+j],sum[i][i+j+1]+dp[i][i+k]+dp[i+k+1][i+j]);
	print(dp[0][n-1]);
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
long long int knapsack(int n,long int w,long long int v[][2],long long int dp[][102])
{
	if(n==0 || w==0)
	return 0;
	if(dp[w][n-1]==-1)
	dp[w][n-1]=knapsack(n-1,w,v,dp);
	if(w<v[n-1][0])
	return dp[w][n]=dp[w][n-1];
	if(dp[w-v[n-1][0]][n-1]==-1)
	dp[w-v[n-1][0]][n-1]=knapsack(n-1,w-v[n-1][0],v,dp);
	return dp[w][n]=max(dp[w][n-1],dp[w-v[n-1][0]][n-1]+v[n-1][1]);
}
int main()
{
	int n;
    long int w,i,j;
	cin>>n>>w;
	long long int v[n][2];
	for(i=0;i<n;i++)
	cin>>v[i][0]>>v[i][1];
	long long int dp[w+1][102];
	for(i=0;i<=w;i++)
	for(j=0;j<=102;j++)
	dp[i][j]=-1;
	cout<<knapsack(n,w,v,dp);
	return 0;
}

Measured memory_bytes: 80000
#include<stdio.h>

int main()
{
  int a,b,c,d,e,f;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

d=a+b;
e=b+c;
f=a+c;
  if(d<=e && d<=f)
    printf("%d",d);

  else if(e<=d && e<=f)
   printf("%d",e);
   else
    printf("%d",f);

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void EducationalDP_K()
{
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for (auto& x : a)
		cin >> x;
	vi dp(K + 1);
	for (auto& x : a)
		dp[x] = 1;
	for (int i = 1; i <= K; ++i)
	{
		if (dp[i] > 0)
			continue;

		for (auto& x : a)
		{
			if (i + x > K)
				break;
			dp[i + x] = 1;
		}

	}
	if (dp[K] == 1)
		cout << "First" << endl;
	else
		cout << "Second" << endl;
}

int main()
{
	EducationalDP_K();
	return 0;
}

Measured memory_bytes: 640
import bisect

k = int(input())

def runrun(n):
    str_n = str(n)
    for i in range(len(str_n)-1):
        if abs(int(str_n[i]) - int(str_n[i+1])) > 1:
            return False
    return True

def build_runrun(d):
    r = ["0","1","2","3","4","5","6","7","8","9"]
    ans = []
    for i in r:
        if i == "0":
            continue
        queue = [[i,1,i]]
        while queue != []:
            q = queue.pop(0)
            if q[1] > d:
                continue
            if q[1] == d:
                bisect.insort(ans,int(q[2]))
                continue

            queue.append([q[0],q[1]+1,q[2]+q[0]])

            low = int(q[0])-1
            if low >= 0:
                queue.append([str(low),q[1]+1,q[2]+str(low)])
            high = int(q[0])+1
            if high < 10:
                queue.append([str(high),q[1]+1,q[2]+str(high)])

    return ans

run = []
d = 1
while len(run) < k:
    run.extend(build_runrun(d))
    d+=1

print(run[k-1])


Measured memory_bytes: 21132
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    L = list(map(int, lines.pop(0).split(' ')))
    L.sort()
    print(L[-1] - L[0])

#
# main
#

# 1. use list instead of stdin

# contents = '''\
# 4
# 1 4 6 3\
# '''
# lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int cnt = 0;
			for(int i = a;i <= b; i++) {
				if(c%i==0) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 26416