akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    private static final int INF = Integer.MAX_VALUE;

    public class MinCost {
        int id, cost;

        public MinCost(int id, int cost) {
            this.id = id;
            this.cost = cost;
        }
    }

    public class Node {
        int root, cost;

        public Node(int id, int cost) {
            this.root = id;
            this.cost = cost;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();

        Node nodes[] = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node(i, sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            link(sc.nextInt(), sc.nextInt(), nodes);
        }
        sc.close();

        if (n - 1 == m) {
            System.out.println(0);
            return;
        } else if (n < 2 * (n - m - 1)) {
            System.out.println("Impossible");
            return;
        }

        Map<Integer, MinCost> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            Node node = root(i, nodes);
            int root = node.root;
            if (!map.containsKey(root) || (map.get(root).cost > nodes[i].cost)) {
                map.put(root, new MinCost(i, nodes[i].cost));
            }
        }

        long ans = 0;
        for (Map.Entry<Integer, MinCost> entry : map.entrySet()) {
            MinCost minCost = entry.getValue();
            ans += minCost.cost;
            nodes[minCost.id].cost = INF;
        }

        int cnt = 2 * (n - m - 1) - map.size();
        Arrays.sort(nodes, (o1, o2) -> o1.cost - o2.cost);
        for (int i = 0; i < cnt; i++) {
            ans += nodes[i].cost;
        }

        System.out.println(ans);
    }

    private void link(int src, int dst, Node node[]) {
        node[root(dst, node).root].root = root(src, node).root;
    }

    private Node root(int n, Node node[]) {
        int rootn = node[n].root;
        if (rootn != n) {
            node[n].root = root(rootn, node).root;
        }

        return node[n];
    }

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


Measured memory_bytes: 98460
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

class UnionFind {
protected:
  int size;
  vector<int> _leader;
  vector<int> _rank;
  
public:
  UnionFind(int s);
  int leader(int i);
  int merge(int i, int j);
};

UnionFind::UnionFind(int s) {
  size = s;
  _leader = vector<int>(size);
  for (int i = 0; i < size; i++) { _leader.at(i) = i; }
  _rank = vector<int>(size, 1);
}

int UnionFind::leader(int i) {
  int cur = i;
  int nxt = _leader.at(cur);
  vector<int> seen;
  while (cur != nxt) {
    seen.push_back(cur);
    cur = nxt;
    nxt = _leader.at(cur);
  }
  for (auto j : seen) _leader.at(j) = cur;
  return cur;
}

int UnionFind::merge(int i0, int j0) {
  int li = leader(i0);
  int lj = leader(j0);
  if (li == lj) return li;
  int ri = _rank.at(li);
  int rj = _rank.at(lj);
  if      (ri < rj)  return _leader.at(li) = lj;
  else if (ri > rj)  return _leader.at(lj) = li;
  else {
    (_rank.at(lj))++;
    return _leader.at(li) = lj;
  }
}

// ----------------------------------------------------------------------

struct DI {
  int axis;
  int idx1;
  int idx2;
  int dist;
  DI(int a, int i1, int i2, int d) : axis(a), idx1(i1), idx2(i2), dist(d) {}
  bool operator<(const DI& that) const { return dist < that.dist; }
};

int N;
vector<vector<int>> Z(2);

// dist ... list of (i, axis, dist)
//          where dist is the distance between i and the next larger point
//          in the direction of axis, sorted by dist
vector<DI> dist;


int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> N;
  Z.at(0).resize(N); Z.at(1).resize(N);
  for (int i = 0; i < N; i++) cin >> Z.at(0).at(i) >> Z.at(1).at(i);
  for (int axis = 0; axis <= 1; axis++) {
    vector<int> ordZ(N);
    iota(ordZ.begin(), ordZ.end(), 0);
    sort(ordZ.begin(), ordZ.end(),
	 [&](int p, int q) { return Z.at(axis).at(p) < Z.at(axis).at(q); });
    for (int i = 0; i < N-1; i++) {
      int idx1 = ordZ.at(i);
      int idx2 = ordZ.at(i+1);
      dist.emplace_back(axis, idx1, idx2,
			Z.at(axis).at(idx2) - Z.at(axis).at(idx1));
    }
  }
  sort(dist.begin(), dist.end());
  
  int ans = 0;
  UnionFind uf(N);
  for (DI d : dist) {
    if (uf.leader(d.idx1) == uf.leader(d.idx2)) continue;
    ans += d.dist;
    uf.merge(d.idx1, d.idx2);
  }
  cout << ans << endl;

}


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

const int maxn = 105;
int val[maxn];
int mn = 1e9, n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&val[i]);
	for(int i=1;i<=100;i++){
		int cur = 0;
		for(int j=1;j<=n;j++) cur += (i - val[j]) * (i - val[j]);
		mn = std::min(mn, cur);
	}
	printf("%d\n", mn);
	return 0;
}

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

using namespace std;

int main(){ 
	int n;
	long long int a;
	long long int cnt1[61]={0};
	
	cin >> n;
	
	long long int mod,ans=0;
	mod = 1000000007;
	
	long long int c[61];
	long long int temp=1;
	c[0]=1;
	for(int i=1;i<60;i++){
		temp = temp*2%mod;
		c[i]=temp;
	}
	
	for(int i=0;i<n;i++){
		cin >> a;
		for(int j=0;j<60;j++){
			if( a%2 == 1) cnt1[j]++;
			a = a/2;
		}
	}
	
	
	for(int i=0;i<60;i++){
		ans = (ans + (cnt1[i]*(n-cnt1[i])%mod*c[i])%mod)%mod;
		
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  	long long int N, K;
  	cin >> N >> K;
  	long long int p[N];
  	for (int i = 0; i < N; i++) cin >> p[i];
  	long long int min = 0, count = 0;
  
  	for (int i = 0; i < K; i++) min += p[i];
  	count = min;
  
  	for (int i = 0; i < N - K; i++) {
      	count = count - p[i] + p[i + K];
      	if (min < count) min = count;
    }

  	if ((min + K) % 2 == 0) cout << (min + K) / 2 << endl;
  	else printf("%.10lf\n", (double)(min + K) / 2);
}


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

string get_term(string, int&);
int get_num(string);
int get_exp(string);

int get_num(string str) {
    int num = 0;

    if (str.size() == 0) return 0;

    int i = 0;
    if (str[i] == '(') {
        i++;
        string exp;
        for (int count = 1; count; i++) {
            if (str[i] == '(') count++;
            if (str[i] == ')') count--;
            if (count) exp += str[i];
        }

        num = get_exp(exp + "=");
    } else {
        for (; i < str.size() && '0' <= str[i] && str[i] <= '9'; i++) {
            num = num * 10 + (str[i] - '0');
        }
    }

    for (; i < str.size(); i++) {
        if (str[i] == '*') {
            i++;
            int tmp = 0;
            if (str[i] == '(') {
                i++;
                string exp;
                for (int count = 1; count; i++) {
                    if (str[i] == '(') count++;
                    if (str[i] == ')') count--;
                    if (count) exp += str[i];
                }

                tmp = get_exp(exp + "=");
            } else {
                for (; i < str.size() && '0' <= str[i] && str[i] <= '9'; i++) {
                    tmp = tmp * 10 + (str[i] - '0');
                }
            }
            num *= tmp;
            i--;
        } else {
            i++;
            int tmp = 0;
            if (str[i] == '(') {
                i++;
                string exp;
                for (int count = 1; count; i++) {
                    if (str[i] == '(') count++;
                    if (str[i] == ')') count--;
                    if (count) exp += str[i];
                }

                tmp = get_exp(exp + "=");
            } else {
                for (; i < str.size() && '0' <= str[i] && str[i] <= '9'; i++) {
                    tmp = tmp * 10 + (str[i] - '0');
                }
            }
            num /= tmp;
            i--;
        }
    }

    return num;
}


void solve(string str) {
    cout << get_exp(str) << endl;
}

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

    while (N--) {
        string str;
        cin >> str;
        solve(str);
    }

    return 0;
}

string get_term(string str, int& i) {
    string init_str;
    for (int count = 0; i < str.size(); i++) {
        if (str[i] == '(') count++;
        if (count > 0 || ('0' <= str[i] && str[i] <= '9') || str[i] == '/' || str[i] == '*') {
            init_str += str[i];
        }
        if (str[i] == ')') count--;

        if (count == 0 && (str[i] == '+'|| str[i] == '-' || str[i] == '=')) {
            break;
        }
    }

    return init_str;
}

int get_exp(string str) {
    int num  = 0;
    int i = 0;

    string init_str = get_term(str, i);
    num = get_num(init_str);

    while (str[i] != '=') {
        if (str[i] == '-') {
            i++;
            string term = get_term(str, i);
            num -= get_num(term);
        } else if (str[i] == '+') {
            i++;
            string term = get_term(str, i);
            num += get_num(term);
        }
    }

    return num;
}

Measured memory_bytes: 3216
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
l = len(s)
if list(s) != list(reversed(s)):
    print('No')
    exit()
if list(s[:(l - 1) // 2]) != list(reversed(s[:(l - 1) // 2])):
    print('No')
    exit()
if list(s[(l + 3) // 2 - 1:l]) != list(reversed(s[(l + 3) // 2 - 1:l])):
    print('No')
    exit()
print('Yes')

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

long long c[255];

int main () {

    string s; cin >> s;
    long long n = s.size();

    long long ans = n*(n+1)/2;
    for (int i=0; i<n; i++) c[ s[i] ]++;
    for (int i='a'; i<='z'; i++) ans -= c[i]*(c[i]+1)/2;
    ans = ans+1;
    cout << ans << endl;
}


Measured memory_bytes: 640
import string
import collections
a=string.ascii_letters
l=[]

while True:
    try:
        n=list(input())
        l+=n
    except:
        break
    
c = collections.Counter(l)
for i in range(26):
    print(a[i]+" : "+str(c[a[0+i]]+c[a[26+i]]))



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


int dp[100000][3];
int N;

int main(){
    cin >> N;
    int a, b, c;
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;

    for(int i = 1; i < N; i++){
        int abc[3];
        cin >> abc[0] >> abc[1] >> abc[2];
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j != k){
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[j]);
                }
            }
        }
    }

    cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
   ll N,K;
   cin>>N>>K;
   ll ans=0;
   for(ll i=0;i<N;i++) {
       ll x;
       cin>>x;
       ans+=min(x,K-x);
   }
   cout<<2*ans<<endl;


   }


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n, l, p, f[320][320];
int main() {
	scanf("%d%d%d", &n, &l, &p);
	f[0][0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = i; k >= 0; k--) {
				if (k) {
					f[j][k - 1] = (f[j][k - 1] + f[j][k]) % p;
				} else {
					f[j + 1][i] = (f[j + 1][i] + f[j][k]) % p;
				}
				f[j][k] = f[j][k] * (k + 1LL) % p;
			}
		}
	}
	printf("%d\n", f[l][n]);
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,a[N],u,v,ans[N];
vector <int> adj[N];
multiset <int> s;

void dfs(int node,int parent=0)
{
	s.insert(a[node]);
	int del=-1;
	auto it=s.lower_bound(a[node]);
	if(++it!=s.end()) del=*it,s.erase(it);
	ans[node]=s.size();
	
	for(auto child:adj[node])
		if(child!=parent) dfs(child,node);
	
	if(del!=-1) s.insert(del);
	s.erase(s.find(a[node]));
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(1);
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 33508
#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 a[3];
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
	return 0;
}

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

vector<long long> input(long long N) {
  vector<long long> res(N);
  for (int i = 0; i < N; i++) {
    cin >> res.at(i);
  }
  return res;
}

int main(){
    long long N, A, B;
    long long sum = 0;
    cin >> N >> A >> B;
    vector<long long> X(N);
    X = input(N);
    for(int i = 1; i < N; i++)sum += min(A * (X[i] - X[i - 1]), B);
    cout << sum << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Rolling Hash
//-------------------------------------------------
using ull = unsigned long long;
using Hash = vector<ull>;

const int M_NUM = 4;
const ull mod[4] = {(ull)1e9+33,(ull)1e9+87,(ull)1e9+93,(ull)1e9+97};
const ull base = 9973;

class RollingHash
{
private:
    int n;
    vector<ull> _hash[4], _pow[4];
public:
    RollingHash(const string &s){
        n = s.size();
        for(int i=0; i<M_NUM; i++){
            _hash[i].resize(n+1); _hash[i][0] = 0;
            _pow[i].resize(n+1); _pow[i][0] = 1;
            for(int j=0; j<n; j++){
                _pow[i][j+1] = (_pow[i][j]*M_NUM)%mod[i];
                _hash[i][j+1] = (_hash[i][j]*M_NUM+s[j])%mod[i];
            }
        }
    }
    bool match(int l, int r, Hash h){
        bool ret=true;
        for(int i=0; i<M_NUM; i++){
            ull value = _hash[i][r]-(_hash[i][l]*_pow[i][r-l])%mod[i];
            value = (value+mod[i])%mod[i];
            ret&=(value==h[i]);
        }
        return ret;
    }
    vector<int> matches(Hash h, int w){
        vector<int> ret;
        for(int i=0; i<n-w+1; i++)
            if (match(i,i+w,h)) ret.push_back(i);
        return ret;
    }
    static Hash hash(const string &s){
        Hash ret(M_NUM);
        for(int i=0; i<M_NUM; i++)
            for(int j=0; j<s.size(); j++)
                ret[i]=(ret[i]*M_NUM+s[j])%mod[i];
        return ret;
    }
};


//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    int w = t.size();
    RollingHash rh(s);
    Hash pat = RollingHash::hash(t);
    auto ms = rh.matches(pat,w);
    for(auto e:ms){
        cout<<e<<"\n";
    }
    return 0;
}



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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	puts(s.substr(0, 4) == "YAKI" ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 764
N = gets.to_i
S = gets.chomp
A = S.split("")
a = Array.new
for i in 0..N-1
    if i == 0 
        if A[i] == 'I'
            a[i] = 1
        elsif A[i] == 'D'
            a[i] = -1
        end
    else
        if A[i] == 'I'
            a[i] = a[i-1] + 1
        else A[i] == 'D'
            a[i] = a[i-1] - 1
        end
    end
end
if a.max > 0
    puts a.max
else 
    puts 0
end


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


int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v.at(i);
    }
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (v.at(i) != i+1) {
            cnt += 1;
        }
    }
    if (cnt == 2 || cnt == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}


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

int main(void){
  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    string event;
    int outCnt = 0, fb = 0, sb = 0, tb = 0, score = 0;
    while(outCnt != 3 && cin >> event){
      if(event == "HIT") { score += tb; tb = sb; sb = fb; fb = 1; }
      if(event == "HOMERUN") { score += fb + sb + tb + 1; fb = 0; sb = 0; tb = 0;};
      if(event == "OUT") outCnt++;
    }
    cout << score << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		for(int i = 0; i < str.size(); ++i)
		{
			if(str[i] == '@')
			{
				for(int j = 0; j < str[i + 1] - '0'; ++j)
				{
					cout << str[i + 2];
				}
				i += 2;
			}
			else
			{
				cout << str[i];
			}
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 1172
N = int(input())
Ln = [int(i) for i in input().split()]

def exist(l1, l2, l3):
    array = [l1, l2, l3]
    array.sort()
    return array[0] + array[1] > array[2]

count = 0
for i in range(N - 2):
    Li = Ln[i]
    for j in range(i + 1, N - 1):
        Lj = Ln[j]
        if Li == Lj:
            continue
        for k in range(j + 1, N):
            Lk = Ln[k]
            if Li == Lk or Lj == Lk:
                continue
            if exist(Li, Lj, Lk):
                count += 1

print(count)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	double n; cin >> n;
	double k; cin >> k;
	double ans = 0;
	for(ll i = 1; i <= n; ++i){
		ll cnt = 0, tmp = i;
		while(tmp < k){
			tmp *= 2;
			cnt++;
		}
		ans += (double(1) / double(n)) * double(pow((double(1)/ double(2)), double(cnt)));
	}
	cout << setprecision(12) << ans;
	cout << fixed;
    return 0;
}


Measured memory_bytes: 4176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	int n,b;
	int a[3][3];
	bool c[3][3]={false};
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cin>>n;
	for(int k=0;k<n;k++){
		cin>>b;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(a[i][j]==b){
					c[i][j]=true;
				}
			}
		}
	}
	bool ch=false;
	for(int i=0;i<3;i++){
		if(c[0][i]&&c[1][i]&&c[2][i]){
			ch=true;
		}
		if(c[i][0]&&c[i][1]&&c[i][2]){
			ch=true;
		}
	}
	if(c[0][0]&&c[1][1]&&c[2][2]){
		ch=true;
	}
	if(c[2][0]&&c[1][1]&&c[0][2]){
		ch=true;
	}
	if(ch){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 123456;
int f[maxn + 10];
int main(){
  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    f[x]++;
  }
  int ans = 0;
  for(int i = 0; i < maxn; i++) ans = max(ans, f[i] + f[i + 1] + f[i + 2]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <sstream>
#include <deque>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <utility>   // std::pair, std::make_pair
#include <stdlib.h>  //atoi
using namespace std;
typedef long long ll;
const  double PI = 3.141592654;
#define rep(i,x) for(int(i)=0;(i)<(ll)(x);(i)++)
#define all(s)      (s).begin(),(s).end()
#define allv(v)      (v).begin(),(v).end()
#define pb          push_back
#define sz          s.size()
#define vz          v.size()
//x = atoi(a.c_str())
void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main()
{
	fast();
	int x, y;
	cin >> x;
	y = 24 - x;
	y += 24;
	cout << y << endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 10;

int n;
LL res;
priority_queue<double, vector<double>, greater<double> > heap;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        heap.push(x);
    }

    while(heap.size() > 1)
    {
        double a = heap.top();
        heap.pop();
        double b = heap.top();
        heap.pop();
        heap.push((a + b) / 2);
    }

    printf("%f\n", heap.top());

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

input = sys.stdin.readline
MAX_A = 10 ** 6


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    divisible = [False] * (MAX_A + 1)
    ans = 0
    for k, v in Counter(A).items():
        if v == 1 and not divisible[k]:
            ans += 1
        for i in range(k, MAX_A + 1, k):
            divisible[i] = True

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44956
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>=MOD){
		a -= MOD;
	}
}

int main(void){
	int n,k,c=0,i,l=0,r,ans=0;
	string s;
	cin >> n >> k;
	cin >> s;
	s.push_back('@');
	c = (s[0]=='0');
	for(r=1; r<=n; ++r){
		ans = max(ans,r-l);
		if(s[r-1]=='1'&&s[r]=='0'){
			++c;
		}
		while(c>k){
			if(s[l]=='0' && s[l+1]=='1'){
				--c;
			}
			++l;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	N, _ := strconv.Atoi(nextLine())
	s_line := strings.Split(nextLine(), " ")

	C := make([]Card, 0)
	for _, s := range s_line {
		sign := s
		value, _ := strconv.Atoi(string(s[1]))
		c := Card{sign: sign, value: value}
		C = append(C, c)
	}

	sort_b := make([]Card, len(C))
	copy(sort_b, C)
	sort_b, _ = bubbleSort(sort_b, N)

	sort_s := make([]Card, len(C))
	copy(sort_s, C)
	sort_s, _ = selectionSort(sort_s, N)

	m_origin := same_value(C)
	b_origin := signed_order(sort_b)

	stable := true
	for k, v := range b_origin {
		s := m_origin[k]
		// fmt.Printf("s=%s, v=%s\n", strings.Join(s, " "), strings.Join(v, " "))
		if !reflect.DeepEqual(s, v) {
			stable = false
			break
		}
	}

	fmt.Println(stringify(sort_b))
	if stable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	s_origin := signed_order(sort_s)
	stable = true
	for k, v := range s_origin {
		s := m_origin[k]
		// fmt.Printf("s=%s, v=%s\n", strings.Join(s, " "), strings.Join(v, " "))
		if !reflect.DeepEqual(s, v) {
			stable = false
			break
		}
	}

	fmt.Println(stringify(sort_s))
	if stable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

type Card struct {
	sign  string
	value int
}

func stringify(C []Card) string {
	r := make([]string, len(C))
	for i, v := range C {
		r[i] = v.sign
	}
	return strings.Join(r, " ")
}

func bubbleSort(C []Card, N int) ([]Card, int) {
	count := 0
	flag := 1

	for flag == 1 {
		flag = 0
		for j := N - 1; j > 0; j-- {
			if C[j].value < C[j-1].value {
				tmp := C[j]
				C[j] = C[j-1]
				C[j-1] = tmp
				flag = 1
				count++
			}
		}
	}
	return C, count
}

func selectionSort(C []Card, N int) ([]Card, int) {

	count := 0
	for i := 0; i < N; i++ {
		minj := i
		for j := i; j < N; j++ {
			if C[j].value < C[minj].value {
				minj = j
			}
		}

		// changed value i
		if i != minj {
			count++
		}

		tmp := C[i]
		C[i] = C[minj]
		C[minj] = tmp
	}

	return C, count
}

func signed_order(C []Card) map[int][]string {

	m := make(map[int][]string, 0)

	prev := C[0]
	for i := 1; i < len(C); i++ {
		if prev.value == C[i].value {
			if len(m[C[i].value]) == 0 {
				m[C[i].value] = append(m[C[i].value], prev.sign)
			}
			m[C[i].value] = append(m[C[i].value], C[i].sign)
		}
		prev = C[i]
	}
	return m
}

func same_value(C []Card) map[int][]string {
	m := map[int][]string{}

	for _, v := range C {
		m[v.value] = append(m[v.value], v.sign)
	}
	return m
}



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

using namespace std;

int main(){
    long long mincost = 4000000, cur = 0;
    int n;
    cin >> n;
    int arr[n];
    for(int one = 0; one < n; one++){
        cin >> arr[one];
    }
    for(int one = -100; one < 101; one++){
        cur = 0;
        for(int two = 0; two < n; two++){
            long long x = (arr[two] - one)*(arr[two] - one);
            cur += x;
        }
        mincost = min(cur, mincost);
    }
    cout << mincost;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include<queue>
#include<stack>

using namespace std;

int a, b, k;
int m = 100000;
int answer;
vector<int>V;

int main(){
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i = 1; i <= min(a, b); ++i){
    if(a % i == 0 && b % i == 0){
      cnt++;
      V.push_back(i);
      //cout << i << endl;
    }
  }
  cout << V[cnt - k] << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string impossible;

mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
// const int N=6;
const int N=1e5+5;
const int L=31;
ll mod=1e12+7;
ll n,i,j,k,x,m,b,a,da,db,u,v;
bool f0,f1,f2;
const int MAXN=1e6+5;
string s;
int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
    cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    for(int te=1;te<=tests;te++){
        cin>>x;
        cout<<1-x;
    }
    return 0;
}





Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int in()
{
	int x;cin>>x;
	return x;
}
int stringInt(string a)
{
	return atoi(a.c_str());
}
string intString(int a)
{
	stringstream ss;
	ss<<a;
	return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
	vector<int> a;
	vector<int> b(x+1,0);
	for(int i=2;i<=x;i++)
	{
		if(b[i]==0)
		{
			a.push_back(i);
			for(int l=i;l<=x;l+=i)
			{
				b[l]=1;
			}
		}
	}
	return a;
}

struct Node
{
	int k;
	Node *p,*r,*l;
};
Node *root,*NIL;

void ins(int k)
{
	Node *y,*x,*z;
	z=(Node*)malloc(sizeof(Node));
	z->k=k;
	z->l=z->r=NIL;
	y=NIL;
	x=root;
	while(x!=NIL)
	{
		y=x;
		if(x->k > k)
		{
			x=x->l;
		}
		else
		{
			x=x->r;
		}
	}
	z->p=y;
	if(y==NIL)
	{
		root=z;
	}
	else if(z->k < y->k)
	{
		y->l=z;
	}
	else
	{
		y->r=z;
	}
	return ;
}
void ino(Node* root)
{
	if(root==NIL)return ;
	ino(root->l);
	cout<<" "<<root->k;
	ino(root->r);
	return ;
}
void pre(Node* root)
{
	if(root==NIL)return ;
	cout<<" "<<root->k;
	pre(root->l);
	pre(root->r);
	return ;
}
Node* fin(Node* root,int x)
{
	while(root!=NIL&&root->k!=x)
	{
		if(x>root->k)
		{
			root=root->r;
		}
		else root=root->l;
	}
	return root;

}
Node* getMi(Node* a)
{
	while(a->l!=NIL)
		a=a->l;
	return a;
}
Node* getSuccessor(Node* a)
{
	if(a->r!=NIL)return getMi(a->r);


	Node* y= a->p;
	while(y!=NIL&&a==y->r)
	{
		a=y;
		y=y->p;
	}
	return y;
}

void del(Node* z)
{
	Node *y,*x;
	if(z->l==NIL||z->r==NIL)y=z;
	else y=getSuccessor(z);

	if(y->l!=NIL)x=y->l;
	else x=y->r;

	if(x!=NIL)x->p=y->p;

	if(y->p==NIL)root=x;
	else
	{
		if(y==y->p->l)y->p->l=x;
		else y->p->r=x;;
	}
	if(y!=z)z->k=y->k;
	free(y);
}
int main()
{
	int n;
	root=NIL;
	cin>>n;
	rep(i,n)
	{
		string a;
		cin>>a;
		switch(a[0])
		{
		case'i':
			ins(in());
			break;
		case'p':

			ino(root);cout<<endl;
			pre(root);cout<<endl;
			break;
		case'f':
			if(fin(root,in())!=NIL)cout<<"yes"<<endl;
			else cout<<"no"<<endl;
			break;
		case'd':
			del(fin(root,in()));
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 19964
// Getting Started - Insertion Sort
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A
using System;
using System.Linq;

namespace ALDS1_1_A {
	class Program {
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var N = int.Parse(Input);	// Number of elements
			var A = Input				// Array : N elements
					.Split(' ')
					.Select(i => int.Parse(i))
					.ToArray();
			
			for(int i = 0; i < N; i++) {
				int target = A[i];
				int j = i;
				
				for(; j > 0 && target <= A[j-1]; j--)
					A[j] = A[j-1];
				A[j] = target;
				
				Output(A.Select(s => s.ToString())
						.Aggregate((s, t) => s + " " + t));
			}
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}
	}
}

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

long long int lcmat(long long int a, long long int b)
{
 
  long long int r, tmp;
  long long int x;
 
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return x / b;
}

int main(){
  long long int A, B, C, D, DivC, DivD, DivCD;
  cin >> A >> B >> C >> D;

  if(A % C == 0){
    DivC = B/C - A/C + 1;
  }else{
    DivC = B/C - A/C;
  }

  if(A % D == 0){
    DivD = B/D - A/D + 1;
  }else{
    DivD = B/D - A/D;
  }

  long long int lcmcd = lcmat(C,D);
  if(A % lcmcd == 0){
    DivCD = B/(lcmcd) - A/(lcmcd) + 1;
  }else{
    DivCD = B/(lcmcd) - A/(lcmcd);
  }

  cout << B - A + 1 -(DivC + DivD - DivCD) << endl;
}

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

int main() {
    vector<int> x(5);
    for (int i=0; i<5; i++) {
        cin >> x.at(i);
    }
    for (int i=0; i<5; i++) {
        if(x.at(i) == 0) {
            cout << i+1 << endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
double kaku(double x,double y){
    if(x==0){
        if(y>=0)return pi/2.0;
        else return 3*pi/2.0;
    }
    else{
        double ret=atan(y/x);
        if(x<0)ret+=pi;
        else if(y<0)ret+=2*pi;
        return ret;
    }
}
double dist(double a,double b,double c,double d){
    return pow(((a-c)*(a-c)+(b-d)*(b-d)),0.5);
}
int main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    double x[n],y[n];
    double ka[n];
    vector<double> v;
    rep(i,0,n){
        scanf("%lf %lf",&x[i],&y[i]);
        ka[i]=kaku(x[i],y[i]);
        v.push_back(ka[i]);
    }
    vector<double> w;
    
    double noww=kaku(50000,1);
    double e=0;
    for(;;){
        w.push_back(e);
        e+=noww;
        if(e>=2*pi)break;
    }
    double di[n];
    rep(i,0,n)di[i]=dist(x[i],y[i],0,0);
    double ans=0;
    rep(j,0,w.size()){
        double now=w[j];
        double sum=0;
        rep(i,0,n){
            double si=ka[i];
            double sa=si-now;
            double r=di[i];
            r*=cos(sa);
            if(r>0)sum+=r;
        }
        ans=max(ans,sum);
    }
    
    cout<<fixed<<setprecision(15)<<ans<<endl;
    
}




Measured memory_bytes: 6516
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll N, T;
	ll m = 99999;
	REP(i, N)
	{
		inll c, t;
		if (t <= T)
		{
			m = min(m, (ll)c);
		}
	}

	if (m == 99999) {
		return OUT("TLE");
	}else {
		return OUT(m);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>


int main() {


    double W, H, x, y;
    std::cin >> W >> H >> x >> y;

    std::cout << std::setprecision(10) << (0.5 * W * H) << "\n";

    if (((W * 0.5) == x) and ((H * 0.5) == y)) {
        std::cout << '1' << "\n";
    } else {
        std::cout << '0' << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner input =new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int k=input.nextInt();
		int n=input.nextInt();
		int[] arr=new int[n];
		for(int i =0 ;i<n ;i++) {
			arr[i]=input.nextInt();
		}
		int[] diff=new int[n];
		for(int i=0;i<n-1;i++) {
			diff[i]=arr[i+1]-arr[i];
		}
		diff[n-1]=arr[0]+(k-arr[n-1]);
		Arrays.sort(diff);
		pw.print(k-diff[n-1]);
		pw.close();
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}


Measured memory_bytes: 48160
package main

import "fmt"

func main()  {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	b := make([]int, N)

	for i := range a {
		fmt.Scan(&a[i])
	}

	var sum int
	var f int
	for i:=N; i>0; i-- {
		sum = 0
		for j:=1; j*i<=N; j++ {
			sum += b[j*i - 1]
		}
		if sum%2 != a[i-1] {
			b[i-1]++
			f++
		}
	}
	if f > 0 {
		fmt.Println(f)
	} else {
		fmt.Println(0)
	}
	for i := range b {
		if b[i] == 1 {
			fmt.Printf("%d ", i+1)
		}
	}
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll h, w;
    cin >> h >> w;
    if(h < w) swap(h, w);
    if(w == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = ll(w/2) * ll(h/2) + ll((w+1)/2) * ll((h+1)/2);
    cout << ans << endl;
	return 0;
}


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

int main() {
  int a;
  int b;
  int c;
  int d;
  int e;
  cin >> e;
    a = e / 1000;
    b = (e - a * 1000) / 100;
    c = (e - a * 1000 - b * 100) / 10;
    d = e - a * 1000 - b * 100 - c * 10;
if (a == b) {
	if (b == c) {
      cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
}
}
  else if (b == c) {
    if (c == d) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
    else {
      cout << "No" << endl;
   }
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
using namespace std;
typedef long long ll;

const int MAXN = 2e5+1;
ll A[26];
int main(){
  string s; cin >> s;
  ll ans=0;
  ans+=SZ(s);
  ans=ans*(ans+1LL)/2LL;
  fore(x,0,SZ(s)){
    A[s[x]-'a']++;
    ans -= A[s[x]-'a'];
  }
  cout << ans +1<< "\n";
}


Measured memory_bytes: 640
fun main(args : Array<String>) {
    val (a1, a2, a3) = readLine()!!.split(" ").map { it.toInt() }
    val allList = listOf(
            Triple(a1, a2, a3),
            Triple(a1, a3, a2),
            Triple(a2, a1, a3),
            Triple(a2, a3, a1),
            Triple(a3, a1, a2),
            Triple(a3, a2, a1)
    )
    val minCost = allList.map {
        val (x1, x2, x3) = it
        x1 * 0 + Math.abs(x2 - x1) + Math.abs(x3 - x2)
    }.min()

    println(minCost)
}

Measured memory_bytes: 37796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;cin>>S>>T;
  string ans="No";
  for(int i=0; i<S.size(); i++){
    S=S.substr(1,S.size()-1)+S.substr(0,1);
    if(S==T)ans="Yes";
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const int mod = 1e9 + 7;
const int N = 3e5 + 17;

int n, m;
int a[N], up[N][25];

int get(int l, int r) {
	int ans = 0;
	for (int i = 19; i >= 0; i--) {
	    int p = up[r][i];
//		cout << i << " " << r << " " << p << endl;
	    if (p > l) {
	    	ans += (1 << i);
	    	r = p;
	    }
	}
	return ans + 1;	
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int l = 0, L; cin >> L;
	for (int i = 0; i < n; i++) {
		while (a[i] - a[l] > L) l++;
		up[i][0] = l;
		for (int j = 1; j < 20; j++)
			up[i][j] = up[up[i][j - 1]][j - 1];
	}
	cin >> m;
	while (m--) {
		int l, r; cin >> l >> r;
		l--; r--;
		if (r < l) swap(l, r);
		cout << get(l, r) << endl;
	}
}


Measured memory_bytes: 13784
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1000000007;
main(){
    int n;
    scanf("%lld",&n);
    int two[n+1];
    two[0] = 1;
    for (int i = 1; i <= n; i++){
        two[i] = two[i-1]*2;
        two[i] %= mod;
    }
    int c[n];
    for (int i = 0; i < n; i++){
        scanf("%lld",&c[i]);
    }
    sort(c,c+n);
    long long ans = 0;
    for (int i = 0; i < n; i++){
        int ct = n-i-1;
        long long multi = ct == 0 ? 0 : (two[ct-1]*ct)%mod;
        multi *= two[i]; multi %= mod;
        //printf("%lld add on to %d\n",multi,two[n-1]);
        multi += two[n-1]; multi %= mod;
        long long toadd = (multi*c[i])%mod;
        //printf("%lld %lld\n",multi,toadd);
        ans += toadd;
        ans %= mod;
    }
    ans *= two[n]; ans %= mod;
    printf("%lld",ans);

}


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


int main() {
  int K;
  cin>>K;
  int t=0;
  for(int i=1;i<=K;i++) {
    for(int j=1;j<=K;j++) {
      for(int k=1;k<=K;k++) {
        t+=gcd(i,gcd(j,k));
      }
    }
  }
  cout<<t<<endl;
}
      

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,K;
    cin>>N>>K;
    ll p[200001];
    p[0] = 0;
    Rep(i,N) cin>>p[i];
    Rep(i,N) p[i] += p[i-1];
    ll max_val=0;
    rep(i,N-K+1){
        max_val = max(max_val, p[i+K]-p[i]+K);
    }
    cout<<fixed;
    cout<< setprecision(3)<<((double) max_val) / 2.0 <<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

int main() {
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define g 9.8

/* prototype declaration */
double getTime(double v);
double getHeight(double t);
int getFloor(double h);

int main(int argc, const char *argv[])
{
	double velocity, time;
	while(scanf("%lf", &velocity)!=EOF){
		time = getTime(velocity);
		printf("%d\n", getFloor(getHeight(time)));
	}	
	return 0;
}

double getTime(double v)
{
	return v/g;
}

double getHeight(double t)
{
	return 4.9*t*t;
}

int getFloor(double h)
{
	int i;
	for(i=0; i<h; i+=5);
	return i/5+1;
}

Measured memory_bytes: 0