akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main(){
	var N,M,X,Y int
	fmt.Scan(&N,&M,&X,&Y)
	x := make([]int,N)
	y := make([]int,M)
	for i:=0;i<N;i++{
		fmt.Scan(&x[i])
	}
	for i:=0;i<M;i++ {
		fmt.Scan(&y[i])
	}
	xmax := x[0]
	ymin := y[0]

	for i:=0;i<N;i++{
		if xmax < x[i]{
			xmax = x[i]
		}

	}

	for i:=0;i<M;i++{
		if ymin > y[i]{
			ymin = y[i]
		}
	}

	if xmax < ymin && X < xmax+1 && xmax+1 <= Y {
		fmt.Println("No War")
	}else {
		fmt.Println("War")
	}

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())

#define INF 1e12

using Coordinate = pair<Int, Int>;

int main() {
    Int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;
    auto s = vector<string>();
    rep(i, h) {
        string x;
        cin >> x;
        s.PB(x);
    }
    auto t = vector<vector<Int>>(h, vector<Int>(w, INF));

    auto compare = [&](const Coordinate &p1, const Coordinate &p2) -> bool {
        return t[p1.F][p1.S] > t[p2.F][p2.S];
    };

    priority_queue<Coordinate, vector<Coordinate>, decltype(compare)> q(compare);

    q.push(MP(ch, cw));

    t[ch][cw] = 0;

    auto test = [&](Int x, Int y, Int new_v) {
        if (0 <= x && x < h && 0 <= y && y < w && s[x][y] == '.') {
            auto old_v = t[x][y];
            if (new_v < old_v) {
                t[x][y] = new_v;
                q.push(MP(x, y));
            }
        }
    };

    while (SZ(q) > 0) {
        auto p = q.top();
        q.pop();
        auto x = p.F;
        auto y = p.S;
        auto v = t[x][y];
        test(x - 1, y, v);
        test(x + 1, y, v);
        test(x, y - 1, v);
        test(x, y + 1, v);

        rep(i, 5) {
            rep(j, 5) {
                test(x - 2 + i, y - 2 + j, v + 1);
            }
        }
    }

    auto ans = t[dh][dw];
    PUTS(ans == INF ? -1 : ans)
}


Measured memory_bytes: 12508
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main() {
  int A, B, ans, i;// A: 8%  B: 10%
  double a, b;
  scanf("%d %d", &A, &B);
  for(i = 1; i <= 1000; i++){
    a = i * 0.08; b = i * 0.1;
    if((int)a == A && (int)b == B) {
      ans = i;
      i = -1;
      break;
    }
  }
  if(i != -1){
    ans = -1;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))
P = [0] + [-1] * (len(H)-1)

def minv(i, v):
  if i < len(H):
    cost = v()
    if P[i] < 0:
      P[i] = cost
    else:
      P[i] = min(P[i], cost)

for i in range(len(H)-1):
  minv(i + 1, lambda : P[i] + abs(H[i] - H[i+1]))
  minv(i + 2, lambda : P[i] + abs(H[i] - H[i+2]))

print(P[-1])


Measured memory_bytes: 13908
#include<bits/stdc++.h>
#define for(i,i0,n) for(i=i0;i<n;i++)
#define ford(i,i0,n) for(i=i0;i>n;i--)
#define lli long long int
using namespace std;
int main(){
int n;
cin>>n;
if(n%2==0) cout<<n/2;
else cout<<n/2+1;
return 0;
}


Measured memory_bytes: 256
n = gets.to_i
h = gets.chomp.split(" ").map(&:to_i)
dp = Array.new(n) { nil }
dp[0] = 0
dp[1] = (h[1] - h[0]).abs
2.upto(n - 1) do |i|
  dp[i] = [dp[i - 1] + (h[i] - h[i - 1]).abs, dp[i - 2] + (h[i] - h[i - 2]).abs].min
end
puts dp[n - 1]

Measured memory_bytes: 11780
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define sd(x)   scanf("%g",&x)
#define ss(s)	scanf("%s",s)
#define pd(x)   printf("%g\n",x)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define nline   printf("\n")
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define fitr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int main()
{
    int d,s,t;
    si(d);si(t);si(s);
    if((s*t)>=d)
    printf("Yes");
    else
    {
        printf("No");
    }
    
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

bool used[10];
vector<pint> vp[10];
int d[10];
int inf=1000100010;
int main(){
    int r,h,w;
    cin>>h>>w;
    rep(i,10)rep(j,10){
        cin>>r;
        vp[j].pb(mp(r,i));
    }
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,10) d[i]=inf;
    d[1]=0;
    pq.push(make_pair(0,1));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        for(vector<pint>::iterator it=vp[t].begin();it!=vp[t].end();++it){
            if(d[it->second]>d[t]+it->first){
                d[it->second]=d[t]+it->first;
                pq.push(make_pair(d[it->second],it->second));
            }
        }
    }
    int ans=0;
    rep(i,h)rep(j,w){
        cin>>r;
        if(r>=0)ans+= d[r];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> sum = {0};
    for(int i = 0; i < n; ++i) {
      int K;
      cin >> K;
      sum.push_back((sum.back() + (K % m)) % m);
    }
    int answer = 0;
    set<int> used = {m};
    for(auto j: sum) {
      answer = max(answer, (j - *used.lower_bound(j) + m) % m);
      used.insert(j);
      used.insert(j + m);
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 3716
#include<iostream>
#include<algorithm>
#include<cstring>
#define INF 987654321
void DFS(int idx, int cnt, int K);
int map[13][13];
using namespace std;
int visit[13], sumLines[13];
int N, M, X, ans=INF;
int main(){
	cin >> N >> M >> X;
	for(int i=1; i<=N; i++){
		for(int j=0; j<=M; j++){
			cin >> map[i][j];
		}
	}
	
	for(int i=1; i<=N; i++){
		memset(visit, 0, sizeof(visit));
		DFS(1, 0, i);
	}
	if(ans >= INF){
		cout << "-1";
		return 0;
	} else cout << ans;
}

void DFS(int idx, int cnt, int K){
	if(cnt == K){
		memset(sumLines, 0, sizeof(sumLines));
		int costSum = 0;
		for(int i=1; i<=N; i++){
			if(visit[i]) {
				costSum += map[i][0];
				for(int j=1; j<=M; j++){
					sumLines[j] += map[i][j];
				}
			}
		}
		for(int i=1; i<=M; i++){
			if(sumLines[i] < X) return;
		}
		ans = min(costSum, ans);
		return;
	}
	for(int i=idx; i<=N; i++){
		if(!visit[i]){
			visit[i] = 1;
			DFS(i, cnt+1, K);
			visit[i] = 0;
		}
	}
}

int getSumLine(int lineNum){
}

Measured memory_bytes: 3140
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	string key="keyence";
	int N=S.size();
	rep(i,N){
		for(int saizu=0;saizu<=N-i;saizu++){
			string A,B;
			if(i!=0) A=S.substr(0,i);
			else A="";
			if(i+saizu<N) B=S.substr(i+saizu);
			else B="";
			if(A+B==key){
				prin("YES");
				return 0;
			}
		}
	}
	prin("NO");
	//prin(S.substr(0,7));
	//prin(S.substr(8,1));
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
y=[]
if n>=m:
    print(0)
    exit()
for i in range(m-1):
    y.append(x[i+1]-x[i])
z=sorted(y,reverse=True)
count=0
for i in range(n-1):
    count+=z[i]
print(x[-1]-x[0]-count)

Measured memory_bytes: 13960
import java.util.*

val sc = Scanner(System.`in`)
val H = sc.nextInt()
val W = sc.nextInt()
val S = Array(H) { sc.next() }

fun main(args: Array<String>) {
    val cntA = Array(H) { Array(W) { 0 } }
    for (i in 0 until H) {
        for (j in 0 until W) {
            if (S[i][j] == '#') {
                cntA[i][j] = 10
                for (y in -1..1) {
                    for (x in -1..1) {
                        if (i + y in 0 until H && j + x in 0 until W) {
                            cntA[i + y][j + x]++
                        }
                    }
                }
            }
        }
    }
    for (i in 0 until H) {
        for (j in 0 until W) {
            if (cntA[i][j] >= 10) {
                print('#')
            } else {
                print(cntA[i][j])
            }
        }
        println()
    }
}


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

int main(){
    int n, a;
    vector<int> A;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a;
        A.push_back(a);
    }

    for(int x : A){
        if(x%2==0){
            if(x%3==0 || x%5 == 0){
                continue;
            } else {
                cout<<"DENIED\n";
                return 0;
            }
        }
    }

    cout<<"APPROVED\n";
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long GCD(long long A, long long B) {
	if (B == 0) return A;
	else return GCD(B, A % B);
}
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long long ans = A.at(0);
	for (long long i = 1; i < N; i++) {
		ans = GCD(ans, A.at(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import math
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
ans = 0
for y in range(n):
    for z in range(y+1, n):
        temp = 0
        for i in range(d):
            temp += (x[y][i] - x[z][i])**2
        if float(math.sqrt(temp)).is_integer():
            ans += 1
print(ans)

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

int main() {
    ll n, a, b, ans;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0) ans = (b - a) / 2;
    else ans = (b - a - 1) / 2 + min(a, n - b + 1);
        
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto N = readln.split[0].to!int;
  auto p = readln.split.to!(int[]);

  auto ctr = 0;
  foreach(i, pi; p) {
    if(pi != i+1) ctr++;
  }
  if(ctr == 0 || ctr == 2) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;
	long double ans=0;
	for(int i=1; i<=n; i++) {
		int a; cin>>a;
		ans+=((double)1/a);
	}
	long double aa=(double)1/ans;
	cout<<fixed<<setprecision(6)<<aa<<endl;


	return 0;
}


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

long long a, b, k;

int main()
{
	cin >> a >> b >> k;
	if (a > k)
	{
		a -= k;
		k = 0;
	}
	else {
		k -= a;
		a = 0;
	}
	if (b > k)
	{
		b -= k;
	}
	else
	{
		b = 0;
	}
	cout << a <<" "<< b;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
candies = list(map(int, input().split()))

MOD = int(pow(10, 9) + 7)

dp = [[0 for i in range(K+1)] for i in range(N+1)]
dp[0] = [1 for i in range(K+1)]

for c in range(1, N+1):
    for r in range(K, -1, -1):
        lo = dp[c - 1][r]
        hi = dp[c - 1][r + candies[c - 1] + 1] if r + candies[c - 1] + 1 <= K else 0
        dp[c][r] = (lo - hi) + (dp[c][r+1] if r + 1 <= K else 0)
        dp[c][r] %= MOD

def pprint(table):
    for i, row in enumerate(table):
        print([row[j] - row[j+1] for j in range(K)] + [row[K]])

# pprint(dp)

print((dp[N][0] - (dp[N][1] if K > 0 else 0)) % MOD)


Measured memory_bytes: 173448
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    ll N;
    cin >> N;
    vector<ll>cnt(256, 999);
    for(ll i = 0; i < N; i++){
        vector<ll>tmp(256, 0);
        string s;
        cin >> s;
        for(ll j = 0; j < s.size(); j++)tmp[s[j]]++;
        for(ll j = 0; j < 256; j++)chmin(cnt[j], tmp[j]);
    }
    for(char c = 'a'; c <= 'z'; c++){
        for(ll i = 0; i < cnt[c]; i++)cout << c;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;



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

	int INF = 101010;
	vector< vector<int> > dist(100, vector<int>(100,INF));
	vector< vector<int> > v(M,vector<int>(3,0));
	rep(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		dist[a][b] = c;
		dist[b][a] = c;
		v[i][0] = a;
		v[i][1] = b;
		v[i][2] = c;
	}

	rep(i, 0, 100) {
		rep(j, 0, 100) {
			if (i == j) {
				dist[i][j] == 0;
			}
		}
	}




	rep(k, 0, N) {
		rep(i, 0, N) {
			rep(j, 0, N) {
				dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}

	int ans=0;
	rep(i, 0, M) {
		if(dist[v[i][0]][v[i][1]] != v[i][2]){
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}



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

int main()
{
    int n,m;
    cin>>n>>m;
    vector<bool> arr[n+1];
    string x; int p;
    for(int i=0;i<m;++i){
        cin>>p>>x;
        if(x=="AC"){
            arr[p].push_back(true);
        }else{
            arr[p].push_back(false);
        }

    }

    int score =0;
    int pen = 0;
    int cnt = 0;
    for(int i=0;i<n+1;++i){
        cnt=0;
        for(int j=0;j<arr[i].size();++j){
            if(arr[i][j]==false){
                cnt++;
            }else if(arr[i][j]==true){
                pen+=cnt;
                score+=1;
                //cout<<score<<" "<<cnt<<endl;
                break;
            }
        }
    }
    cout<<score<<" "<<pen<<endl;
    return 0;
}


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

int m = 2019;

int main(void){
    //input
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int x=1, tmp=0;
    long long ans=0;
    vector<int> cnt(m);

    //calculate
    rep(i,n){
        cnt[tmp]++;        
        tmp += (s[i]-'0')*x;
        tmp %= m;
        ans += cnt[tmp];
        x = x*10%m;        
    }

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

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<b;++i)
#define FORS(i,a,b,c) for(i=a;i<b;i+=c)
#define ss second
using namespace std;

void mx(map<int,int> &m,int &s,int &id){
    for(auto x:m){
        //cout<<x.first<<" "<<x.ss<<endl;
        if(x.ss>s){
            s=x.ss;
            id=x.first;
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a[100005];
    int n;
    cin>>n;
    int m=n/2;
    int i;
    FOR(i,1,n+1) cin>>a[i];
    map<int,int> freq1;
    map<int,int> freq2;
    FORS(i,2,n+1,2){
        //cout<<i<<endl;
        ++freq2[a[i]];
        ++freq1[a[i-1]];
    }
    int curmx1=-1,curmx2=-1;
    int id1,id2;
    mx(freq1,curmx1,id1);
    mx(freq2,curmx2,id2);
    
    if(id1==id2){
        int a=0;
        int b=0;
        auto tmp1=freq1;
        auto tmp2=freq2;
        freq1.erase(id1);
        int curmx3=-1;
        int id3;
        if(!freq1.empty()){
            mx(freq1,curmx3,id3);
            a=m-curmx3+m-curmx2;
        }else{
            a=m+m-curmx2;
        }
        freq2.erase(id2);
        curmx3=-1;
        
        if(!freq2.empty()){
            mx(freq2,curmx3,id3);
            b=m-curmx3+m-curmx1;
        }else{
            b=m+m-curmx1;
       } 
        cout<<min(a,b)<<endl;

    }else cout<<m-curmx1+m-curmx2<<endl;
    return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  int sum=0,MAX=0;
  rep(i,n){
    int l; cin>>l;
    MAX=max(MAX,l);
    sum+=l;
  }
  ((sum-MAX>MAX))?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


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

int main(){
  int N;
  
  cin >> N;
  int d[N];
  
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  
  int ans=0;
  
  for(int i=0; i<N; i++){
    for(int j=i; j<N; j++){
      if(i!=j)
        ans = ans + d[i]*d[j];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int64 MOD = 1000000007;

map<long long, long long> primeFact(long long n) {
    map<long long, long long> prime;
    for(long long i = 2; i * i <= n; i++) {
        long long cnt = 0;
        while(n % i == 0) {
            cnt++;
            n /= i;
        }
        if(cnt) prime[i] = cnt;
    }
    if(n != 1) prime[n]++;
    return prime;
}

long long powMod(long long x, long long n, long long mod = 1000000007) {
    long long res = 1LL;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return res;
}

long long invMod(long long n, long long mod = 1000000007) {
    return powMod(n, mod - 2, mod);
}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    map<int64, int64> ma;
    for(int i = 0; i < N; ++i) {
        for(auto &p : primeFact(A[i])) {
            int64 n, k; tie(n, k) = p;
            if(ma[n]) ma[n] = max(ma[n], k);
            else ma[n] = k;
        }
    }
    int64 L = 1LL;
    for(auto &p : ma) {
        int64 n, k; tie(n, k) = p;
        L = L * powMod(n, k) % MOD;
    }
    int64 ans = 0;
    for(int i = 0; i < N; ++i) {
        ans += L * invMod(A[i]);
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
int n,v[65],x[65],y[65],z[65];
int main(){
	scanf("%d",&n);
	v[19]=1;
	Rep(i,18,1) v[i]=v[i+1]*2;
	For(i,2,19){
		x[++*x]=i,y[*x]=i+1,z[*x]=0;
		x[++*x]=i,y[*x]=i+1,z[*x]=v[i];
	}
	int l=0,r=v[1]-1;
	for (;r<n;l+=v[1],r+=v[1])
		x[++*x]=1,y[*x]=2,z[*x]=l;
	For(i,2,19) if (n&v[i])
		x[++*x]=1,y[*x]=i+1,z[*x]=l,l+=v[i];
	printf("20 %d\n",*x);
	For(i,1,*x) printf("%d %d %d\n",x[i],y[i],z[i]);
}

Measured memory_bytes: 256
N, M = map(int, input().split())

last_bin = (2 ** N)
switches = [[int(i) for i in input().split()][1:] for _ in range(M)]
ps = [int(i) for i in input().split()]

# print('{:010b}'.format(last_bin))

counter = 0
score = 0
while last_bin != counter:
    state = '{:010b}'.format(counter)
    # print(state)
    okFlag = True
    for i in range(len(switches)):
        # print(switches[i])
        states = [state[-1 * x] for x in switches[i]]
        # print(states)
        if states.count('1') % 2 == ps[i]:
            pass
        else:
            okFlag = False
            break
    if okFlag:
        score += 1
    counter += 1

print(score)

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



Measured memory_bytes: 2100
#include<cstdio>
int n, ans;
int a[1000005];
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		int x;scanf("%d",&x);
		if(x > n) ans++;
		else a[x]++;
	}
	for(int i = 1;i <= n;i++){
		if(a[i] == 0) continue;
		if(a[i] < i) ans += a[i];
		else if(a[i] > i) ans += a[i]-i;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long d = sc.nextLong();
    long[]x = new long[n];
    long[]y = new long[n];

    for(int i=0; i<n; i++) {
    	x[i] = sc.nextLong();
    	y[i] = sc.nextLong();
    }
    long cou = 0;
    long a = 0;
    for(int i=0; i<n; i++) {
    	a = x[i]*x[i]+y[i]*y[i] ;
    	if(a <= d*d) {
    		cou++;
    	}
    }
    	System.out.println(cou);
    }
}

Measured memory_bytes: 62760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int x=-1,y=-1;

    string s;
    cin>>s;

    for(int i=0; i<s.size()-2; i++){
        if(s[i]==s[i+1] || s[i+1]==s[i+2] || s[i]==s[i+2]){
            x=i+1; y=i+3;
            break;
       }
    }

    if(s.size()==2){
        if(s[0]==s[1]){
            x=1; y=2;
        }
    }

    cout<<x<<" "<<y<<endl;

    return 0;
}


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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastRead ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);cin.tie(0),cout.tie(0);
#define ll long long int
#define Endl cout<<"\n"
using namespace std;
int main()
{
    FastRead;
    ll i,j,n,mn=0,t,c,x,y;
    string a;
    cin>>t;
    map< string,ll >mp;
    while(t--){
        ll z=0,tw=0;
        cin>>a;
        mp[a]++;
        mn=max(mn,mp[a]);

    }
    for(auto i:mp){
        if(i.second==mn){
            cout<<i.first<<endl;
        }
    }


    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<deque<int>> a(n, deque<int>(n-1));
	rep(i, n) rep(j, n-1){ cin >>a[i][j]; a[i][j]--;}
	int ans = 0;
	set<pii> q;
	
	auto mkmc=[&](int c){
		if(sz(a[c]) ==0) return;
		int tb = a[c].front();
		if(a[tb].front() != c) return;
		q.emplace(min(c, tb), max(c, tb));
	};
	
	rep(i, n) mkmc(i);

	while(sz(q)){
		ans++;
		set<pii> cq;
		swap(q, cq);
		for(auto x: cq){
			a[x.first].pop_front();
			a[x.second].pop_front();
		}
		for(auto x: cq){
			mkmc(x.first);
			mkmc(x.second);
		}
	}
	rep(i, n) if(sz(a[i])>0) ans =-1;
	cout <<ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 4608
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> intpair;
typedef std::pair<long long, long long> llpair;

#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i, n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using namespace std;

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

	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;

		int ans = 0;
		bool flag = true;
		rep(i, n) {
			int k;
			cin >> k;
			if (k > 0) ++ans;
			if (k > 1) flag = false;
		}

		if (flag) {
			cout << "NA" << "\n";
		}
		else {
			cout << ++ans << "\n";
		}
	}

	return 0;
 }



Measured memory_bytes: 3232
N = int(input())
A = list(map(int, input().split()))
print(' '.join(map(str, A)))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(' '.join(map(str, A)))


Measured memory_bytes: 5592
#include<stdio.h>
int main()
{
  char s[4];
  int x=0,y=0,z=0;
  int i;
  scanf("%s", s);
  for(i=0;i<3;i++){
    if(s[i]=='a')
      x=1;
    if(s[i]=='b')
      y=1;
    if(s[i]=='c')
      z=1;
  }
  if(x==1&&y==1&&z==1)
  printf("Yes");
  else
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;
long long gcd(long long, long long);
long long lcm(long long, long long);
int main()
{
	long long A,B,C,D,num;
	long long CA,CB,DA,DB,gcdv,lcmv,CDA,CDB,k;
	
//while(1){
	cin >> A >> B >> C >> D;

if ((B-A)<1) { cout << 0 << endl;}
else{
	//A=A;
	//B=B-1;
	if (A%C == 0) { CA=A/C;	}
	else {		CA = A/C + 1; }
	CB = B/C;
	num = CB-CA+1;
	
	if (A%D == 0) { DA=A/D;	}
	else  { DA = A/D+1;}
	DB = B/D;
	num += DB-DA+1;

/*
	cout << "CA..."<< CA << "; CB..."<< CB << "; num..." << CB-CA+1 << endl;
	cout << "CA..."<< CA*C << "; CB..."<< CB*C << "; num..." << CB-CA+1 << endl;
	cout << "DA..."<< DA << "; DB..."<< DB << "; num..." << DB-DA+1 << endl;
	cout << "DA..."<< DA*D << "; DB..."<< DB*D << "; num..." << DB-DA+1 << endl;
*/
		
	//gcdv = gcd(C,D);

	lcmv = lcm(C,D);
	
	//cout << "GCD..." << gcdv << "; k..." << k << "; lcm..." << lcmv << endl;
		
	if (A%lcmv==0) { CDA = A/lcmv;}
	else { CDA = A/lcmv +1;	}	
	CDB = B/lcmv;
	num -= (CDB-CDA+1);	

	//cout << "CDA..."<< CDA << "; CDB..."<< CDB << "; num..." << CDB-CDA+1 << endl;
	
	//cout << "B-1..." << B << "; A..."<< A << "; B-A... " << B-A+1 << endl;
	
	num = B-A+1 - num;
	cout << num << endl;
	
}
//}
	return 0;
}
long long gcd(long long m, long long n)
{
	if (n==0) return m;
	else gcd((m>n)?n:m, (m>n)?m%n:n%m);
}

long long lcm(long long m, long long n)
{
	return(m*n/gcd(m,n));
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		sc.close();

		int max = 0;

		if (k <= a) {
			max = k;
		} else if (k <= a + b) {
			max = a;
		} else {
			max = a - (k-a-b);
		}

		System.out.println(max);
	}

}


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


def solve(N: int, M: int, A: "List[int]"):
    while M > 0:
        A = sorted(A, reverse=True)
        MD = A[0] // 2
        for i, ai in enumerate(A):
            if ai > MD and M > 0:
                A[i] = ai//2
                M -= 1
            else:
                break
        if A[i] == 0:
            break
    print(sum(A))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int k, s;
    scanf("%d%d", &k, &s);
    int cnt = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s-x-y;
            if(z >= 0 && z <= k) cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader sc, PrintWriter w) {

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

            int ans = Math.min(a + b, Math.min(b + c, a + c));
            w.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
S=int(input())
if S<10**18:
    x1,y1,x2,y2,x3,y3=0,0,(S//10**9+1),10**9-S%10**9,1,10**9
else:
    x1,y1,x2,y2,x3,y3=(0,0,10**9,1,0,10**9)
print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3060
N = int(input())
Cls = [0]
Sls = [0]
Fls = [0]
lsans = []
for i in range(1,N):
    c,s,f = map(int,input().split())
    Cls.append(c)
    Sls.append(s)
    Fls.append(f)
for i in range(1,N):
    t = 0
    for j in range(i,N):
        if t < Sls[j]:
            t = Sls[j] + Cls[j]
        elif t%Fls[j] == 0:
            t += Cls[j]
        else:
            t += Fls[j]-(t%Fls[j])+Cls[j]
    lsans.append(t)
lsans.append(0)
for i in lsans:
    print(i)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define U(i, a, b) for (int i = (a); i <= (b); ++i)
#define D(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;
int gi() {
  int f = 1, x = 0; char ch = getchar();
  while (ch < '0' || ch > '9') { if (ch == '-') f = -f; ch = getchar(); }
  while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
  return f * x;
}
typedef long long LL;
typedef pair<int,int> pi;

int main() {
	int x, y;
	cin >> x >> y;
	for (int many = 0; many <= x; ++many) {
		int left = (y - many * 2);
		if (left >= 0 && (x - many) * 4 == left) return puts("Yes"), 0;
	}
	puts("No");
  return 0;
}

Measured memory_bytes: 3624
// バケット法による解
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];

    //set<int> values; // insert するときに重複を取り除いてくれます
    //for (int i = 0; i < N; ++i) {
    //    values.insert(A[i]); // 挿入します
    //}
    //for(auto itr = values.begin(); itr != values.end(); ++itr) {
    //    cout << *itr << endl;      // イテレータの指す先のデータを表示
    //}
    //for(auto x : values) cout << x << endl;     // 要素を順に表示
    
    int sum[N] = {0};
    for (int i = 0; i < N; ++i) ++sum[A[i]-1];
    sort(sum, sum + N, greater<int>());
    
    int convert = 0;
    for (int i = K; i < N; ++i) convert += sum[i];
    cout << convert << endl;


}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
char str[100100];
int a[100100];
int n;
bool check(int k)
{
//    printf("k = %d\n",k);
    int flag = 1;
    for (int i=n-k+1;i<k;i++) if (a[i] == 1) {flag = 0; break;}
    return flag;
}
int main(void)
{
    scanf("%s",str);
    n = strlen(str);
    a[0] = str[0] - '0';
    for (int i=1;i<n;i++) a[i] = (str[i]-'0') ^ (str[i-1]-'0');
    a[n] = 1;
    // 010000 k = 3 011111
//    for (int i=0;i<n;i++) printf("%d ",a[i]); puts("");
    int l = 2, r = n, ans = 1;
    while (l <= r) {
        int mid = (l+r)/2;
        if (check(mid)) ans = max(ans,mid), l = mid+1;
        else r = mid-1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int num[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    int n, q, numq, ans = 0;
    cin >> n;
    rep(i, 0, n-1)
        cin >> num[i];
    cin >> q;
    while (q--)
    {
        cin >> numq;
        int l = 0, r = n;
        while (l < r)
        {
            int mid = (l+r)>>1;
            if (num[mid] == numq)
            {
                ans++;
                break;
            }
            else if (num[mid] < numq)
                l = mid+1;
            else
                r = mid;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3504
n=int(input())
res=0
if int(n**0.5)**2==n:
    ran=int(n**0.5)
else:
    ran=int(n**0.5)+1
for i in range(1,ran):
    if n%i==0:
        x=i
        m=n//i-1
        if x==m:
            break
        if x*(m+1)==n:
            res+=m
print(res)

Measured memory_bytes: 40172
import sys
import copy
x=int(input())

alist=[i for i in range(121)]
blist=copy.deepcopy(alist)

for a in alist:
    for b in blist:
        if a**5 - b**5 == x:
            print(a,b)
            sys.exit()
        elif a**5 + b**5 == x:
            print(a,-b)
            sys.exit() 


print(";;")



Measured memory_bytes: 9348
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		//if(a > 10) System.out.println(0);
		long ten = 1;
      	long nine = 1;
      	long eight = 1;
      	long m = 1000000007;
	    for(int i = 0; i < n; i++) {
          ten = (ten*10) % m;
          nine = (nine*9) % m;
          eight = (eight*8) % m;
        }
          
		System.out.println((int) ( (((ten + eight)%m + m)  - ((2*nine)%m))%m)); 
	}
}

Measured memory_bytes: 35828
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string t = io.r<string>().ToLower();
        int n = 0;
        while (true)
        {
            string s = io.r<string>();
            if (s == "END_OF_TEXT") { break; }
            s = s.ToLower();
            string[] ss = s.Split(' ');
            for (int i = 0; i < ss.Count(); i++)
            {
                if (ss[i] == t) { n++; }
            }
        }
        io.w(n);
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rrep(i,beg,end)   for (auto i=(beg);i>=(end);i--)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
using pii = pair<int, int>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    priority_queue<double, deque<double>, greater<double>> pq;
    rep(i, 0, n)
    {
        ll t;
        cin >> t;
        pq.push(t);
    }
    while(pq.size() >= 2) {
        double a = pq.top(); pq.pop();
        double b = pq.top(); pq.pop();
        pq.push((a + b) / 2);
    }

    cout << pq.top() << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll lcm( ll a, ll b){
  return a / __gcd( a, b) * b;
}
int main(){
  ll a[3], m[3];
  while(cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2], a[0]){
    ll cnt[3] = {1, 1, 1}, jv[3];
    for(int i = 0 ; i < 3 ; i++ ){
      jv[i] = a[i] % m[i];
      while(jv[i] != 1){
        jv[i] = (jv[i] * a[i]) % m[i];
        cnt[i]++;
      }
    }
    cout << lcm(cnt[0],lcm(cnt[1],cnt[2])) << endl;
  }
}

Measured memory_bytes: 1156
# include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int fa[maxn],rk[maxn];
int findr(int x){
	return fa[x] = fa[x]==x ? x : findr(fa[x]);
}
int read(){
	int x=0;char c=getchar();
	for (;c<'0'||c>'9';c=getchar());
	for(;c>='0'&c<='9';c=getchar())x=x*10+c-'0';
	return x;
}
int n,q;
int a[maxn];
int main(){
	n=read(); q=read();
	for (int i=1;i<=n;++i) fa[i]=i;
	for (int i=1;i<=n;++i) a[i]=read();
	for (int i=1;i<=q;++i){
		int x,y; x=read(),y=read();
		fa[findr(x)]=findr(y);
	}
	
	int ans =0; for (int i=1;i<=n;++i) if (findr(i)==findr(a[i])) ++ ans;
	printf("%d\n",ans);
	return 0;
}

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

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

	if (n < 105) cout << 0 << endl;
	else if (n < 135) cout << 1 << endl;
	else if (n < 165) cout << 2 << endl;
	else if (n < 189) cout << 3 << endl;
	else if (n < 195) cout << 4 << endl;
	else cout << 5 << endl;

	return 0;
}

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

class Main
{

	public static void main(String[] args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str;
		while((str=br.readLine())!=null)
		{
			int n=Integer.parseInt(str);
			int debt=100000;
			System.out.println(debt(debt,n));


		}
	}

	static int debt(int debt,int n)
	{
		int add=(int)Math.ceil(((int)Math.round(debt*5.0/100.0))/1000.0)*1000;
		debt+=add;
		n--;
		if(n>0){return debt(debt,n);}
		else{return debt;}
	}



}

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

using namespace std;

int main(void)
{

	int val,count = 0;
	while (scanf("%d", &val) != EOF)
	{
		for (int a = 0; a < 10; a++)
		{
			for (int b = 0; b < 10; b++)
			{
				for (int c = 0; c < 10; c++)
				{
					for (int d = 0; d < 10; d++)
					{
						if (a + b + c + d == val)count++;

					}

				}


			}


		}

		printf("%d\n", count);
		count = 0;

	}

}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  string S, T;
  cin >> N >> S >> T;
  for(int i = 0; i < N * 2; i++){
    if(i % 2 == 0)cout << S.at(i / 2);
    else cout << T.at(i / 2);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

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


int a, b, c, k;

void solve()
{
    cin >> a >> b >> c >> k;
    while (k--) {
        if (b<=a) b*=2;
        else if (c<=b) c*=2;
    }
    if (b>a && c>b) nout("Yes");
    else nout("No");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int N, vector<ll> &A, ll &ans){

    bool pflg = false, nflg = false;
    for(int i = 0; i != N-1; ++i){
        int tmp = A.at(i+1) - A.at(i);

        if(tmp < 0){
            if(pflg == true){
                ++ans;
                pflg = false;
            }
            else nflg = true;
        }
        else if(tmp > 0){
            if(nflg == true){
                ++ans;
                nflg = false;
            }
            else pflg = true;
        }
    }
    ++ans;
    
    return;
}

int main(){

    int N;
    cin >> N;
    vector<ll> A(N);
    for(auto iter = A.begin(); iter != A.end(); ++iter) cin >> *iter;

    ll ans{};
    solver(N, A, ans);

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

Measured memory_bytes: 3964
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	double r;
  	cin >> r;
  	cout << 2*r*M_PI << endl;
  	cout << fixed << setprecision(8);
}

Measured memory_bytes: 3756
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<time.h>
#include<cmath>
#include<queue>
using namespace std;
#define INF 1000000;
int c,len;
char str[101];
int main(){
	while(cin>>str){
		c=0;
		while(strlen(str)>c){
			if(str[c]!='@'){
				cout<<str[c];
				c++;
			}else{
				for(int i=0;i<(int)(str[c+1]-'0');i++){
					cout<<str[c+2];
				}
				c+=3;
			}
		}
		cout<<endl;
	}

	return 0;
}	

Measured memory_bytes: 1132
N = int(input())
A = [int(i) for i in input().split()]
maxA=max(A)
pn=list(range(maxA+1))
n=2
while n*n <= maxA:
  if n == pn[n]:
    for m in range(n, len(pn), n):
      if pn[m] == m:
        pn[m] = n
  n+=1

s=set()
for a in A:
  st = set()
  while a > 1:
    st.add(pn[a])
    a//=pn[a]
  if not s.isdisjoint(st):
    break
  s |= st
else:
  print("pairwise coprime")
  exit()

from math import gcd

n = gcd(A[0], A[1])
for a in A[2:]:
  n=gcd(n,a)
if n == 1:
  print("setwise coprime")
else:
  print("not coprime")


Measured memory_bytes: 188936
s = input()
size = len(s)
flag = False

if size == 2:
    if s[0] == s[1]:
        print('1 2')
        flag = True
    else:
        print('-1 -1')
else:
    for i in range(size-2):
        if s[i] == s[i+1]:
            print(i+1, i+2)
            flag = True
            break
        elif s[i] == s[i+2]:
            print(i+1, i+3)
            flag = True
            break
        else:
            continue
    if flag == False:
        print('-1 -1')

Measured memory_bytes: 3188