akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int oo = 1e9;

int f(int x) {
	int ans = 0;
	while (x > 0) ans += x % 10, x /= 10;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	int ans = oo;
	for (int i = 1; i < n; i++)
		ans = min(ans, f(i) + f(n - i));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;

	int ans = 0;
	for(int i=0; i<N-2; i++){
		if(S.substr(i, 3) == "ABC"){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if (a == b && b != c) ans = "Yes";
  if (a == c && a != b) ans = "Yes";
  if (b == c && a != b) ans = "Yes";
  cout << ans << endl;
}


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

public class Main {
    private static String solve(int n, int k, int[] arr) {
        // dp[i] = true if player who play wins;
        // e.g. we have arr = [2,3] k = 4
        // dp[2] = true because we have element 2 in a;
        // dp[3] = true because we have element 3 in a
        // for dp[4] we can choose either 2 or 3
        // if we choose 2 than other play choose 2 in next move and we loose
        // for that if we take 2 than look at dp[4-2] = dp[2] == true(for second player
        // so we loosing)
        // if we choose 3 than dp[4-3] = dp[1] == false(for second player and we win
        // because 2nd player can't make move)
        // dp[i-arr[j]] == false than dp[i] = true and than we break because we are
        // playing
        // optimally. we are looking for false value for dp[i-arr[j]] to win.
        Boolean[] dp = new Boolean[k + 1];
        Arrays.fill(dp, false);
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j < n; j++) {
                if (i - arr[j] < 0) {
                    dp[i] = false;
                    break;
                }

                if (dp[i - arr[j]] == false) {
                    dp[i] = true;
                    break;
                }
            }
        }

        if (dp[k] == true) {
            return "First";
        }
        return "Second";
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        System.out.println(solve(n, k, arr));
        sc.close();
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>

using namespace std;

int H[200000];

int main(){
  int N,K;
  long long int sum = 0;
  cin >> N >> K;
  for(int i = 0;i < N;i++){
    cin >> H[i];
  }
  sort(H,H+N);
  for(int i = 0;i <N-K;i++){
    sum += (long long int)H[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
int cnt;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		cnt+=b[i]-a[i]+1;
	}
	cout<<cnt<<endl;
    return 0;
}

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

int main(){
    int hindo[100] = {0};
    int max = 0;
    int n;

    while(cin >> n){
        hindo[n-1]++;
    }

    for(int i=0; i<100; i++){
        if(max < hindo[i]){
            max = hindo[i];
        }
    }

    for(int i=0; i<100; i++){
        if(max == hindo[i]){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	pair<int, string> deta[10];//int mod string ?????????
	deta[1] = mp(5, ".,!? ");
	deta[2] = mp(3, "abc");
	deta[3] = mp(3, "def");
	deta[4] = mp(3, "ghi");
	deta[5] = mp(3, "jkl");
	deta[6] = mp(3, "mno");
	deta[7] = mp(4, "pqrs");
	deta[8] = mp(3, "tuv");
	deta[9] = mp(4, "wxyz");
	//deta[0] = mp(0, "");

	int n; cin >> n;
	int tmp;
	rep(i, n){
		string tmp;
		cin >> tmp;
		int size = tmp.size();
		int cnt = 0;
		rep(j, size){
			//printf("j %d\n", j);
			if(tmp[j] == '0') continue;//?????????????????????????????????
	
			if(tmp[j] == tmp[j + 1]){
				cnt++;
				//printf("cnt++%d\n", cnt);
				continue;
			}
			else{
				int num = tmp[j] - '0';
				//printf("num%d\n", num);
				string moziretu = deta[num].se;
				//cout << moziretu <<endl;
				printf("%c", moziretu[cnt % deta[num].fi]);
				cnt = 0;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3032
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;  using i64 = int64_t;  using str = string;
using u32 = uint32_t; using u64 = uint64_t; using usize = size_t;
using f64 = double_t; template <typename T> using vec = vector<T>;
#define times(n, i) for (i64 i = 0; i < (n); ++i)
#define range(n, m, i) for (i64 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i64 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i64 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 h, w, a, b;
i64 dp[100002];

template <class T> T powmod(T b, T e, T m) {
    T x = 1;
    while (e>0) { if (e&1) { x = (x*b)%m; } b = (b*b)%m; e >>= 1; }
    return x;
}

vec<i64> fact;
void initfact(i32 n, i32 m) {
    fact = vec<i64>(n+1); fact[0] = 0; fact[1] = 1;
    upto(2, n, i) { fact[i] = (fact[i-1] * i) % m; }
}

vec<i64> factinv;
void initfactinv(i32 n, i32 m) {
    i64 e = 1000000005;
    factinv = vec<i64>(n+1); factinv[0] = 0; factinv[1] = 1;
    upto(2, n, i) { factinv[i] = powmod(fact[i], e, MOD); }
}

i64 cnt(i32 y1, i32 x1, i32 y2, i32 x2) {
    i32 y = y2-y1;
    i32 x = x2-x1;
    if (x == 0 || y == 0)
        return 1;
    return fact[y+x] * factinv[y] % MOD * factinv[x] % MOD;
}

i32 main()
{
    cin >> h >> w >> a >> b;
    initfact(h + w, (i32)MOD);
    initfactinv(h + w, (i32)MOD);

    i64 ans = 0;
    upto(b, w-1, x) {
        i64 v = cnt(0, 0, h-a-1, x);
        v = (v * cnt(h-a, x, h-1, w-1)) % MOD;
        ans = (ans + v) % MOD;
    }

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

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int h, a, cnt = 0;
  cin >> h >> a;
  while (0 < h) h -= a, cnt++;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int tab[100001];
int main()
{
    int n;
    cin >> n;
    int a;
    int m = 0;
    for(int i = 1 ; i <= n; i++){
        cin >> a;
        tab[a-1]++;
        tab[a]++;
        tab[a+1]++;
    }
    for(int i = 1 ; i <= 100000 ; i++ ){
        if(tab[i]>m)m=tab[i];
    }
    cout << m;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	VL a(N),a_, b(N), b_;
	REP(i, N) cin >> a[i];
	REP(i, N) cin >> b[i];
	bool flag = true;
	REP(i, N) {
		if (a[i] != b[i]) {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
		
		return 0;	
	}

	ll n = accumulate(b.begin(), b.end(), 0LL) - accumulate(a.begin(), a.end(), 0LL);
	if (n <= 0) {
		cout << "No" << endl;
		return 0;
	}
	ll counta = 0,countb = 0;
	REP(i, N) {
		if (a[i] > b[i]) countb += a[i] - b[i];
		if (b[i] > a[i]) {
			if ((b[i] - a[i]) % 2LL == 0LL) counta += (b[i] - a[i])/2LL;
			if ((b[i] - a[i]) % 2LL == 1LL) {
				counta += (b[i] - a[i])/2LL + 1;
				countb += 1;
			}
		}
	}
	
	if(n < max(counta,countb)){
		cout << "No" << endl;
		return 0;
	}
		
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		sc.close();

		long ans = Math.min(n, m / 2);
		m -= ans * 2;
		ans += m / 4;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
def gcd(a,b)
  a,b = b,a%b while b > 0
  a
end

N, X = gets.split.map(&:to_i)

city_dist = gets.split.map(&:to_i).map{|i| (X-i).abs}

(city_dist.size-1).times do |i|
  # puts "city_dist:#{city_dist}"
  city_dist[i+1] = gcd(city_dist[i], city_dist[i+1])
end

puts city_dist[-1]

Measured memory_bytes: 9220
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int p[55];
int n;
bool check(){
    for(int i=0; i<n-1; i++){
        if(p[i]>p[i+1]) return false;
    }
    return true;
}
int main()
{

    cin>>n;
    for(int i=0; i<n; i++) cin>>p[i];
    if(check()){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            swap(p[i], p[j]);
            if(check()){
                cout<<"YES"<<endl;
                return 0;
            }
            swap(p[i], p[j]);
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <limits.h>
#include <stdio.h>

int matrix[100][2];
int memoization[100][100];

int minSum(int i, int j) {
  if (i == j) {
    return 0;
  }
  if (memoization[i][j]) {
    return memoization[i][j];
  }

  int k;
  int min = INT_MAX;
  for (k = i; k < j; k++) {
    int holder = matrix[i][0] * matrix[k][1] * matrix[j][1] + minSum(i, k) +
                 minSum(k + 1, j);
    if (holder < min) {
      min = holder;
    }
  }
  memoization[i][j] = min;
  return min;
}

int main() {
  int n;
  scanf(" %d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf(" %d %d", &matrix[i][0], &matrix[i][1]);
  }
  printf("%d\n", minSum(0, n - 1));
  return 0;
}


Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//C

//B
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll result = 0;

	rep(i, len / 2) {
		if (s[i] != s[len - 1 - i]) {
			result++;
		}
	}

	printf("%lld\n", result);
}


//A
/*
int main() {
	ll a;
	scanf("%lld", &a);
	ll b;
	scanf("%lld", &b);
	ll c;
	scanf("%lld", &c);

	if (a + b + c >= 22) {
		printf("bust\n");
	}
	else {
		printf("win \n");
	}
}
*/

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

int main() {
  long long n, k;
  cin >> n >> k;
  
  if (n >= k) { 
    long long amari;
    amari = n % k;

    if (abs(amari - k) < amari)
      cout << abs(amari - k) << endl;
    else 
      cout << amari << endl;
  } else {
    if (k - n < n)
      cout << k - n << endl;
    else
      cout << n << endl;
  }
}

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

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}


//naoto


Measured memory_bytes: 2732
#include<iostream>
#include<cctype>
#include<cstdio>

using namespace std;

char s[2345678];
char *p;

int term();

int expr(){
  int rv=term();
  for(;;){
    bool f=false;
    char *r=p;
    while(*r==' '){
      r++;
    }
    if(r[0]=='>'&&r[1]=='>'){
      r+=2;
      while(*r==' '){
	r++;
      }
      if(*r=='S'||isdigit(*r)){
	f=true;
	p=r;
	int sw=term();
	if(sw>32){
	  rv=0;
	}else{
	  rv>>=sw;
	}
      }
    }
    if(!f)break;
  }
  return rv;
}

int term(){
  if(isdigit(*p)){
    int d,n;
    sscanf(p,"%d%n",&d,&n);
    p+=n;
    return d;
  }else{
    p++;
    while(*p==' '){
      p++;
    }
    p++;
    while(*p==' '){
      p++;
    }
    int rv=expr();
    while(*p==' '){
      p++;
    }
    p++;
    return 1LL*rv*rv%1000000007;
  }
}

int main(){
  while(cin.getline(s,sizeof(s)),s[0]!='#'){
    p=s;
    cout<<expr()<<endl;
  }
}

Measured memory_bytes: 3400
// https://atcoder.jp/contests/abc086/tasks/abc086_a

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if ((a * b % 2) == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY){
			if (d[v] > M[u][v]) {
				d[v] = M[u][v];
				p[v] = u;
				color[v] = GRAY;
			}

		}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1) sum += M[i][p[i]];
	}

	return sum;

}


int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}

	cout << prim() << endl;

	return 0;
}




Measured memory_bytes: 3100
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt(), w=sc.nextInt();
        char[][] c=new char[h][w];
        for(int i=0;i<h;i++) c[i]=sc.next().toCharArray();
        sc.close();
        int ex=4;
        int[][] sharp=new int[h+ex][w+ex];
        int[][] sharpT=new int[w+ex][h+ex];
        for(int i=0;i<h;i++){
            sharp[i][0]=-1; sharp[i][1]=-1;
            int index=2;
            for(int j=0;j<w;j++){
                if(c[i][j]=='#'){
                    sharp[i][index]=j;
                    index++;
                }
            }
            while(index<w+ex){
                sharp[i][index]=w;
                index++;
            }
        }
        for(int j=0;j<w;j++){
            sharpT[j][0]=-1; sharpT[j][1]=-1;
            int index=2;
            for(int i=0;i<h;i++){
                if(c[i][j]=='#'){
                    sharpT[j][index]=i;
                    index++;
                }
            }
            while(index<h+ex){
                sharpT[j][index]=h;
                index++;
            }
        }
        // for(int i=0;i<h+2;i++){
        //     for(int j=0;j<w+2;j++){
        //         System.out.print(sharp[i][j]+" ");
        //     }
        //     System.out.print("\n");
        // }
        // for(int j=0;j<w+2;j++){
        //     for(int i=0;i<h+2;i++){
        //         System.out.print(sharpT[j][i]+" ");
        //     }
        //     System.out.print("\n");
        // }
        int max=Integer.MIN_VALUE;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(c[i][j]=='#') continue;
                int left=binarySearch(sharp[i], j);
                int top=binarySearch(sharpT[j], i);
                int row, column;
                
                //System.out.println("i,j:"+i+","+j/*+" r:"+row+" c:"+column*/);
                row=sharp[i][left+1]-sharp[i][left]-1;
                column=sharpT[j][top+1]-sharpT[j][top]-1;
                max=Math.max(max, row+column-1);
            }
        }
        System.out.println(max);
    }
    public static boolean isOK(int[] array, int index, int key) {
        if (array[index]<key) return true;
        return false;
    }
    public static int binarySearch(int[] array, int key){
        int left=-1;
        int right=array.length;
        while(right-left>1){
            int mid=left+(right-left)/2;
            if(isOK(array, mid, key)) left=mid;
            else right=mid;
        }
        //if(right<array.length && isOK(array, right, key)) return right;
        return left;
    }
}

Measured memory_bytes: 106072
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
xt=0
yl=0
yt=0
for i in range(n-1):
  if i==0:
    for j in range(1,n):
      xt+=x[j]-x[i]
    xl=xt
  else:
    xt-=(x[i]-x[i-1])*(n-i)
    xl=(xl+xt)%mod
for i in range(m-1):
  if i==0:
    for j in range(1,m):
      yt+=y[j]-y[i]
    yl=yt
  else:
    yt-=(y[i]-y[i-1])*(m-i)
    yl=(yl+yt)%mod
print(xl*yl%mod)

Measured memory_bytes: 84324
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
int main()
{
    string N;
    cin >> N[0] >> N[1] >> N[2];
    if(N[0] == '7' || N[1] == '7' || N[2] == '7') cout << "Yes" << endl;
    else    cout << "No" << endl;
    return 0;
}

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  int K,N, B, C, count=0, ans=0;
  string D, E;
  cin >> K >> N;
  vector<int> A(N); 
  rep(i,N){
  	cin >> A[i];
  }
  sort(A.begin(), A.end());
  B=0;
  rep(i,N-1){
    B=max(A[i+1]-A[i],B);
  }
  B=max(B,K-A[N-1]+A[0]);
  C=K-B;
  cout << C << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
double dp[21][150001];
const double INF=(1LL<<50);
int a[21];
int n;
int maxSize=0;

double dfs(int idx,int lastNum){
    if(idx==-1)
        return 0.0;
    if(!EQ(INF,dp[idx][lastNum]))
        return dp[idx][lastNum];
    double minCost=INF;
    if(idx==n-1)
        for(int i = 1; i <= maxSize*2+1; i++){
            if(minCost<(double)abs(a[idx]-i)/a[idx])
                continue;
            minCost=min(minCost,max(dfs(idx-1,i),(double)abs(a[idx]-i)/a[idx]));
        }
    else{
        // lastNumðèØéÅJÚ
        for(int i = 1; i*i <= lastNum; i++){
            if(lastNum%i==0){
                minCost=min(minCost,max(dfs(idx-1,i),(double)abs(a[idx]-i)/a[idx]));
                minCost=min(minCost,max(dfs(idx-1,(lastNum/i)),(double)abs(a[idx]-(lastNum/i))/a[idx]));
            }
        }
    }
    return dp[idx][lastNum]=minCost;
}

int main(){
    for(int i = 0; i < 21; i++)
        for(int j = 0; j < 150001; j++)
            dp[i][j]=INF;
    cin>>n;
    for(int i = 0; i < n; i++){ 
        cin>>a[i];
        maxSize=max(maxSize,a[i]);
    }
    double res=dfs(n-1,0);
    printf("%.9f\n",res);
    return 0;
}

Measured memory_bytes: 24000
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

Int f(Int m, VInt v, VInt w)
{
    int i, j;
    FOR(i, 0, 3)
    FOR(j, i + 1, 3)
    if(w[i]*v[j] < w[j]*v[i])
    {
        swap(v[i], v[j]);
        swap(w[i], w[j]);
    }
    
    Int res = m;
    FOR(i, 0, v[0])
    FOR(j, 0, v[0])
    {
        Int left = m - v[1]*i - v[2]*j;
        if(left < 0) continue;
        res = max(res, left + w[1]*i + w[2]*j);
        
        Int k = left / v[0];
        left -= k*v[0];
        res = max(res, left + w[1]*i + w[2]*j + w[0]*k);
    }
    return res;
}

void solve(int test)
{
    int n;
    cin >> n;
    
    VInt v[] = {VInt(3), VInt(3)};
    int i, j;
    FOR(i, 0, 2)
    FOR(j, 0, 3)
    scanf("%d", &v[i][j]);
    
    Int r1 = f(n, v[0], v[1]);
    Int r2 = f(r1, v[1], v[0]);
    
    cout << r2 << endl;
}

int main()
{
    int t, T;
    T = 1;
    //scanf("%d", &T);
    FOR(t, 0, T) solve(t);
    
    return 0;
};



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

const int N = 1010;

int a[N];

int main(){
	string st1,st2;
	cin>>st1>>st2;
	int n = st1.length();
	for (int i = 0; i < n; i++){
		if (st1[i] != st2[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3596
(let* ((nm (mapcar (lambda (a) (parse-integer (string a))) (concatenate 'list (read-line))))
      (form '()))
  (loop :for k :from 0 :upto 7 :do
    (let* ((kl (concatenate 'list (format nil "~3,'0B" k))))
      (setf form (nconc (list (first nm) ) (mapcar (lambda (x w)
                                            (if (char= x #\0)
                                                w
                                                (* -1 w))) kl (cdr nm))))
      form) :until (= 7 (reduce #'+ form)) :finally (format t "~D~@D~@D~@D=7" (nth 0 form) (nth 1 form) (nth 2 form) (nth 3 form))))

Measured memory_bytes: 6504
import java.io.*;
import java.util.ArrayList;
public class Main{
  public static void main(String args[]){
    String str;
          int limit=(int)Math.pow(10,9);
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      String[] numstr = str.split(" ");
      int[] num=new int[2];
      for(int i=0;i<2;i++){
        num[i]=Integer.parseInt(numstr[i]);
      }
      int ans=calAbs(num);
      if(ans==limit){
        System.out.println("IMPOSSIBLE");
      }else{
      System.out.println(ans);
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  }

    public static int calAbs(int[] num){
      int i=Integer.MIN_VALUE;
      int a,b;
      int limit=(int)Math.pow(10,9);
      if((num[0]+num[1])%2!=0)return limit;
      int ave=(num[0]+num[1])/2;
      return ave;
    }

}


Measured memory_bytes: 19412
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> Ps(N);
    REP(n, N) cin >> Ps[n];

    int mn = 1e9;
    int ans = 0;
    for(auto p: Ps) {
        if (p < mn) ++ans;
        mn = min(mn, p);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
//13
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(int n;cin>>n,n!=-1;){
    string s;
    do{
      s+=char(n%4+'0');
      n/=4;
    }while(n);
    cout<<string(s.rbegin(),s.rend())<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
char ans[111][111];
string s[111];
ll vx[8]={1,1,1,0,0,-1,-1,-1};
ll vy[8]={1,-1,0,1,-1,1,-1,0};
ll h,w;
bool check(ll x,ll y){
  return x>=0&&x<h&&y>=0&&y<w;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j] == '#'){ans[i][j]='#';continue;}
      ll cnt = 0;
      for(int k=0;k<8;k++){
	ll x = i+vx[k],y = j+vy[k];
	if(check(x,y) && s[x][y] == '#'){
	  cnt++;
	}
      }
      ans[i][j] = cnt + '0';
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
input=sys.stdin.readline


def solve():
    N, M = map(int, input().split())
    *A, = map(int, input().split())
    *B, = map(int, input().split())
    c = Counter()
    MOD = 10**9+7
    used = set()

    for i in range(N):
        for j in range(M):
            if A[i]==B[j]:
                if A[i] in used:
                    print(0)
                    return
                else:
                    used.add(A[i])
            c[min(A[i], B[j])] += 1

    cd = 0
    ans = 1
    bef = 0
    for i, j in sorted(c.items()):
        cd += (i - bef)
        if i not in used:
            ans *= j
        cd -= 1
        for k in range(j-1):
            ans *= (cd-k)
            ans %= MOD
        cd -= j-1
        bef = i
    print(ans%MOD)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3700
import sys
input = lambda: sys.stdin.readline()


def solve():
    def init(init_arr):
        global num, segfunc, ide_ele, seg
        segfunc = lambda x, y: max(x, y)
        ide_ele = 0
        num = 2 ** (n - 1).bit_length()
        seg = [ide_ele] * 2 * num
        for i in range(n):
            seg[i + num - 1] = init_arr[i]
        for i in range(num - 2, -1, -1):
            seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

    def update(k, x):
        k += num - 1
        seg[k] = x
        while k:
            k = (k - 1) // 2
            seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])

    def query(p, q):
        if q <= p:
            return ide_ele
        p += num - 1
        q += num - 2
        res = ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = segfunc(res, seg[p])
            if q & 1 == 1:
                res = segfunc(res, seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = segfunc(res, seg[p])
        else:
            res = segfunc(segfunc(res, seg[p]), seg[q])
        return res

    n, q = map(int, input().split())
    a = list(map(int, input().split()))

    init(a)
    res = []

    for _ in range(q):
        t, a, b = map(int, input().split())
        if t == 1:
            update(a - 1, b)
        elif t == 2:
            res.append(query(a - 1, b))
        elif t == 3:
            ng = a - 1
            ok = n + 1
            while ok > ng + 1:
                mid = (ok + ng) // 2
                if query(ng, mid) >= b:
                    ok = mid
                else:
                    ng = mid
            res.append(ok)
    print("\n".join(map(str, res)))


solve()


Measured memory_bytes: 118132
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(lli i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int n, x; cin >> n >> x;
	
	if(x==n*2-1 || x==1){
		cout << "No" << endl;
	}else if(n==2){
		cout << "Yes" << endl;
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
	}else{
		cout << "Yes" << endl;
		if(x==2){
			int c = 6;
			rep(i, n-3) cout << c++ << endl;
			cout << 3 << endl;
			cout << 1 << endl;
			cout << 2 << endl;
			cout << 5 << endl;
			cout << 4 << endl;
			rep(i, n-3) cout << c++ << endl;
		}else if(x==3){
			int c = 6;
			rep(i, n-3) cout << c++ << endl;
			cout << 5 << endl;
			cout << 1 << endl;
			cout << 3 << endl;
			cout << 4 << endl;
			cout << 2 << endl;
			rep(i, n-3) cout << c++ << endl;
		}else{
			int c = 1;
			rep(i, n-3){
				if(c==x-3) c = x+2;
				cout << c++ << endl;
			}
			cout << x-3 << endl;
			cout << x-1 << endl;
			cout << x+1 << endl;
			cout << x << endl;
			cout << x-2 << endl;
			rep(i, n-3){
				if(c==x-3) c = x+2;
				cout << c++ << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1536
open System.Collections.Generic

let [|N;W|] = stdin.ReadLine().Split() |> Array.map int
let wv =
    [|1..N|]
    |> Array.map (fun _ -> stdin.ReadLine().Split() |> Array.map int)

wv
|> Array.scan (fun s [|w;v|] ->
    [|0..W|]
    |> Array.map (fun x ->
        if x >= w then max (s.[x-w]+int64(v)) (s.[x])
        else s.[x])) ([|0..W|] |> Array.map (fun _ -> 0L))
|> fun x -> x.[N].[W]
|> stdout.WriteLine

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

int n,a[25],ans;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++)
    {
		int tag = 1;
		for(int j = 1; j < i; j++)
			if(a[j]>a[i]) tag = 0;
		if(tag) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// 嘘解法
// 4 8
// 0 0 8 8
// とかで嘘の答え出す

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#include <stack>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  ll N, K; cin >> N >> K;
  ll A[N]; rep(i,N) cin >> A[i];
  ll t_bit[50] = {}; rep(i,N) rep(j,50) t_bit[j] += ((A[i]>>j)&1);
  bool bit[50]; rep(i,50) bit[i] = !(t_bit[i]>N/2);

  ll X = 0;
  for(int i=50; i>=0; i--) {
    if (bit[i]) {
      ll tmp = X | ((ll)1<<i);
      if (tmp<=K) X = tmp;
    }
  }

  ll result = 0; rep(i,N) result += X^A[i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
S = input()

S = S[::-1]

dream = "maerd"
dreamer = "remaerd"
erase = "esare"
eraser = "resare"

if len(S) > 0:
    while len(S) > 0:
        if S.startswith(dream):
            S = S[len(dream):]
        elif S.startswith(dreamer):
            S = S[len(dreamer):]
        elif S.startswith(erase):
            S = S[len(erase):]
        elif S.startswith(eraser):
            S = S[len(eraser):]
        else:
            break
    if len(S) > 0:
        print("NO")
    else:
        print("YES")

else:
    print("NO")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  if(a >= b&&a >= c) {
    d = b + c;
  }
  if(b >= a&&b >= c) {
    d = a + c;
  }
  if(c >= a&&c >= b) {
    d = a + b;
  }
  cout << d << endl;
}

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

int main() {
  int x,y,z;cin>>x>>y>>z;
  int n=x-z;
  cout<<n/(y+z)<<endl;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            for (char cc : in.next().toCharArray()) {
                switch (cc) {
                    case '0':
                        sb.append('0');
                        break;
                    case '1':
                        sb.append('1');
                        break;
                    case 'B':
                        if (sb.length() > 0)
                            sb.deleteCharAt(sb.length() - 1);
                        break;
                }
            }
            out.println(sb);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



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

int main() {
#ifdef _debug
    freopen( "in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a , b;
    cin >> a >> b;
    puts( b>=a? "unsafe":"safe");
    return 0;
}


Measured memory_bytes: 3652
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
asum=sum(a)

for i in range(m):
    if a[n-i-1]*4*m<asum:
        #print(a[n-i-1]*4*m,a[n-i-1],asum)
        print("No")
        exit()
print("Yes")
        

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n,d;
  cin >> n >> d;
  ll cnt = 0;
  rep(i,n){
    ll x , y;
    cin >> x >> y;
    double z = sqrt(x*x+y*y);
    if(z<=d)cnt++;
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    long n = Long.parseLong(sl[0]);
    long a = 0;
    for(long x = 10; x <= n; x *= 5)
    {
      a += n / x;
    }
    System.out.println(n % 2 == 0 ? a : 0);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;

void solve(){
	cin >>x;
	for(int i =1;i<=x;i++){
		if((360*i)%x == 0){
			cout << (360*i)/x;
			return;
		} 
	}
}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define Max 100001
#define inf 1000000000000000
using namespace std;
int n,m,flag;
int first[Max * 2],nextv[Max * 2],u[Max * 2],v[Max * 2],s[Max * 2];
long long vis[2][Max],l = 0,r = inf,ans;
void dfs(int from,int tag,long long va) {
    if(flag)return;
    int k = first[from];
    while(k != -1) {
        if(flag)return;
        int vtag = (tag == 1);
        int to = v[k];
        long long lva = s[k] - va;
        if(vis[vtag][to] != inf) {
            if(vis[vtag][to] == lva) {
                k = nextv[k];
                continue;
            }
            else {
                flag = 1;
                return;
            }
        }
        vis[vtag][to] = lva;
        if(vtag)r = min(r,lva);
        else l = max(l,-lva);
        dfs(to,-tag,lva);
        k = nextv[k];
    }
}
int main() {
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 1;i <= n;i ++) {
        vis[0][i] = vis[1][i] = inf;
    }
    for(int i = 0;i < m;i ++) {
        scanf("%d%d%d",&u[i],&v[i],&s[i]);
        u[i + m] = v[i];
        v[i + m] = u[i];
        s[i + m] = s[i];
        nextv[i] = first[u[i]];
        first[u[i]] = i;
        nextv[i + m] = first[u[i + m]];
        first[u[i + m]] = i + m;
    }
    dfs(1,1,0);///dfs遍历所有点和第一个点的关系，如果有冲突flag为1
    if(!flag) {///遍历后无冲突
        long long temp = -1;
        for(int i = 1;i <= n;i ++) {
            if(vis[0][i] != inf && vis[1][i] != inf) {
                long long d = (vis[1][i] - vis[0][i]) / 2;
                if(d < 0) {///解是负数 不成立
                    flag = 1;
                    break;
                }
                if(temp == -1)temp = d;
                else if(temp != d) {///解不一致
                    flag = 1;
                    break;
                }
            }
        }
        if(temp != -1 && !flag) {///有环 且各关系无冲突
            if(temp > l && temp < r)ans = 1;
        }
        else if(r - l - 1 > 0) ans = r - l - 1;
    }
    printf("%lld",ans);
    return 0;
}


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



int main(void)
{
    int N,ans = 0,sum;
    cin >> N;
    vector<vector<int>> a(2,vector<int>(N));

    rep(i,2){
        rep(j,N){
            cin >> a[i][j];
        }
    }

    rep(k,N){
        int i = 0;
        sum = 0;
        rep(j,N){
            sum += a[i][j];
            if(k == j){
                i = 1;
                sum += a[i][j];
            }
        }
        ans = max(ans,sum);
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3612
H,N=map(int,input().split())

ablist=[]
for i in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
  
dp=[]
for i in range(N+1):
  dp.append([10**9]*(H+1))
  
for i in range(N+1):
  dp[i][0]=0
  
#print(dp)  
for i in range(1,N+1):
  ai,bi=ablist[i-1]
  for j in range(1,H+1):
    if j-ai<0:
      dp[i][j]=min(dp[i-1][j],bi)
    else:
      dp[i][j]=min(dp[i-1][j],dp[i][j-ai]+bi)
      
#print(dp)
print(dp[N][H])

Measured memory_bytes: 120300
def insertionSort(At, Nt):
	for i in range(Nt):
		v = At[i]
		j = i - 1
		while j >= 0 and At[j] > v:
			A[j + 1] = A[j]
			j = j - 1
		A[j + 1] = v
		print(" ".join(map(str,At)))
	return At

if __name__ == '__main__':
	N = int(input())
	A = list(map(int, input().split()))
	A = insertionSort(A, N)
	#print(" ".join(map(str,A)))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=3005;
struct Node{
    int a,b;
}p[max_n];
int n,T;
int pre[max_n][max_n],suf[max_n][max_n];
int main(){
    scanf("%d%d",&n,&T);
    for(int i=1;i<=n;i++)scanf("%d%d",&p[i].a,&p[i].b);
    pre[0][0]=0;
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=p[i].a;
        for(int j=T-1;j>=0;j--){
            pre[i][j]=pre[i-1][j];
            if(j>=p[i].a)pre[i][j]=max(pre[i][j],pre[i-1][j-p[i].a]+p[i].b);
        }
        for(int j=1;j<=T-1;j++)pre[i][j]=max(pre[i][j],pre[i][j-1]);
    }
    sum=0;
    suf[n+1][0]=0;
    for(int i=n;i>=1;i--){
        sum+=p[i].a;
        for(int j=T-1;j>=0;j--){
            suf[i][j]=suf[i+1][j];
            if(j>=p[i].a)suf[i][j]=max(suf[i][j],suf[i+1][j-p[i].a]+p[i].b);
        }
        for(int j=1;j<=T-1;j++)suf[i][j]=max(suf[i][j],suf[i][j-1]);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=T-1;j++)ans=max(ans,pre[i-1][j]+suf[i+1][T-1-j]+p[i].b);
    }
    printf("%d\n",ans);
    return 0;
}

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

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

    int n = s.size();
    map<char, int> mp;
    mp['a'] = 0;
    mp['b'] = 0;
    mp['c'] = 0;
    for (auto c : s) mp[c]++;
    bool ok = true;
    if (n <= 3) {
        for (auto p : mp) {
            if (2 <= p.second) ok = false;
        }
    }
    if (1 < abs(mp.at('a') - mp.at('b'))) ok = false;
    if (1 < abs(mp.at('b') - mp.at('c'))) ok = false;
    if (1 < abs(mp.at('c') - mp.at('a'))) ok = false;

    
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3736