akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    int n, res = 0;
    cin >> n;
    vector<ll> a(n), l(n + 1), r(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; ++i) {
        l[i + 1] = gcd(a[i], l[i]);
    }
    for (int i = n - 1; i >= 0; --i) {
        r[i] = gcd(a[i], r[i + 1]);
    }
    res = -INF;
    for (int i = 0; i < n; ++i) {
        res = max((ll)res, gcd(l[i], r[i + 1]));
    }
    cout << res << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B; cin >> A >> B;
	for (int i = 0; i < 2000; i++)
	{
		if(8 * i / 100 == A && i / 10 == B) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int min_a = s.size(), max_z = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'A' and i < min_a) {
      min_a = i;
    }
    if (s.at(i) == 'Z' and i > max_z) {
      max_z = i;
    }
  }
  cout << max_z - min_a + 1 << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>

#define M 1046527
#define L 14
#define NIL (-1)

char H[M][L];

int getChar(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
  else
    return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); ++i) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) {
  return key % M;
}

int h2(int key) {
  return 1 + (key % (M - 1));
}

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0; ; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {
  int i = 0, j;
  long long key = getKey(str);
  while (1) {
    j = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[j], str) == 0) {
      return 1;
    } else if (strlen(H[j]) == 0) {
      strcpy(H[j], str);
      return 0;
    }
    ++i;
  }
  return 0;
}

int main() {
  int i, n;
  char com[9], str[L];
  for (i = 0; i < M; ++i)
    H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str))
        printf("yes\n");
      else
        printf("no\n");
    }
  }
  return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

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

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int n; cin >> n; n %= 10;

    string ans;
    if (n == 3) ans = "bon";
    else if (n == 0 or n == 1 or n == 6 or n == 8) ans = "pon";
    else ans = "hon";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>

#define MAX_NODE 100
#define INF 1000000000

using namespace std;

struct Edge{
	int to, w;
};

vector <Edge> e[MAX_NODE];

int minw[MAX_NODE];
bool flag[MAX_NODE];

int prim(int n,int start){
	fill(minw,minw+n,INF);
	fill(flag,flag+n,false);
	minw[start]=0;
	int sum=0;
	int from = start;
	while(1){
		for(int i=0;i<e[from].size();i++){
			if(e[from][i].w<minw[e[from][i].to]){
				minw[e[from][i].to]=e[from][i].w;
			}		
		}
		int minimum_e;
		minimum_e=INF;
		for(int i=0;i<n;i++){
			if(minimum_e>minw[i]&&flag[i]==false){
				minimum_e=minw[i];
				from=i;
			}
		}
		if(minimum_e==INF){
			break;
		}
		sum+=minimum_e;
		flag[from]=true;
	}
	return sum;
}

int main(){
	int n,tmp,sum;
	Edge edge;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>tmp;
			if(tmp!=-1){
				edge.to=j;
				edge.w=tmp;
				e[i].push_back(edge);
			}
		}
	}
	sum=prim(n,0);
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;
//等間隔ではないRGB の位置の組
vector<int> search(string s, string find_word){
    vector<int> positions;
    std::string::size_type pos = s.find(find_word);
    while (pos != std::string::npos) {
        positions.emplace_back(pos);
        //std::cout << pos << std::endl;
        pos = s.find(find_word, pos + find_word.length());
    }
    return positions;
}

int main(){
    int n, k;
    cin >> n;
    string s;
    cin >> s;

    vector<int> rpos = search(s, "R");
    vector<int> gpos = search(s, "G");
    vector<int> bpos = search(s, "B");
    long long count = 0;
    long long first_conditions = rpos.size() * gpos.size() * bpos.size();
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            if(s[i] == s[j]) continue;
            k = 2 * j - i;
            if(k >= n || s[j] == s[k] || s[i] == s[k]) continue;
            count++;
        }
    }
    cout << first_conditions - count << endl;
}

Measured memory_bytes: 3616
N = int(input())
counters = []
for i in range(0, N):
	lst = []
	for j in range(0, 26):
		lst.append(0)
	S = input()
	for j in range(0, 10):
		lst[ord(S[j])-97] += 1
	counters.append(lst)
counters.sort()
cntlist = [1]
for i in range(1, N):
	if counters[i-1] == counters[i]:
		cntlist[-1] += 1
	else:
		cntlist.append(1)
ans = 0
for i in range(0, len(cntlist)):
	if cntlist[i] != 1:
		ans += (cntlist[i] * (cntlist[i]-1)) // 2
print(ans)

Measured memory_bytes: 92632
//103
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> vec(N);
    int ans = 0;
    int max = 0;
    for(int i = 0; i < N; i++)
    {
        /* code */
        cin >> vec[i];
        if(max <= vec[i]){
            max = vec[i];
            ans++;
        }

    }
    cout << ans << endl;

}


Measured memory_bytes: 256
// 2020.4.15

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>

using namespace std;

string S;
int n;

long dfs(int i, int start, long sum) {
    if (i == n - 1) {
        // cout << i << ": " << start << " " << i - start + 1 << endl;
        return sum + stol(S.substr(start, i - start + 1));
        // cout << "OK" << endl;
    }

    // i番目の後に+を差し込む場合
    long sum1 = dfs(i + 1, i + 1, sum + stoi(S.substr(start, i - start + 1)));

    // i番目の後に+を使わない場合
    long sum2 = dfs(i + 1, start, sum);

    return sum1 + sum2;
}

int main() {
    cin >> S;
    n = (int)(S.length());

    // cout << n << endl;

    // cout << S.substr(0, 10) << endl;
  
    // cout << (long)stol(S.substr(0, 10)) << endl;

    cout << dfs(0, 0, 0) << endl;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	FIO
	
	int k, n;
	cin >> k >> n;
	vector<long long> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	for(int i = 0; i < n - 1; i++)a.push_back(a[i]);
	vector<long long> b;
	for(int i = 1; i < n; i++)b.push_back(a[i]);
	vector<long long> c;
	for(auto i:b)c.push_back(i);
	for(auto i:a)c.push_back(i);
	long long sum = 0;
	vector<int> pre;
	for(int i = 1; i < (int)c.size(); i++){
		if(c[i] > c[i - 1])pre.push_back(c[i] - c[i - 1]);
		else pre.push_back(k + c[i] - c[i - 1]);
	}
	deb(pre);
	for(int i = 0; i < n - 1; i++)sum += pre[i];
	long long ans = sum;
	//deb(sum);
	for(int i = n - 1; i < (int)pre.size(); i++){
		long long curr = sum - pre[i - n + 1];
		deb(curr, pre[i]);
		curr += pre[i];
		ans = min(ans, curr);
		sum = curr;
	}
	cout << ans;
	return 0; 
}


Measured memory_bytes: 19164
#include <stdio.h>
int main(void){
int m,f,b;
scanf("%d %d %d", &m, &f, &b);
if(m>=b){
  printf("0\n");
 }  else if(m+f>=b){
  printf("%d\n",b-m);
 } else{
  printf("NA\n");
}
return 0;
}





Measured memory_bytes: 2112
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    deque<char> dq;
    string s;
    int q;
    cin >> s >> q;
    for(int i = 0;i < s.size();i++)
    {
        dq.push_back(s[i]);
    }
    bool flag = true;
    for(int i = 0;i < q;i++)
    {
        int t;
        cin >> t;
        if(t == 1)
        {
            flag = !flag;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if(flag && f == 1 || !flag && f == 2)
            {
                dq.push_front(c);
            }
            else
            {
                dq.push_back(c);
            }
        }
    }
    if(!flag)
    {
        reverse(dq.begin(),dq.end());
    }
    for(int i = 0;i < dq.size();i++)
    {
        cout << dq[i];
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  	int N;
	string S;
  	cin >> N;
  	cin >> S;
  	ll ans = 1;
	map<char, ll> m;
    for(int i = 0; i < N; i++){
    	m[S[i]]++;
    }
  	for(auto x: m){
    	ans *= (x.second+1);
      	ans%=MOD;
    }
  	if(N == 0) ans = 0;
  	else ans = (ans-1+MOD)%MOD;
  	cout << ans << endl;
}

Measured memory_bytes: 512
#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 T;
    cin >> T;
    for(int i =0 ; i < T.size(); ++i)
    {
        if(T[i] == '?')
        {
            T[i] = 'D';
        }
    }

    cout << T << endl;
 
	return 0;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < m; i++) {
			int left = sc.nextInt() - 1;
			int right = sc.nextInt() - 1;
			arr[left]++;
			if (right < n - 1) {
				arr[right + 1]--;
			}
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (i != 0) {
				arr[i] = arr[i - 1] + arr[i];
			}
			if (arr[i] == m) {
				count++;
			}
		}
		System.out.print(count);
	}
}


Measured memory_bytes: 63540
/**
  *  Worg
  */
#include <vector>
#include <iostream>
#include <algorithm>

const int MOD = 1e9 + 7;

void dfs(int node, int father, std::vector<std::vector<int>>& graph, std::vector<std::vector<int>>& dp) {
    // 0 = white, 1 = black
    dp[node][0] = dp[node][1] = 1;
    for (auto& son: graph[node]) {
        if (son != father) {
            dfs(son, node, graph, dp);
            dp[node][0] = 1LL * dp[node][0] * (dp[son][0] + dp[son][1]) % MOD;
            dp[node][1] = 1LL * dp[node][1] * dp[son][0] % MOD;
        }
    }
}


int main() {
    int n; std::cin >> n;
    std::vector<std::vector<int>> graph(n);

    for (int i = 1; i < n; i++) {
        int u, v; std::cin >> u >> v;
        u--; v--;
        graph[u].push_back(v); graph[v].push_back(u);
    }

    std::vector<std::vector<int>> dp(n, std::vector<int>(2, 0));
    dfs(0, 0, graph, dp);
    std::cout << (dp[0][0] + dp[0][1]) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 18176
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int f[200000+20];
int b(int x){
	int cnt=0;
	while(x){
		if(x&1) cnt++;
		x>>=1;
	}
	return cnt;
}
string s;
int tmp=0;
int l1,l2,l3;
int MOD;
LL quick(int A,int B){
	LL res;
	if(B==0) return 1;
	res=quick(A,B>>1);
	res*=res;
	res%=MOD;
	if(B&1){
		res*=(LL)A;
		res%=MOD;
	}
	return res;
}
int main(){
	fastio;
//	freopen("tt.in","r",stdin);
	f[0]=0;
	rb(i,1,200000+1){
		f[i]=f[i%b(i)]+1;		
	}
	int n;
	cin>>n>>s;
	rep(i,n){
		if(s[i]=='1'){
			tmp++;	
		}
	}
	if(tmp==0){
		rb(i,1,n)
			cout<<1<<endl;
		return 0;
	}
	l1=l2=l3=0;
	rep(i,n){
		if(tmp!=1)
		l1<<=1;
		if(tmp)
		l2<<=1;
		l3<<=1;
		if(s[i]=='1'){
			if(tmp!=1)
			l1++;
		if(tmp)
			l2++;
			l3++;
		}
		if(tmp!=1)
		l1%=tmp-1;
		if(tmp)
		l2%=tmp;
		l3%=tmp+1;
	}
	rep(i,n){
		int res;
		if(s[i]=='1'){
			//->0
			if(tmp!=1){
			MOD=tmp-1;
			res=l1;
			res-=quick(2,n-1-i);
			res+=MOD;
			res%=MOD;
			res=f[res]+1;
			
			}else{
				res=0;
			}
		}
		else{
			MOD=tmp+1;
			res=l3;
			res+=quick(2,n-1-i);
			res%=MOD;
			res=f[res]+1;
		}
		cout<<res<<endl;
	}
	return 0;
}


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

int main() {
    int n, cnt = 1;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }

    int now = 0;
    for (int i = 0; i < n; i++) {
        if (a[now] == 2) {
            cout << cnt << endl;
            return 0;
        }
        now = a[now] - 1;
        cnt++;
        //cout << "now = " << now << endl;
        //cout << "cnt = " << cnt << endl;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>  
#include <cstring>  
#include <queue>
#include <stack> 
#include <algorithm>  
using namespace std; 
long long N,a[10010],b[10010],c[10010],i,j,s,ax,bx,t;      
int main()  
{ 
	
	scanf("%lld",&N);
	for(i=0;i<N;i++)
		scanf("%lld",&a[i]);
	for(s=ax=bx=i=0;i<N;i++)
	{
		scanf("%lld",&b[i]);
		c[i]=b[i]-a[i];
		if(c[i]>0)
		{
			bx+=c[i];
			if(c[i]%2)
				s++;
		}			
		else
			ax+=c[i];
	}
	if((bx-s)/2>=(-ax))
		printf("Yes\n");
	else
		printf("No\n");
	/*if((bx%2==0||ax%2)&&bx>(-ax))
		printf("Yes\n");
	else
		printf("No\n");	*/

	return 0; 
}

Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

	int count = H / A;
	if (H % A != 0) count++;

	cout << count << endl;
	
	return 0;
}

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

using namespace std;

int main(){

    int long long n;
    while(true){
        cin>>n;
        if(n==0)break;
        int long long st[n];
        int long long sa[n-1];

        for(int long long i=0;i<n;i++){
            cin>>st[i];
        }
        sort(st,st+n);

        for(int long long i=1;i<n;i++){
            sa[i-1]=st[i]-st[i-1];
        }
        sort(sa,sa+n-1);
        cout<<sa[0]<<endl;
    }
return 0;




}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  if(N*A<B) cout << N*A << endl;
  else cout << B << endl;
}

Measured memory_bytes: 256
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 105;

int n;
int arr[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>n;
    REP(i,1,n)cin>>arr[i];
    int mn = arr[1], mx = arr[1];
    REP(i,2,n){
        mn = min(mn, arr[i]);
        mx = max(mx, arr[i]);
    }
    
    int ans = OO;
    REP(i,mn,mx){
        int cost = 0;
        REP(j,1,n){
            cost += (i-arr[j]) * (i-arr[j]);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())

if N % 2 != 0:
    print(0)

else:
    fives = 0
    power = 0

    while (5 ** (power+1)) <= N:  # Nには5のpower乗まで入る
        power += 1

    for i in range(1, power+1):
        fives += N // (5 ** i) // 2

    print(int(fives))


Measured memory_bytes: 61880
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

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

	int q;
	cin >> q;

	double area = 0.0, prex, prey, x0, y0, x, y;
	for (int i = 0; i < q; i++)
	{
		cin >> x >> y;

		if (i == 0)
		{
			x0 = x, y0 = y;
		}
		else
		{
			area += (x - prex)*(y + prey);
		}

		prex = x, prey = y;
	}
	area += (x0 - prex)*(y0 + prey);
	
	printf("%.1lf\n", abs(area / 2));

	return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
    string s;cin >> s;
    int count = 0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]) count++;
    }
    cout << count << endl;
}

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

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		for(;;)
		{
			int N = sc.nextInt();
			if (N==0)break;
			
			int[][] is = new int[N][2];
			int[] time = new int[86400];
			for (int i = 0; i < N; i++)
			{
				String t1 = sc.next();
				String t2 = sc.next();
				is[i][0] = toSec(t1);
				is[i][1] = toSec(t2);
			}
			for (int i = 0; i < N; i++)
			{
				for (int s = is[i][0]; s < is[i][1]; s++)
				{
					time[s]++;
				}
			}
			int max = 0;
			for (int i = 0; i < 86400; i++)
			{
				max = Math.max(max, time[i]);
			}
			System.out.println(max);
		}
	}
	
	private static int toSec(String s)
	{
		String[] parts = s.split(":");
		int sec = 0;
		for (int i = 0; i < 3; i++)
		{
			sec = 60 * sec + Integer.parseInt(parts[i]);
		}
		return sec;
	}
}

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

int main(){
  int a, b, n, cnt;
  cnt = 0;
  n = 0;
  cin >> a >> b;
  while(true){
    n += a;
    cnt++;
    if(n >= b) break;
    n--;
  }
  if(b == 1) cout << 0 << endl;
  else cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

int main()
{
  int N;
  cin >> N;
  string ID[N];
  REP(i, N)
    cin >> ID[i];
  int M, state;
  string T;
  state = 1;
  cin >> M;
  REP(i, M){
    cin >> T;
    if(find(ID, ID + N, T) != ID + N){
      if(state){
        cout << "Opened by " << T << endl;
        state = 0;
      }else{
        cout << "Closed by " << T << endl;
        state = 1;
      }
    }else{
      cout << "Unknown " << T << endl;
    }
  }
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
using namespace std;

int INF = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	set<int> s;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s.insert(a[i]);
	}

	sort(begin(a) + 1, end(a));

	int j = 1, sum = 0, ans = 0;
	for (auto i : s) {
		while (j <= n) {
			if (i == a[j]) sum++;
			else break;
			j++;
		}
		if (sum % 2 == 1) ans++;
		sum = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5376
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t N;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (int64_t b = -1000; b < 1000; b++)
        for (int64_t i = -1000; i < 1000; i++)
    {
        if (i * i * i * i * i - b * b * b * b * b == N) {
            out << i << ' ' << b << endl;
            return 0;
        }
    }

    return 0;
}
#endif


Measured memory_bytes: 3176
#include <cstdio>
#include <cmath>
using namespace std;

int n[2];
bool num[2][10];

int main(){
	while(scanf("%d%d",&n[0],&n[1])){
		if(n[0] == 0 && n[1] == 0) break;
		for(int i = 0; i < 2; i++) for(int j = 0; j < 10; j++) num[i][j] = false;
		int h = 0, d = 0;
		for(int i = 0; i < 2; i++) for(int j = 0; j < 4; j++) num[i][(n[i]%(int)pow(10,4-j))/(int)pow(10,3-j)] = true;
		for(int i = 0; i < 4; i++) if((n[0]%(int)pow(10,4-i))/(int)pow(10,3-i) == (n[1]%(int)pow(10,4-i))/(int)pow(10,3-i)) h++;
		for(int i = 0; i < 10; i++) if(num[0][i] == true && num[1][i] == true) d++;
		printf("%d %d\n", h, d-h);
	}
}

Measured memory_bytes: 1072
s = input()

if s[0] == s[1]:
    print(1, 2)
    exit()

for i in range(len(s)-2):
    if s[i] == s[i+1] or s[i] == s[i+2]: 
        print(i+1, i+3)
        exit()

print(-1, -1)

Measured memory_bytes: 9164
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 03:08:56 2020

@author: liang
"""

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
ans = 10**10
h.sort()
for i in range(0,N-K+1):
    tmp = h[i+K-1] - h[i]
    ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 13328
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    sc.nextLine();
    String s=sc.nextLine();
    if(n%2!=0)
      System.out.println("No");
    else
    {
      boolean b=true;
      for(int i=n/2-1,j=n-1;i>=0;i--,j--)
      {
        if(s.charAt(i)!=s.charAt(j))
        {
          b=false;
          break;
        }
      }
      if(b)
        System.out.println("Yes");
      else
        System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size())cout << "GREATER" << endl;
	else if (a.size() == b.size()) {
		if (a > b)cout << "GREATER" << endl;
		else if (a == b)cout << "EQUAL" << endl;
		else cout << "LESS" << endl;
	}
	else cout << "LESS" << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    ans = ""

    while n > 0:
        r = n % 26
        ans += chr((r - 1) % 26 + ord('a'))
        n //= 26
        if r == 0:
            n -= 1
    print(ans[::-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9504
from collections import deque
k=int(input())
t=[1]*k
q=deque()
q.append((1,1))
while q:
    p,r=q.popleft()
    if p==0:
        print(r)
        break
    if t[p]:
        t[p]=0
        q.appendleft(((p*10)%k,r))
        q.append(((p+1)%k,r+1))

Measured memory_bytes: 14444
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    forn (i, l, r + 1)
        if (i % d == 0)
            ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
l = []
for i in range(5):
    l.append(int(input()))

ans = 10**10

import itertools
t = 0
tt = 0
for P in itertools.permutations(l,len(l)):
    for p in P:
        t += p
        if (p % 10) != 0:
            tt = 10-p%10
            t += (10 - p%10)
    ans = min(ans , t-tt)
    t = 0
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N, K; cin >> N >> K;
VI x(N); rep(i, 0, N) cin >> x[i];

if (x[0] >= 0){
    cout << x[K-1] << "\n";
    return 0;
}

if (x[N-1] <= 0){
    cout << -1 * x[N - K] << "\n";
    return 0;
}

// 全探索，2^N.TLE．
//原点を含むろうそく K 本 で最短な位置を見つける．
int mini = INF;
rep(i, 0, N - K + 1){
    if (x[i + K - 1] < 0) continue;
    if (x[i] > 0) break;
    int diff = x[i + K - 1] - x[i];
    mini = min(mini, min(-1 * x[i], x[i + K - 1]) + x[i + K - 1] - x[i]);
}

cout << mini <<  "\n";

}

// 境界，出力文字列 チェック



Measured memory_bytes: 640
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n")[0].split(" ");
    const num = parseInt(input[0] + input[1] + input[2], 10);
    console.log(num % 4 == 0 ? "YES" : "NO");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define ppb pop_back
using namespace std;

int n,w;
vector<pair<int,int> >v;

ll solve()
{
	ll dp[n+1][w+1];
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=w;j++) 
		{
			if (i==0 || j==0 ) dp[i][j]=0; else
			if (v[i-1].first<=j) dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i-1].first]+1ll*v[i-1].second); else
			dp[i][j]=dp[i-1][j];
		}
	}
	return dp[n][w];
}
int main()
{
	ios::sync_with_stdio(false);
	
	cin>>n>>w;
	int a,b;
	for (int i=0;i<n;i++)
	{
		cin>>a>>b;
		v.pb(mk(a,b));
	}
	
	cout<<solve();
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

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

  vector<bitset<40>> a(n);
  ll tmp;
  rep(i,n) {
    cin >> tmp;
    a[i] = bitset<40>(tmp);
  }
  
  Graph G(40, vi(2, 0));
  rep(i,n) rep(j,40) ++G[j][a[i][j]];

  bitset<40> x(0);
  rep(j,40) if (G[j][0] > G[j][1]) x.set(j);

  bitset<40> max_x(k);
  int digit = 39;
  while (digit >= 0 && !max_x.test(digit)) {
    x.reset(digit);
    --digit;
  }
  while (digit >= 0) {
    if (max_x.test(digit) && !x.test(digit)) break;
    if (!max_x.test(digit) && x.test(digit)) x.reset(digit);
    --digit;
  }

  bitset<40> xxor;
  ll ans = 0;
  rep(i,n) {
    xxor = (x^a[i]);
    ans += xxor.to_ullong();
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <cassert>
using namespace std;
typedef long long ll;
pair<ll,ll> p[100010];
vector<pair<ll,ll>> v;
int main(){
	int i,n;
	cin >> n;
	ll mx = -1,mn = 1000000001;
	int j = -1,k = -1;
	for(i=0;i<n;i++){
		ll l,r; cin >> l >> r;
		p[i] = {r,l};
		if(mx<l){
			j = i;
			mx = l;
		}
		if(mn>r){
			k = i;
			mn = r;
		}
	}
	if(j==k){
		ll sum = 0;
		sum += p[k].first - p[j].second + 1;
		mx = -1;
		for(i=0;i<n;i++){
			if(i==j) continue;
			mx = max(mx,p[i].first - p[i].second + 1LL);
		}
		cout << sum + mx << endl;
		return 0;
	}
	for(i=0;i<n;i++){
		if(i==j || i==k) continue;
		v.push_back(p[i]);
	}
	if(n==2){
		cout << p[0].first - p[0].second + p[1].first - p[1].second + 2 << endl;
		return 0;
	}
	sort(v.begin(),v.end());
	ll amnr = p[j].first,amxl = p[j].second,bmnr = p[k].first,bmxl = p[k].second;
	ll ans = 0;
	for(i=0;i<v.size();i++){
		amnr = min(p[j].first,v[i].first);
		if(i!=0) bmxl = max(bmxl,v[i - 1].second);
		ans = max(ans,max(amnr - amxl + 1LL,0LL) + max(bmnr - bmxl + 1LL,0LL));
	}
	amnr = p[j].first;
	bmxl = max(bmxl,v.back().second);
	ans = max(ans,max(amnr - amxl + 1LL,0LL) + max(bmnr - bmxl + 1LL,0LL));
	mx = -1;
	for(i=0;i<n;i++){
		if(i==j || i==k) continue;
		mx = max(mx,p[i].first - p[i].second + 1LL);
	}
	ans = max(ans,max(p[k].first - p[j].second + 1LL,0LL) + mx);
	cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n, k;
  cin >> n >> k;
  fin(n - k + 1)
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
<?php
$x = rtrim(fgets(STDIN));
$y = rtrim(fgets(STDIN));

while ($x != 0){
    $x_rt = ($x / 2)**2;
    $y_rt = $y**2;
    // print $x_rt;
    // print $y_rt;
    $xy_rt = $x_rt + $y_rt;
    $z = sqrt($xy_rt);
    // print $z;

    // 表面積計算
    $answer = ($x**2) + (($x / 2 * $z) * 4);
    print $answer;
    print PHP_EOL;

    $x = rtrim(fgets(STDIN));
    $y = rtrim(fgets(STDIN));
}


Measured memory_bytes: 9208
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize, d: i64,
        p: [(i64, i64); n]
    }

    let ans = p.into_iter().filter(|x| x.0 * x.0 + x.1 * x.1 <= d * d).count();
    println!("{}", ans);
}


Measured memory_bytes: 7856
package main

import (
	"fmt"
)

func main() {
var a, b int
	for {
		fmt.Scanln(&a, &b)

		if (a == 0) && (b == 0) {
			break
		}
		if a < b {
		fmt.Println(a, b)
		} else{
		fmt.Println(b, a)
               }
	}

}




Measured memory_bytes: 1256
#!/user/bin/env ruby

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


coord = 0
counter = 0

array.each do |item|
  counter = counter + 1
  # p coord
  coord = coord + item
  break if coord > X
end


if coord <= X
  counter = counter + 1
end

# puts ""
puts counter


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll a[3030]; rep(i, N) cin >> a[i];
    ll dp[3030][3030];
    rep(i, N + 1) {
        dp[i][i] = 0;
    }
    rep1(len, N) {
        for(int i = 0; i + len <= N; i++) {
            if((N - len) % 2 == 0) {
                dp[i][i + len] = max(dp[i + 1][i + len] + a[i], dp[i][i + len - 1] + a[i + len - 1]);
            } else {
                dp[i][i + len] = min(dp[i + 1][i + len] - a[i], dp[i][i + len - 1] - a[i + len - 1]);
            }
        }
    }
    cout << dp[0][N] << endl;
	return 0;
}

Measured memory_bytes: 71936
n,k=map(int,input().split())
a=list(map(int,input().split()))
M=max(a)
K=str(format(k,'b'))
M=str(format(M,'b'))
x=max(len(K),len(M))
K=str(format(k,'b').zfill(x))
l=[]
for i in range(n):
  l.append(str(format(a[i],'b').zfill(x)))
ctMz=0
for z in range(len(K)):
  if K[z]=='0':
    ctMz+=1
  else:
    break

l2=[]
l2=['0' for aa in range(x)]

ct=0
for j in range(x):
  ctz=0
  cto=0
  for m in range(n):
    if l[m][j]=='0':ctz+=1
    else:cto+=1
  if j+1<=ctMz:
    ct+=(2**(x-j-1))*cto
    l2[j]='0'
  else:
    if ctz>cto:
      l2[j]='1'
      if int(K)>=int(''.join(l2)):
        ct+=(2**(x-j-1))*ctz
      else:
        ct+=(2**(x-j-1))*cto
        l2[j]='0'
    else:
      ct+=(2**(x-j-1))*cto
      l2[j]='0'
print(ct)

Measured memory_bytes: 19428
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MOD = 998244353;
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define isIn(x, y, h, w) (x >= 0 && x < h && y >= 0 && y < w)
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
#define range(c, r) (c).begin(), (c).begin() + (r)    // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())      // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c), x) != (c).end()) // for vectors
#define run(x, c) for ((x) = (c).begin(); (x) != (c).end(); (x)++)
#define fo0 (i, n) for (i = 0; i < n; i++)
#define fo1 (i, n) for (i = 1; i <= n; i++)
#define rfo(i, n) for (i = n - 1; i >= 0; i--)
#define rfor(i, n) for (i = n; i > 0; i--)
signed main()
{
    int s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan  = new Scanner(System.in);
      int     n     = scan.nextInt();
      int     v     = scan.nextInt();
      int     count = 0;

      int[] A = new int[5];
      for(int i = n; i <= v; i++){
          A[0]  = i;
          A[1]  = A[0] % 10;
          A[0] /= 10;
          A[2]  = A[0] % 10;
          A[0] /= 10;
          A[3]  = A[0] % 10;
          A[0] /= 10;
          A[4]  = A[0] % 10;
          A[0] /= 10;
          //for(int j = 0; j < 5; j++){
          //System.out.print(A[j]);
          //}
          //System.out.println();
          if(A[0] == A[1] && A[2] == A[4]){
             //System.out.println(A[0] + " " + A[4] + " " + A[2] + " " + A[1]);
             count++;
             }
          }
      System.out.println(count);
   }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll n;
    cin >> n;
    vector<bool> sieve(100000001);
    for (int x = 2; x <= 100000000; x++) {
        if (sieve[x]) continue;
        for (int u = 2 * x; u <= 100000000; u += x) {
            sieve[u] = true;
        }
    }
    ll ans = 0;
    REP(i, n) {
        ll a;
        cin >> a;
        if (sieve[a] == false) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 14872
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
#include <queue>
using namespace std;



signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i != n; ++i)
        cin >> x[i];
    int minn = 1000 * 1000 * 1000;
    for (int p = 1; p <= 100; ++p) {
        int s = 0;
        for (int i = 0; i != n; ++i)
            s += pow(x[i] - p, 2.0);
        minn = min(minn, s);
    }
    cout << minn;
	return 0;
}

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

long long int N;

struct StrangeBank{
    int val[101010];
    int c[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

    constexpr StrangeBank() : val(){
        val[0] = 0;
        for(int i = 1, j = 1; i < 101010; ++i){
            val[i] = 9999999;
            while(j < 12 && c[j] <= i)++j;
            for(int k = 0; k < j; ++k){
                val[i] = min(val[i], val[i - c[k]] + 1);
            }
        }
    }
};

constexpr StrangeBank sb = StrangeBank();

int main(){
    scanf("%lld", &N);
    cout << sb.val[N] << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int max =0;
		int count =0;
		for (int i=0;i<3;i++) {
			if (S.charAt(i)=='S') {
				count =0;
			} else {
				count ++;
				if (max<count) {
					max =count;
				}
			}
		}
		System.out.println(max);
	}
}

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

int main() {
  int n, v = 0;
  string s;
  cin >> s;
  n = s.size();
  rep(i, n) if(s[i] == 'o') ++v;
  if(v-n+8 > 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  vvl a = vv(n, 2, 0, ll);
  re(i, n) std::cin >> a[i][0] >> a[i][1];

  ll m = 0;
  ll ans = 0;

  ll o = 0;
  for(int i=0;i<n;i++){
    if(((o|a[i][0])&(~k))==0) ans+=a[i][1], o|=a[i][0];
  }
  for(int i=30;i>=0;i--){
    if((k&(1<<i))==0) continue;
    m += (1<<i);
    ll tmp = m-1;
    //std::cout << "now" << i << " " << tmp << '\n';
    ll buy = 0, v = 0;
    for(int j=0;j<n;j++){
      if((((buy|a[j][0])&(~tmp))==0)) buy |= a[j][0], v += a[j][1];
    }
    //std::cout << ans << '\n';
    ans = max(ans, v);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
using namespace std;
int n=0, k=0, a[200000] = {}, sam, b[100000] = {}, roop = 0, save[100000] = {0}, ans[100000] = {}, w = 0;
int main(void){
	while (1){
	  	//int n=0, k=0, a[100000] = {}, sam, b[1000] = {}, roop = 0, save[1000] = {0}, ans[1000] = {}, w = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)
		  return 0;
		for (int i = 0; i<k; i++){
			cin >> a[i];
		}
		
		sort(a, a + k);
		for (int i = 0; i<k; i++){
			if (a[i + 1] - a[i] == 1){
				sam++;
			}
			else if (a[i + 1] - a[i] != 1){
				b[roop] = sam+1;
				if(a[0]==0){
					if (a[i + 1] - a[i] == 2){
						save[w] = roop;
						w++;
					}
				}
				sam = 0;
				roop++;
			}
		}
		for (int i = 0; i <= roop; i++){
			if (save[i] != 0){
				ans[i] = b[save[i]];
				ans[i]+= b[save[i] + 1] + 1;
			}
		}
		sort(b, b + roop+1);
		sort(ans, ans + roop+1);
		if (ans[roop]>b[roop])
		cout << ans[roop] << endl;
		if (ans[roop] <= b[roop]){
			if(a[0]==0){
		       	cout << b[roop]+1 << endl;
			}
			else{
			cout << b[roop] << endl;
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 1684
n,m=map(int,input().split())

l=[list(map(int,input().split())) for _ in range(m)]
d=[[float("inf")]*n for _ in range(n)]

for a,b,c in l:
  d[a-1][b-1]=c
  d[b-1][a-1]=c

for k in range(n):
  for i in range(n):
    for j in range(n):
      if i==j:d[i][j]=0
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])

ans=m
for i,(a,b,c) in enumerate(l):
  f=False
  for s in range(n):
    if d[s][a-1]+c==d[s][b-1]:
      f=True
  if f:ans-=1

print(ans)

Measured memory_bytes: 48476