akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;
    cin >> N;

    vector<int> A(N), B(N), p;
    stack<int> m;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }
    REP(i, N) {
        int d = A[i] - B[i];
        if (d > 0) {
            p.push_back(d);
        } else if (d < 0) {
            m.push(-d);
        }
    }
    sort(p.begin(), p.end(), greater<int>());

    if (m.empty()) {
        cout << 0 << endl;
        return 0;
    }

    int mnum = m.size();
    int ans = 0;
    REP(i, p.size()) {
        if (m.empty()) break;

        int v = p[i];
        while (v > 0) {
            if (m.empty()) break;
            int t = m.top();
            m.pop();
            if (v - t >= 0) {
                v -= t;
            } else {
                t -= v;
                m.push(t);
                v = 0;
            }
        }
        ans++;
    }

    if (m.empty()) {
        cout << ans + mnum << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int H, W, A, B; cin >> H >> W >> A >> B;


    vector<vector<int>> WH;
    repp(i,0,H) {
        vector<int> w(W);
        repp(j,0,W) w[j] = 0;
        WH.push_back(w);
    }
    repp(i,0,B) {
        repp(j,0,A) WH[i][j] = 1;
    }
    repm(i,H-1,B-1) {
        repm(j,W-1,A-1) WH[i][j] = 1;
    }
    repp(i,0,H) {
        repp(j,0,W) cout << WH[i][j];
        cout << endl;
    }
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
map<long long, long long> m;
long long sum = 0;
long long rec(long long n){
    if (n == 1){
        return 1;
    }
    sum = 1 + 2 * rec(n/2);
    return sum;
}
int main(){
    m[1] = 1;
    long long h; cin >> h;
    cout << rec(h) << endl;
}

Measured memory_bytes: 256
"""
https://atcoder.jp/contests/abc150/tasks/abc150_b
"""
import numpy as np


def calc(N: int, S: str) -> int:
    return S.count("ABC")


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    N, = load_input_as_int_array()
    S = input()
    result = calc(N, S)
    print(result)


main()


Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,a,b;cin>>n>>a>>b;
	ll c = a + b;
	ll ans = 0LL;
	ans += (n / c) * a;
	if (n % c > a){
		ans += a;
	}
	else{
		ans += (n % c);
	}
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
 ll n,k;
 cin>>n>>k;
 vector<ll>a(n+5);
 for(ll i=1;i<=n;i++)cin>>a[i];
 for(ll i=k+1;i<=n;i++)
 	if(a[i-k]<a[i])
      cout<<"Yes"<<endl;
   else 
   cout<<"No"<<endl;
}

Measured memory_bytes: 4808
from collections import deque, defaultdict
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
d = [0] * (N + 1)
G = [[] for _ in range(N + 1)]
for a, b in ab:
    d[a] += 1
    d[b] += 1
    G[a].append(b)
    G[b].append(a)
print(max(d))

color = defaultdict(int)
q = deque([[1, 0]])
seen = [0] * (N + 1)
while q:
    v, c = q.popleft()
    seen[v] = 1
    tem = 1
    for u in G[v]:
        if seen[u]:
            continue
        if tem == c:
            tem += 1
        q.append([u, tem])
        i, j = min(v, u), max(v, u)
        color[(i, j)] = tem
        tem += 1

for a, b in ab:
    i, j = min(a, b), max(a, b)
    print(color[(i, j)])


Measured memory_bytes: 53212
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double d = sc.nextDouble();
		int count =0;
		for (int i =0;i<n;i++) {
			double x = sc.nextDouble();
			double y =sc.nextDouble();
			double power = (Math.sqrt(Math.pow(x, 2) +Math.pow(y, 2)));
			if(power<=d) {
				count++;}}
		System.out.println(count);

	}

}


Measured memory_bytes: 64272
def main():
    S = input()
    N = len(S)

    ret = [0] * (N + 1)

    for i, c in enumerate(S, start=1):
        if c == '<':
            ret[i] = max(
                ret[i],
                ret[i - 1] + 1
            )

    for i, c in enumerate(reversed(S), start=1):
        i = N - i
        if c == '>':
            ret[i] = max(
                ret[i],
                ret[i + 1] + 1
            )

    print(sum(ret))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23452
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X; 
  cin >> X;

  int ans = 1;
  FOR(i, 2, 1001){
    int cur = i*i;
    while(cur*i <= X){
      cur *= i;
    }
    if(cur <= X) chmax(ans, cur);
  }

  cout << ans << "\n";

  return 0;
}

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

int main() {
    string o, e;
    cin >> o >> e;
    rep(i, max(o.size(), e.size())) {
        if(i > e.size() - 1)
            cout << o.at(i);
        else
            cout << o.at(i) << e.at(i);
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toInt() }

    print(abc130c(list))
}

fun abc130c(list: List<Int>): Int {
    var highestStreak = 0
    var currentStreak = 0

    for (i in 0 until list.size - 1) {
        when {
            list[i] >= list[i + 1] -> currentStreak += 1
            else -> {
                if (currentStreak > highestStreak) highestStreak = currentStreak
                currentStreak = 0
            }
        }
    }

    if (currentStreak > highestStreak) highestStreak = currentStreak
    return highestStreak
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  int Q; cin >> Q;
  vector<vector<string>> query(Q);
  REP(i, Q) {
    string tmp; cin >> tmp;
    query[i].push_back(tmp);
    if(tmp == "2") {
      string b, c;
      cin >> b >> c;
      query[i].push_back(b);
      query[i].push_back(c);
    }
  }
  bool flag = false;
  deque<string> q;
  REP(i, S.size()) {
    q.push_back(char_to_string(S[i]));
  }
  REP(i, Q) {
    if(query[i][0] == "1") {
      flag = !flag;
    } else if(query[i][0] == "2") {
      if(flag == false) {
        if(query[i][1] == "1") {
          q.push_front(query[i][2]);
        } else if(query[i][1] == "2") {
          q.push_back(query[i][2]);
        }
      } else if(flag == true) {
        if(query[i][1] == "2") {
          q.push_front(query[i][2]);
        } else if(query[i][1] == "1") {
          q.push_back(query[i][2]);
        }
      }
    }
  }
  if(flag == true) reverse(all(q));
  for(auto x : q) {
    cout << x;
  }
  cout << endl;
}

Measured memory_bytes: 49920
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll a,b,k,count=0,i;
    cin >> a >> b >> k;
    i=min(a,b);
    while(true){
        if (a%i==0 && b%i==0)count++;
        i--;
        if (count==k)break;
    }
    cout << i+1 << endl;
    return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
int main(void)
{
    init();
    int A,B,C,D,flag;
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){
             flag=0;
            break;
        }
        A-=D;
        if(A<=0){
            flag=1;
            break;
        }
    }
    if(flag==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3424
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  int N;
  cin >> N;
  vint a(N);
  int maxa=0,imax=0;
  repeat(i,N){
    cin >> a[i];
    if(maxa < abs(a[i])){
      maxa = abs(a[i]);
      imax = i;
    }
  }
  cout << 2*(N-1) << endl;
  repeat(i,N){
    if(i==imax) continue;
    cout << imax+1 << " " << i+1 << endl;
    a[i] += a[imax];
  }
  debugArray(a,N);
  if(a[imax] > 0){
    repeat(i,N-1){
      cout << i+1 << " " << i+2 << endl;
      a[i+1] += a[i];
    }
  }else{
    repeat(i,N-1){
      cout << N-i << " " << N-i-1 << endl;
      a[N-i-2] += a[N-i-1];
    }
  }
  debugArray(a,N);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    REP(i,n-1) cin >> c[i] >> s[i] >> f[i];
    int ans;
    REP(i,n-1) {
        ans = s[i] + c[i];
        FOR(j,i+1,n-1) {
            if(ans>=s[j]) {
                if(ans%f[j]==0) ans += c[j];
                else ans += (f[j] - ans%f[j]) + c[j];
            }
            else {
                ans = s[j]+c[j];
            }
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import math

n,m = map(int,input().split())
roop = min(m//n,math.floor(math.sqrt(m)))
if n == 1:
    print(m)
    exit()
ans = -10**9
for i in range(1,roop+1):
    if m%i == 0:
        if m//i <= m//n:
            ans = max(ans,i,m//i)
        else:
            ans = max(ans,i)
print(ans)


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

int main() {
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
char ara[30][30];
int visit[30][30],h,w;
int dx[]= {1,-1,0,0};
int dy[]= {0,0,1,-1};
queue<pi>q;
int ans;

void bfs()
{
    int x,y,a,b,i;
    while(!q.empty())
    {
        x=q.front().first;
        y=q.front().second;
        q.pop();
        for(i=0; i<4; i++)
        {
            a=dx[i]+x,b=dy[i]+y;
            if(a<0 || b<0 || a==h || b==w || visit[a][b]!=-1 || ara[a][b]=='#')continue;
            q.push({a,b});
            visit[a][b]=visit[x][y]+1;
            ans=max(ans,visit[a][b]);
        }
    }
}

int main()
{
    int i,j;
    scanf("%d %d",&h,&w);
    for(i=0; i<h; i++)scanf("%s",ara[i]);
    ans=0;
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
        {
            if(ara[i][j]=='.')
            {
                for(int k=0; k<h; k++)
                    for(int l=0; l<w; l++)visit[k][l]=-1;
                visit[i][j]=0;
                q.push({i,j});
                bfs();
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
  int i, j, N;
  int num, count = 0;
  scanf("%d", &N);

  for (i = 0; i < N; i++) {

    scanf("%d", &num);

    for (j = 2; j <= sqrt(num); j++) {
      if (num % j == 0) {
	count++;
	break;
      }
    }
  }

  printf("%d\n", N - count);

  return 0;
}

Measured memory_bytes: 596
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var K = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var A = input[0];
        var B = input[1];

        if (A % K == 0 || A + (K - A % K) <= B)
        {
            Console.WriteLine("OK");
        }
        else
        {
            Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 28172
/*
USER: caoash3
LANG: JAVA
TASK: 
*/

import java.io.*;
import java.util.*;

public class Main {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

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

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			int N = br.nextInt();
			int K = br.nextInt();
			int[] in = new int[N];
			
			for(int i = 0; i < N; i++) {
				in[i] = br.nextInt();
			}
			
			int[] dp = new int[N];
			
			dp[0] = 0;
			
			for(int i = 1; i < N; i++) {
				int min = Integer.MAX_VALUE;
				for(int j = 1; j <= K; j++) {
					if(i-j >= 0) {
						min = Math.min(min, dp[i-j] + dist(i, i-j, in));
					}
				}
				
				dp[i] = min;
			}
			
			pw.println(dp[N-1]);
			
			pw.close();
		}
		
		public static int dist(int i, int j, int[] in) {
			return Math.abs(in[i] - in[j]);
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



Measured memory_bytes: 33388
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

string deflate_run_length_code(vector<int> const & p, bool initial) {
    string s;
    for (int p_i : p) {
        s += string(p_i, '\0' + initial);
        initial ^= 1;
    }
    return s;
}
int count_swaps(vector<int> b, string const & a) {
    assert (b.size() == a.size());
    if (count(ALL(b), 1) != count(ALL(a), 1)) return INT_MAX;
    int n = a.size();
    int result = 0;
    REP (i, n) if (b[i] != a[i]) {
        REP3 (j, i + 1, n) if (b[i] != b[j]) {
            swap(b[i], b[j]);
            result += j - i;
            break;
        }
    }
    return result;
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<int> b(n); REP (i, n) scanf("%d", &b[i]);
    vector<int> p(n); REP (i, m) scanf("%d", &p[i]);
    int result = min(
        count_swaps(b, deflate_run_length_code(p, 0)),
        count_swaps(b, deflate_run_length_code(p, 1)));
    printf("%d\n", result);
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int64_t> a(n),b(n+1,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  int64_t sum=0;
  for(int i=1;i<=n;i++){
    sum+=b[i]*(b[i]-1)/2;
  }
  int64_t ans;
  for(int i=0;i<n;i++){
    ans=sum-b[a[i]]+1;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 5760
#include <iostream>
#include <set>
using namespace std;
int main()
{
 int i,c,n;
 c=1;
 cin >> n;
 set<int> s;
 int a[n];
 for(i=0;i<n;i++)
 {
  cin >> a[i];
 }
 s.insert(a[0]);
 for(i=1;i<n;i++)
 {
  if(a[i]<=*s.begin())
  c++;
  s.insert(a[i]);
 }
 cout << c;
 return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main (void)
{
	int a[60000], cpy[60000];
	int i, j, n, max, min;
	
	for (i = 1; i <= 60000; i++)a[i] = 1;
	
	a[1] = 0;
	for (i = 2; i * i <= 60000; i++){
		if (a[i] == 1){
			for (j = i * i; j <= 60000; j += i)a[j] = 0;
		}
	}
	
	while (scanf("%d", &n) != EOF){
		for (i = n - 1; i >= 0; i--){
			if (a[i] == 1){
				max = i;
				break;
			}
		}
		for (i = n + 1; i <= 60000; i++){
			if (a[i] == 1){
				min = i;
				break;
			}
		}
		
		printf("%d %d\n", max, min);
		
	}
	
	return (0);
}

Measured memory_bytes: 828
#include                            <iostream>
#include                            <list>
#include                            <stdio.h>
#include                            <math.h>
#include                            <string.h>
#include                            <time.h>
#include                            <stdlib.h>
#include                            <string>
#include                            <bitset>
#include                            <vector>
#include                            <set>
#include                            <map>
#include                            <queue>
#include                            <algorithm>
#include                            <sstream>
#include                            <stack>
#include                            <iomanip>
#include                            <numeric>
#include                            <unordered_map>
using namespace                     std;
#define                             int long long int

signed main()
{

    int n, ans = 0; cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 1; i < n; i++)
    {
        if (arr[i] < arr[i - 1])
        {
            ans += (arr[i - 1] - arr[i]);
            arr[i] = arr[i - 1];
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 4424
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner in =new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        long sum = 0;
        sum=1;
        sum*=N;
        sum*=(N-1);
        sum/=2;
        int sumM =1;
        sumM*=(M-1);
        sumM*=M;
        sumM/=2;
        System.out.println(sum+sumM);
    }
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N;
  vector<long> as;
  scanf("%ld", &N);
  for (int i = 0; i < N; i++) {
    long a;
    scanf("%ld", &a);
    as.push_back(a);
  }

  // create reverse mapping
  vector<long> bs(as);
  sort(bs.begin(), bs.end());

  // calculate the number of inversions
  long ans = 0;
  for (int i = 0; i < N; i++) {
    const long a = as[i], k = lower_bound(bs.begin(), bs.end(), a) - bs.begin();
    if ((i % 2 == 0 && k % 2 == 1) || (i % 2 == 1 && k % 2 == 0)) {
      ans++;
    }
  }
  ans /= 2;
  printf("%ld\n", ans);

  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s,s2;
  rep(i,n){
    cin >> s2;
    s += s2;
  }
  rep(i,1000){
    if(s.find(to_string(i)) == string::npos){
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3252
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

const int N = 100005;

int n,ans,c;
string s;

int main(){
	cin>>s;n=s.length();
	for(int i=0;i<n;i++){
		if(c>0) c--,ans+=(s[i]=='g');
		else c++,ans-=(s[i]=='p');
	}cout<<ans<<endl;
	return 0;
}

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

#define SENTINEL 1000000000000000000

void merge(long long A[], long long B[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R, *Lb, *Rb;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  Lb = (long long*)malloc(sizeof(long long) *(n1 + 1));
  Rb = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
    Lb[i] = B[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
    Rb[j] = B[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  Lb[n1] = SENTINEL;
  Rb[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      B[k] = Lb[i];
      i++;
    }
    else{
      A[k] = R[j];
      B[k] = Rb[j];
      j++;
    }
  }
  free(L);
  free(R);
  free(Lb);
  free(Rb);
}

void mergeSort(long long A[], long long B[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A,B, left, mid);
    mergeSort(A,B, mid, right);
    merge(A,B, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long a[N], b[N];

    for(int i = 0; i < N; i++){
        scanf("%lld%lld", &a[i], &b[i]);
    }

    long long c[N], d[N];

    for(int i = 0; i < N; i++){
        scanf("%lld%lld", &c[i], &d[i]);
    }

    mergeSort(b, a, 0, N);
    mergeSort(c, d, 0, N);

    int B = 0;
    int ans = 0;
    int f[N];

    for(int i = 0; i < N; i++){
        f[i] = 0;
    }

    while(1){
        if(B >= N){
            break;
        }
        for(int i = N-1; i >= 0; i--){
            if(a[i] < c[B] && b[i] < d[B] && f[i] == 0){
                ans++;
                f[i] = 1;
                break;
            }
        }
        B++;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {

	int R;

	cin >> R;

	if(R < 1200) {
		cout << "ABC" << endl;
		return 0;
	}

	if(R < 2800) {
		cout << "ARC" << endl;
		return 0;
	}

	cout << "AGC" << endl;

	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())

ans=10**100
if y-x>=0:
    ans=min(ans,y-x)
if 1+y+x>0:
    ans=min(ans,1+y+x)
if -y-x+1>0:
    ans=min(ans,-y-x+1)
if -y+x>=0:
    ans=min(ans,-y+x+2)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main()
{
    int l;
    cin >> l;
    long double res;
    res = (l / 3.0) * (l / 3.0) * (l / 3.0);
    cout << fixed << setprecision(12) << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

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

    int n, m;
    vi cub(255);
    char c;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> c;
            cub[c]++;
        }
    }

    int p1, p2, p4;

    if (n % 2 && m % 2) {
        p1 = 1;
        p2 = n / 2 + m / 2;
        p4 = (n-1)*(m-1)/4;
    }else if (n % 2 || m % 2) {
        p1 = 0;
        p2 = n % 2 ? m / 2 : n / 2;
        p4 = n % 2 ? (n-1)*m/4 : (m-1)*n/4;
    } else {
        p1 = p2 = 0;
        p4 = n*m/4;
    }

    bool res = true;
    for (int i = 'a'; i <= 'z'; i++) {
        if (cub[i] % 2) {
            if (p1) {
                p1--;
                cub[i]--;
            } else {
                res = false;
            }
        }
    }

    int ant;

    ant = 0;
    while (p4) {
        for (int i = 'a'; i <= 'z'; i++) {
            if (cub[i] > 3) {
                cub[i] -= 4;
                p4--;
            }
        }

        if (ant == p4)
            break;
        ant = p4;
    }
    res &= p4 == 0;

    ant = 0;
    while (p2) {
        for (int i = 'a'; i <= 'z'; i++) {
            if (cub[i] % 4 && cub[i] > 1) {
                cub[i] -= 2;
                p2--;
            }
        }

        if (p2 == ant)
            break;
        ant = p2;
    }

    ant = 0;
    while (p2) {
        for (int i = 'a'; i <= 'z'; i++) {
            if (cub[i] > 1) {
                cub[i] -= 2;
                p2--;
            }
        }

        if (p2 == ant)
            break;
        ant = p2;
    }

    res &= p2 == 0;

    if (res)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}  

Measured memory_bytes: 256
#include<stdio.h>
main(void){
  int N,i,j,a[101],k,key;

 
  scanf("%d",&N);
  for(k=0;k<N;k++){
    scanf("%d",&a[k]);
  }
  
  for(i=0;i<=N-1;i++){
    if(i==N-1){
      printf("%d",a[i]);
    }
    else{
    printf("%d ",a[i]);
    }
  }
  printf("\n");
  
  for(i=1;i<=N-1;i++){
    key = a[i];
    j=i-1;
    while(j >= 0 && a[j]>key){
      a[j+1]=a[j];
      j--;
      a[j+1]=key;

      
    }
     for(k=0;k<N;k++){
       if(k==N-1){
	 printf("%d",a[k]);
       }
       else{
	printf("%d ",a[k]);
      }
     }
      printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
from itertools import groupby, accumulate


def solve(t):
    if t[0] == '0':
        preceding_zeros = len(t)
        t = t.lstrip('0')
        preceding_zeros -= len(t)
    else:
        preceding_zeros = 0

    if len(t) == 0:
        return 0

    grp = [(c, len(list(itr))) for c, itr in groupby(t)]
    even_ones = 0
    zeros_splitting_odd_ones = [preceding_zeros]
    for c, cnt in grp:
        if c == '1':
            if cnt % 2 == 0:
                even_ones += cnt
            else:
                even_ones += cnt - 1
                zeros_splitting_odd_ones.append(0)
        else:
            zeros_splitting_odd_ones[-1] += cnt

    # print(even_ones)
    # print(zeros_splitting_odd_ones)

    # 初期状態で加算されるか
    ad = int(zeros_splitting_odd_ones[0] % 2 == 0)
    is_added_init = [ad]
    for cnt in zeros_splitting_odd_ones[1:]:
        ad ^= (cnt % 2) ^ 1
        is_added_init.append(ad)
    is_added_init.pop()
    acc_added_init = list(accumulate(reversed(is_added_init)))  # 自分より右で、初期状態で足される1の数
    acc_added_init.reverse()

    odd_ones = len(is_added_init)
    ans = 0

    if odd_ones > 0:

        # 先頭の0を全て除くまでのスコア
        zso = zeros_splitting_odd_ones[0]
        zso1 = zso // 2
        zso0 = zso - zso1
        ans += acc_added_init[0] * zso0
        ans += (odd_ones - acc_added_init[0]) * zso1
        # print(ans)

        # 1に挟まれた0を1箇所1つずつ残して全て除くまでのスコア
        ad = int(zeros_splitting_odd_ones[0] % 2 == 0)
        for i in range(1, odd_ones):
            zso = zeros_splitting_odd_ones[i] - 1
            zso1 = zso // 2
            zso0 = zso - zso1
            fixed_ones = i
            right_ones = odd_ones - fixed_ones
            ans += fixed_ones * zso
            if ad:
                # 除外中の0区間の次の"1"が初期状態で足されるなら、区間を操作する直前にも足される
                ans += acc_added_init[i] * zso0
                ans += (right_ones - acc_added_init[i]) * zso1
            else:
                # 除外中の0区間の次の"1"が初期状態で足されないなら、区間を操作する直前には足される
                ans += (right_ones - acc_added_init[i]) * zso0
                ans += acc_added_init[i] * zso1
            ad ^= zso % 2
        # print(ans)

        # 末尾の0を全て除くまでのスコア
        ans += zeros_splitting_odd_ones[-1] * odd_ones
        # print(ans)

    # 1に挟まれた0を右から除いていくまでのスコア
    for i in range(1, odd_ones):
        left_ones = odd_ones - i
        right_ones = i
        ans += left_ones + (right_ones + 1) // 2
    # print(ans)

    # 1だけの列を1つずつ除いていくスコア
    all_ones = odd_ones + even_ones
    ao1 = all_ones // 2
    ao0 = all_ones - ao1
    ans += (ao0 * (ao0 + 1) + ao1 * (ao1 + 1)) // 2
    # print(ans)

    # 0を除いている間の、偶数個の1によるスコア
    all_zeros = len(t) - all_ones + preceding_zeros
    ans += all_zeros * (even_ones // 2)

    return ans


t = input()
print(solve(t))


Measured memory_bytes: 28820
#include<iostream>
using namespace std;
int t[2000],u[2000];
int a[2000000],b[2000000];
int N,M;
int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    for(int i=0;i<2000000;i++)a[i]=b[i]=0;
    for(int i=1;i<=N;i++)cin>>t[i],t[i]+=t[i-1];
    for(int i=1;i<=M;i++)cin>>u[i],u[i]+=u[i-1];
    for(int i=1;i<=N;i++)
      for(int j=i;j<=N;j++)
	a[t[j]-t[i-1]]++;
    for(int i=1;i<=M;i++)
      for(int j=i;j<=M;j++)
	b[u[j]-u[i-1]]++;
    int ans=0;
    for(int i=0;i<2000000;i++)ans+=a[i]*b[i];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 16796
import java.util.*;
import java.io.*;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {
    public static void main(String[] args) throws Exception {

        FastScanner fc = new FastScanner();
        int N = fc.nextInt();
        int i = fc.nextInt();
        //入力値チェック
        if(i < 0 || i > N || N < 0 || N >100){
            throw new IllegalArgumentException("入力値が不正です");
        }
        //Nが偶数の場合
        if(N % 2 == 0){
            if(i==1){
                System.out.println(N);
            }else{
                System.out.println(N-i+1);
            }
        //Nが奇数の場合
        }else{
            if(i==1){
                System.out.println(N);
            }else if(i == (N / 2 + 1)){
                System.out.println(N / 2 + 1);
            }else{
                System.out.println(N-i+1);
            }
        }
         
    }
}



Measured memory_bytes: 23124
n,y=map(int,input().split())
amari=y-1000*n

if amari < 0:
    print(-1,-1,-1)
    exit()

for k in range(0,n+1):
    if amari-4000*k >= 0 and (amari-4000*k)%5000 == 0:
        x=(amari-4000*k)//5000
        if k-x >= 0:
            y=k-x
            print(x,y,n-k)
            break
else:
    print(-1,-1,-1)

Measured memory_bytes: 64412
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}
 
void solve(){
	ll n;
	cin >> n;
	if (n & 1) {
		cout << 0;
		return;
	}
	ll ans = 0;
	n /= 2;
	while(n) {
		n /= 5;
		ans += n;
	}
	cout << ans;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

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

using namespace std;

int main(void) {
  long double a, b, c; cin >> a >> b >> c;
  long double e = 1.0E-14;
  if (sqrt(a) + sqrt(b) + e < sqrt(c)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
int a, b, c = 0, d = 0;
string s;
void f() {
	if (a == c && d == b) {
		cout << s << endl;
		return;
	}
	if (c > a)return;
	if (d > b)return;
	if (c == 5 && d != 4)return;
	if (d == 5 && c != 4)return;
	if (c >= 6 || d >= 6)return;
	s += 'A'; c++;
	f();
	s.pop_back(); c--;
	s += 'B'; d++;
	f();
	s.pop_back(); d--;
	return;
}
signed main() {
	cin >> a >> b;
	f();
	return 0;
}


Measured memory_bytes: 3176
fun main(args: Array<String>) {
    val S = readInputLine().toCharArray()
    val K = readInputLine().toLong()
    val S_ = S.copyOf()

    var allSame = true

    for (i in 1 until S.size) {
        if (S[i] != S[i - 1]) {
            allSame = false
            break
        }
    }
    if (allSame) {
        println(S.size * K / 2L)
        return
    }

    var concurrentCnt = 0L

    for (i in 1 until S.size) {
        if (S_[i] == S_[i - 1]) {
            concurrentCnt++
            S_[i] = '*'
        }
    }

    if (S[S.size - 1] == S[0]) {
        var header = 1L
        for (i in 1 until S.size) {
            if (S[i] == S[i - 1]) {
                header++
            } else {
                break
            }
        }
        var footer = 1L
        for (i in S.size - 2 downTo 0) {
            if (S[i] == S[i + 1]) {
                footer++
            } else {
                break
            }
        }

        println(concurrentCnt * K - (K - 1) * (header / 2L + footer / 2L - (header + footer) / 2L))
    } else {
        println(concurrentCnt * K)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31864
/**
 *    author:  tourist
 *    created: 20.11.2019 15:41:26       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int x = 1;
  while (2 * x <= n) {
    x <<= 1;
  }
  cout << x << '\n';
  return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

result = 0
# a[0] が x 以下でないと、a[1] を空にしても条件を満たせない
t = a[0] - x
if t > 0:
    result += t
    a[0] -= t
for i in range(1, N):
    # 箱に入っているキャンディの数が食べれる上限
    t = min(a[i - 1] + a[i] - x, a[i])
    if t > 0:
        result += t
        a[i] -= t
print(result)


Measured memory_bytes: 14068
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0;i < n;i++){
            h[i] = sc.nextInt();
        }
        
        int cnt = 1;
        int max = h[0];
        for(int i = 1;i < n;i++){
            if (max <= h[i]) {
                cnt++;
                max = h[i];
            }
        }
        System.out.println(cnt);
    }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	vi a(3);
	rep(i, 3) cin >> a[i];

	bool ans = false;
	rep(i, 3) rep(j ,3) rep(k, 3)
	{
		if(a[i] + a[j] == a[k]) ans = true;
	}

	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String[] strings = new String[]{
            "dream",
            "dreamer",
            "erase",
            "eraser"
        };

        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        int allLength = S.length();
        int strLength = 0;
        while (true) {
            for (int i = 0; i < strings.length; i++) {
                int restLength = allLength - strings[i].length();
                if (restLength < 0) {
                    continue;
                }
                if ((S.substring(restLength, allLength)).equals(strings[i])) {
                    strLength = strings[i].length();
                    break;
                }
            }
            if (strLength == 0) {
                System.out.println("NO");
                System.exit(0);
            }
            allLength -= strLength;
            if (allLength == 0) {
                System.out.println("YES");
                System.exit(0);
            }
            strLength = 0;
        }
    }
}


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

int main(){
    int n,k;cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());

    int ans=1e9;

    for(int i=0;i<n-k+1;i++){
        ans = min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
unittest
{
	assert( [ "2 2 2" ].parse.expand.solve == 8 );
	assert( [ "4 5 4" ].parse.expand.solve == 87210 );
	assert( [ "100 100 5000" ].parse.expand.solve == 817260251 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmk = input.front.split.to!( long[] );
	return tuple( nmk[ 0 ], nmk[ 1 ], nmk[ 2 ] );
}

auto solve( long n, long m, long k )
{
	// 縦と横のコストを分けて計算
	return solve2( n, m, k ).addMod( solve2( m, n, k ) );
}

auto solve2( long n, long m, long k )
{
	// 駒2つを固定したときの残りの駒の配置のパターン数を計算
	auto ca = n.mulMod( m ).subMod( 2 ).combinationMod( k.subMod( 2 ) );
	
	// 駒2つの距離がdのときの配置のコストを集計
	auto t = 0L;
	for( auto d = 1L; d < n; d++ )
	{
		// 駒2つの配置のパターン数を計算
		auto cb = n.subMod( d ).mulMod( m ).mulMod( m );
		
		// 駒2つの距離 * 駒2つの配置のパターン数 * 駒2つを固定したときの残りの駒の配置のパターン数 = コスト
		t = t.addMod( d.mulMod( cb ).mulMod( ca ) );
	}
	return t;
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 引き算
auto subMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + MOD - y ) % MOD;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}

// 階乗
auto factorialMod( long MOD = 10L ^^ 9 + 7 )( long x )
{
	static memo = [ 1L ];
	if( memo.length <= x )
	{
		auto i = memo.length;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i % MOD;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combinationMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x < y ) ? 0L : x.factorialMod!MOD.divMod!MOD( y.factorialMod!MOD * ( x - y ).factorialMod!MOD % MOD );
}


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


def solve(S: str):
    prev = ''
    for s in S:
        if s == prev:
            print('Bad')
            break
        else:
            prev = s
    else:
        print('Good')
        
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
void find_ans(long number,int three,int five,int seven){
    if(number<=n){
        if(three&&five&&seven)cnt++;
        find_ans(number*10+3,1,five,seven);
        find_ans(number*10+5,three,1,seven);
        find_ans(number*10+7,three,five,1);
    }
}
int main(){
    cin>>n;
    find_ans(0,0,0,0);
    cout<<cnt<<endl;
}


Measured memory_bytes: 256