akhauriyash/Code-Regression huggingface dataset:
// AOJ 2252
#include<iostream>
#include<string>
using namespace std;

bool member(char c, string set) {
  for (auto&& x : set) {
    if (c == x) return true;
  }
  return false;
}

int solve(string str) {
  int ans = 0;
  string left = "qwertasdfgzxcvb", // false
         right = "yuiophjklnm"; // true
  bool hand = member(str[0],right);
  for (auto&& c : str) {
    string current = (hand ? right : left);
    if (!member(c, current)) {
      hand = !hand;
      ans++;
    }
  }
  return ans;
}

int main() {
  string query;
  while (cin >> query and query != "#") {
    cout << solve(query) << endl;
  }
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        while(!(a & 1)) {
            a >>= 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a[101];
  int n;
  int i;
  int max=0;

  for(i=0;i<101;i++){
    a[i]=0;
  }

  while(scanf("%d",&n)!=EOF){
    a[n]++;
    if(max<a[n]){
      max=a[n];
    }
  }

  for(i=1;i<=100;i++){
    if(max==a[i]){
      printf("%d\n",i);
    }
  }

  return 0;
}

Measured memory_bytes: 596
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N, X = MI()
    x = [abs(int(i) - X) for i in input().split()]

    ans = x[0]
    for i in range(1, N):
        ans = gcd(x[i], ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88300
KN = list(map(int, input().split()))
K = KN[0]
N = KN[1]

A = list(map(int, input().split()))
A.sort()

maxDist = A[0] + (K - A[N-1])

for i in range(N-1) :
  dist = A[i+1] - A[i]
  if dist > maxDist :
    maxDist = dist
    
print(K-maxDist)

Measured memory_bytes: 26060
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main(){
    IOS;
    int a,b,c;
    cin >> a >> b  >>c;
    bool f=0;
    if(a==b&&a!=c)f=1;
    if(a==c&&a!=b)f=1;
    if(b==c&&b!=a)f=1;
    if(f==1)cout<<"Yes";
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
using System;


class AOJ
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Split(' ');

            double x1 = double.Parse(s[0]);
            double y1 = double.Parse(s[1]);
            double x2 = double.Parse(s[2]);
            double y2 = double.Parse(s[3]);
            double x3 = double.Parse(s[4]);
            double y3 = double.Parse(s[5]);

            double a = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
            double b = Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
            double c = Math.Sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));

            double px = (((x1 * x1 + y1 * y1) * (y2 - y3)) + ((x2 * x2 + y2 * y2) * (y3 - y1)) + ((x3 * x3 + y3 * y3) * (y1 - y2))) / ((x1 * (y2 - y3)) + (x2 * (y3 - y1)) + (x3 * (y1 - y2))) * 0.5;
            double py = (((x1 * x1 + y1 * y1) * (x2 - x3)) + ((x2 * x2 + y2 * y2) * (x3 - x1)) + ((x3 * x3 + y3 * y3) * (x1 - x2))) / ((y1 * (x2 - x3)) + (y2 * (x3 - x1)) + (y3 * (x1 - x2))) * 0.5;
            double r  = (a * b * c) / Math.Sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));

            Console.WriteLine("{0:F3} {1:F3} {2:F3}", px, py, r);
        }
    }
}

Measured memory_bytes: 20076
#include<iostream>
#include <vector> 
#include <algorithm>
#include<iomanip>
#include<math.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;


int main() {
    long long N, M,a,b,sum=0;
    int height[100001] = { 0 };
    int highest[100001] = { 0 };
    cin >> N;
    cin >> M;
    for (int x = 0; x < N; x++) {
        cin >> height[x];
    }
    for (int x = 0; x < M; x++) {
        cin >> a;
        cin >> b;
        if (height[a-1] > height[b-1])highest[b-1] = 1;
        else if (height[a-1] < height[b-1])highest[a-1] = 1;
        else {
            highest[a-1] = 1;
            highest[b-1] = 1;
        }
    }
    for (int x = 0; x < N; x++)if (highest[x] == 0)sum++;
        cout << sum << endl;
    return 0;
}

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

int main(){
	int a,b,k;scanf("%d%d%d",&a,&b,&k);
	if(b-a+1<=2*k){
		for(int i=a;i<=b;i++)cout<<i<<endl;
	}
	else{
		rep(i,k)cout<<a+i<<endl;
		for(int i=k-1;i>=0;i--)cout<<b-i<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int s,w;
  cin >> s >> w;

  if(s<=w)  cout << "unsafe" << endl;
  else  cout << "safe" << endl;

  return 0;
}

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

#define rep(i, a, n) for(int i = a; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    string ans = "YES";
    map<long long, int> mp;
    long long a;
    rep(i, 0, n) 
    {
        cin >> a;
        ++mp[a];
        if (mp[a] > 1) ans = "NO";
    }
    cout << ans << endl;
}


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


struct com
{
	string syori;
	int a;
	int b;
	string c;
};


int main()
{
	string str;
	com In[100] = {};
	int count;

	cin >> str;
	cin >> count;

	for (int i1 = 0; i1 < count; i1++)
	{
		cin >> In[i1].syori;
		if (In[i1].syori == "print" || In[i1].syori == "reverse")
		{
			cin >> In[i1].a;
			cin >> In[i1].b;
		}
		else if (In[i1].syori=="replace")
		{
			cin >> In[i1].a;
			cin >> In[i1].b;
			cin >> In[i1].c;
		}
	}


	for (int i = 0; i < count; i++)
	{
		if (In[i].syori == "print")
		{
			for (int i1 = In[i].a; i1 <= In[i].b; i1++)
			{
				cout << str[i1];
			}
			cout << endl;
		}

		else if (In[i].syori == "reverse")
		{
			int x = 0;
			for (int i1 = In[i].a; i1 < In[i].a + 1 + (In[i].b - In[i].a) / 2; i1++)
			{
				char c;
				c = str[i1];
				str[i1] = str[In[i].b - x];
				str[In[i].b - x] = c;
				x++;
			}
		}

		else if (In[i].syori == "replace")
		{
			str.replace(In[i].a, In[i].b - In[i].a + 1, In[i].c);
		}
	}
	return 0;
}

Measured memory_bytes: 3168
import scala.collection.mutable
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val map = mutable.HashMap[Int,Int]()

  val n = in.readLine.toInt
  in.readLine
    .split(" ")
    .foreach(e => {
      val i = e.toInt
      if(!map.contains(i)) map += i -> 1
      else map(i) +=1
    })

  val x = map.keys

  val ans = x./:(0)((acc,e) => {
      val cnt = map.getOrElse(e-1,0) + map.getOrElse(e,0) + map.getOrElse(e+1,0)
      math.max(acc, cnt)
    })

  println(ans)
}

Measured memory_bytes: 50360
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

const long MAX = 100000;
const long NIL = -1;

long n;
vector<long> G[MAX];
long color[MAX];

void dfs(long r, long c){
	stack<long> S;
	S.push(r);
	color[r] = c;
	while (!S.empty()){
		long u = S.top();
		S.pop();
		for (long i = 0; i < G[u].size(); i++){
			long v = G[u][i];
			if (color[v] == NIL){
				color[v] = c;
				S.push(v);
			}
		}
	}
}

void assignColor(){
	long id = 1;
	for (long i = 0; i < n; i++) color[i] = NIL;
	for (long u = 0; u < n; u++){
		if (color[u] == NIL) dfs(u, id++);
	}
}

int main(){
	long s, t, m, q;
	cin >> n >> m;
	for (long i = 0; i < m; i++){
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	assignColor();

	cin >> q;
	for (long i = 0; i < q; i++){
		cin >> s >> t;
		if (color[s] == color[t]) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}

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

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

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<ll,ll>> prime(0);
    ll N_cpy = N;
    for (ll i = 2; i * i <= N; i++) {
        if (N_cpy % i == 0) {
            ll num = 0;
            while (N_cpy % i == 0) {
                num++;
                N_cpy /= i;
            }
            prime.push_back(make_pair(i,num));
        }
    }
    if (N_cpy != 1) prime.push_back(make_pair(N_cpy,1));

//    for (auto i : prime) {
//        cout << i.first << " " << i.second << endl;
//    }
    ll ans = 0;
    for (auto i : prime) {
        ll n = i.second;
        for (ll j = 1; n >= j; j++) {
            ans++;
            n -= j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var slimestr string
	fmt.Scan(&n)
	fmt.Scan(&slimestr)
	slimes := strings.Split(slimestr, "")
	ans := 1
	for index, slime := range slimes {
		if index+1 >= n {
			break
		}
		next := slimes[index+1]
		if slime != next {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2944
a=input()
dic={}
for i in range(len(a)):
  s=a[i]
  if s in dic:
    dic[s]=dic[s]+1
  else:
    dic[s]=1

sum=0
for val in dic.values():
  if val>1:
    sum=sum+(val-1)*val//2
  
print((len(a)*(len(a)-1))//2-sum+1)

Measured memory_bytes: 3500
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;

string s;

int main()
{
    cin>>s;
    if ((s[0]=='Y') &&(s[1]=='A')&&(s[2]=='K')&&(s[3]=='I')) cout<<"Yes"<<endl;
    else cout<<"No" ;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll p=1000000000000000000;
	ll n;
	cin>>n;
	ll ans=1;
	bool big=0,zero=0;
	rep(i,0,n)
	{
		ll x;
		cin>>x;
		if(!x)
		{
			zero=1;continue;
		}
		if(p/x<ans||(p/x==ans&&p%x!=0))
		{
			big=1;
		}
		ans*=x;
	}
	if(zero)
	{
		cout<<"0\n";
		return 0;
	}
	if(big) cout<<"-1\n";
	else cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int A[n];
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]);
	int mn=A[0];	
	long long int res=0;
	for(int i=1;i<n;i++)
	{
		if(mn<A[i])
			mn=A[i];
		else
			res+=(long long)(A[i]-mn);
	}
	printf("%lld\n",abs(res));
}

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

int main(){
	int n,m;
	cin>>n;
	
	vector<string>v;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		v.push_back(s);
		}
		
		cin>>m;
		int flg=0;
		for(int j=0;j<m;j++){
			string s;
			cin>>s;
			int match=0;
			for(int i=0;i<n;i++){
				if(s==v[i]){
					match=1;
					break;
					}
				}
				
			if(match==0)cout<<"Unknown "<<s<<endl;
			else{
				if(flg==0){
					cout<<"Opened by "<<s<<endl;
					flg=1;
					}
				else{
					cout<<"Closed by "<<s<<endl;
					flg=0;
					}	
				}	
			}
			return 0;
	}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int ans = 0;
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    int Amaxi = A[N - 1];
    vector<int> dp(Amaxi + 1, 1);
    rep(i, N) { //各Aiについて
        int p = A[i];
        if(dp[p] == 1) {
            rep(q, (Amaxi / p) + 1) dp[p * q] = 0;
            if(A[i] != A[i + 1]) {
                ans += 1;
            }
        }
    }
    if(dp[Amaxi] == 1) {
        ans += 1;
    }
    cout << ans << endl;
}

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

const long long mod =1e9+7 ;
const int N = 4e2+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vi vector<int>
#define vii vector<ll>
#define vpr vector<pair<int,int> >
#define dbg(x) cout << #x << " is " << x << endl;
#define spk(x) cout<<x<<endl;
#define inf INT_MAX
/*
stoi - sting to int;
stol - string to long;
stoll - string to ll;
*/

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

const ll oo = 1e18;

ll dp[N][N];
ll a[N];

ll solve(int l, int r)
{
	if(l > r)
		return oo;

	if(l == r)
		return 0;

	if(l + 1 == r)
		return a[l] + a[r];

	ll &ans = dp[l][r];

	if(ans != -1)
		return ans;

	ans = oo;

	ll s = 0;
	for(int i = l; i <= r; i++)
		s += a[i];

	for(int i = l; i <= r; i++)
	{
		ll cur = solve(l, i) + solve(i + 1, r) + s;

		ans = min(ans, cur);
	}

	return ans;
}

////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);

memset(dp, -1, sizeof(dp));

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> a[i];

	cout << solve(0, n - 1) << endl;


    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t,ans;
    cin>>n>>x>>t;
    if(n%x!=0)
    {
       ans = ((n/x)+1) * t;
       cout<<ans;
    }
    else
        {ans = (n/x) *t;
        cout<<ans;}

}


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

P = list(map(int, input().split()))

cnt=0

import numpy as np

P=np.array(P)

max_val=P[0]

cnt=1

for i in range(1,N):
    if max_val > P[i-1]:
        max_val=P[i-1]

    if max_val > P[i]:
        cnt+=1

print(cnt)

Measured memory_bytes: 24744
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for(int i = 1; i < N; i++){
            ans = Math.min(ans, calc(i) + calc(N - i));
        }
        System.out.println(ans);
    }
    public static int calc(int i)
    {
        if(i == 0){
            return 0;
        }
        return i % 10 + calc((i - i % 10) / 10);
    }
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A)
{
    sort(A.begin(), A.end());
    bool flg = true;
    rep (i, N - 1) {
        if (A[i] == A[i + 1]) {
            flg = false;
            break;
        }
    }
    if (flg)
        cout << "YES" << endl;
    else {
        cout << "NO" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int d[444444], e[222222];
int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    for(int i = n; i--;)
        d[i] = s[i] == 'o' ? d[i + c + 1] + 1 : d[i + 1];
    for(int i = 0; i < n; i++) {
        if(s[i] == 'o')
            e[i] = 1, i += c;
    }
    for(int i = 0; i < n; i++)
        if(e[i] && d[0] + d[i + 1] - d[i] < k)
            cout << i + 1 << '\n';
    cout << flush;
    return 0;
}


Measured memory_bytes: 3332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        int[] tastes = new int[N];
        int min = Integer.MAX_VALUE;
        int total = 0;
        int index = 0;
        for (int i = 0; i < N; i++) {
            int taste = L+i;
            total += taste;
            tastes[i] = taste;
            int moo = Math.min(min, Math.abs(taste));
            if (moo < min) {
                min = moo;
                index = i;
            }
        }
        System.out.println(total-tastes[index]);
    }
}

Measured memory_bytes: 35708
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
g = [[] for i in range(n)]
for i in range(m):
    a,b = inpl()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
res = 0
seen = [False] * n
seen[0] = True
def dfs(node,seen):
    global res
    if sum(seen) == n:
        res += 1
        return 0
    for now in g[node]:
        if not seen[now]:
            seen[now] = True
            dfs(now,seen)
            seen[now] = False
dfs(0,seen)
print(res)

Measured memory_bytes: 68072
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s[105];
  int n,m;
  cin>>n>>m;
  for (int i=1;i<=n;++i) {
    cin>>s[i];
  }
  for (int i=1;i<=n;++i) {
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }
}

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

long int chmin(long int a,long int b){
  //b:answer_min
  if(a < b){
    b = a;
  }
  return b;
}

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  int h[n];
  long int dp[n];
  for(int i=0; i<n; i++){
    scanf("%d",&h[i]);
    dp[i] = 1LL << 40;
  }
  
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]); 
  
  for(int i=2; i<n; i++){
    for(int j=1; j<=k; j++){
      if(i-j >= 0){
        dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
      }
    }
  }
  
  printf("%ld", dp[n-1]);
  
  return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

// 1<=A,B<=500(自然数)
// hxw 1<=h,w<=100
// 白: A個の連結成分(.)
// 黒: B            (#)
// 

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

    int A, B;
    cin >> A >> B;
    const int N = 99;
    vector<string> S(N, string(N, '#'));

    int i = 0, j = 0;
    B--;
    [&] {
        for (;; j += 3) {
            if (B == 0)return;
            B--;
            if (j == 99)j = 0, i += 3;
            rep(ii, 3)rep(jj, 3) {
                S[i+ii][j+jj] = '.';
            }
            S[i + 1][j + 1] = '#';
        }
    }();
    if (S[0][0] == '.')A--;

    [&] {
        for (;; j += 3) {
            if (A == 0)return;
            if (j == 99)j = 0, i += 3;
            A--;
            S[i + 1][j + 1] = '.';
        }
    }();

    cout << N << ' ' << N << endl;
    each(line, S)cout << line << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <iostream>
#include <vector>
#include <functional>
#include <numeric>
#include <algorithm>
#include <string>
using namespace std;
#define MOD 1000000007


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s ;
	cin >> s ;
	if (s == "ARC") cout << "ABC" << "\n";
	else cout << "ARC" << "\n";


	return 0 ;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   	int a,b,c;
   	cin >> a >> b >> c;
   	if(a+b+c>=22) cout << "bust";
   	else cout << "win";
   	cout << "\n";
    return 0;
}



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

const int INF = 1e9+5;

void print(std::vector<auto> V){
	for(auto v:V)
		cout<<v<<" ";
	cout<<endl;
}
// int min_cost(std::vector<int> v){

// }
int min_cost(std::vector<int> h){
	// cout<<"hey"<<endl;
	int n = h.size();
	std::vector<int> v(n, INF);
	v[0] = 0;
	for(int i = 0; i<n; i++){
		for(int j : {i+1, i+2}){
			if(j<n){
				v[j] = min(v[j], v[i]+abs(h[j]-h[i]));
			}
		}
		// cout<<"iter: "<<i<<" ";
		// print(v);

	}
	return v[n-1];
}
int main(){
	int n;
	cin>>n;
	vector<int>h(n);
	for(int& x: h){
		cin>> x;
	}
	// print(h);

	int ans = min_cost(h);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 1; i < n; i++) {

        for (int i = 0; i < n-1; i++) cout << a[i] << " ";
        cout << a[n-1] <<endl;

        int v = a[i];
        int j = i - 1;
        while ((j>= 0) && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
    }
    for (int i = 0; i < n-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
    
    return 0;
}



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

template <typename T>
T gcd(T x, T y)
{
	return y == 0 ? x : gcd(y, x % y);
}

template <typename T>
std::vector<std::pair<T, int>> primeFactorization(T n)
{
	std::vector<std::pair<T, int>> answer;

	for (T i = 2; i * i <= n; ++i)
	{
		if (n % i != 0)
		{
			continue;
		}

		answer.emplace_back(i, 0);
		do
		{
			n /= i;
			answer.back().second++;
		} while (n % i == 0);
	}

	if (n != 1)
	{
		answer.emplace_back(n, 1);
	}

	return std::move(answer);
}

int main()
{
	long long A, B;
	std::cin >> A >> B;

	auto g = gcd(A, B);
	auto pf = primeFactorization(g);

	std::cout << pf.size() + 1;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        var numStr = Console.ReadLine().Split(' ');

        var nums = new List<int>();
        foreach (var n in numStr)
        {
            nums.Add(int.Parse(n));
        }
        nums.Sort();
        var count = 0;

        //一番長いの
        for(var i = 2; i < input; i++) 
        {
            //二番目に長いの
            for(var j = 1; j < i; j++)
            {
                var thirdMinLength = nums[i] -nums[j] + 1;
                var index = LowerBound(nums, thirdMinLength);

                if (index < j)
                {
                    count += j - index;
                }
                else
                {
                    if (j == i - 1)
                    {
                        break;
                    }
                }
                
            }
        }

        Console.WriteLine(count);
        Console.ReadLine();

    }

    ///<summary>昇順リストと値を渡すとその値が最初に出てくるインデックスを返す</summary>
    public static int LowerBound<T>(List<T> list, T value)
    {
        return LowerBound(list, value, Comparer<T>.Default);
    }

    ///<summary>昇順リストと値を渡すとその値が最初に出てくるインデックスを返す</summary>
    public static int LowerBound<T>(List<T> list, T value, Comparer<T> comparer)
    {
        var head = 0;
        var tail = list.Count - 1;

        //headがtailと同じ値になるタイミングがあり、そこでheadがtail+1になって出られる
        while (head <= tail)
        {
            var middle = head + (tail - head) / 2;

            switch (comparer.Compare(list[middle], value))
            {
                case 1:
                    tail = middle - 1;
                    break;
                case -1:
                    head = middle + 1;
                    break;
                case 0:
                    tail = middle - 1;
                    break;
            }
        }
        return head;
    }
}



Measured memory_bytes: 13280
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long

int main(){
    ll X, Y;
    cin >> X >> Y;
    int i = 0;
    do{
        X *= 2;
        i++;
    }while(X <= Y);
    cout << i;
}

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

int main() {
    int x, y, s;
    while(cin >> x >> y >> s, x) {
        int res = 0;
        for(int i=1; i<=1000; ++i) {
            for(int j=1; j<=1000; ++j) {
                if(i*(100+x)/100 + j*(100+x)/100 == s) {
                    res = max(res, i*(100+y)/100 + j*(100+y)/100);
                }
            }
        }
        cout << res << endl;
    }
}


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

A = [0] * (10 ** 5)

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            A[i**2 + j**2 + k**2 + i*j + j*k + k*i - 1] += 1

for i in range(0, N):
    print(A[i])


Measured memory_bytes: 69532
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int n;
    cin>>n;
    vector<pair<ll,ll>> ba(n); 
    for(int i=0;i<n;++i){
        cin>>ba[i].second >> ba[i].first;
    }
    sort(ba.begin(),ba.end());
    bool ok = true;
    ll sum = 0;
    for(int i=0;i<n;++i){
        sum += ba[i].second;
        if(sum > ba[i].first){
            ok = false;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3328
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    unsigned long int p[a],q[b],r[c];
    for(int i=0;i<a;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<b;i++)
    {
        cin>>q[i];
    }
    for(int i=0;i<c;i++)
    {
        cin>>r[i];
    }
    sort(p, p+a, greater<long long int>());
    sort(q, q+b, greater<long long int>());
    sort(r, r+c, greater<long long int>());
    long long int k=x+y+c;
    long long int z[k];
    for(long long int i=0;i<x;i++)
    {
        z[i]=p[i];
    }
    for(long long int i=x;i<x+y;i++)
    {
        z[i]=q[i-x];
    }
    for(long long int i=x+y;i<x+y+c;i++)
    {
        z[i]=r[i-x-y];
    }
    sort(z, z+k, greater<long long int>());
    unsigned long long int sum=0;
    for(int i=0;i<x+y;i++)
    {
        sum+=z[i];
    }
    cout<<sum<<endl;
    
    return 0;
}




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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int g[15][15];

int main(){
    int n;
    cin >> n;
    rep(i, n) rep(j, n) g[i][j] = -1;
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            g[i][--x] = y;
        }
    }
    int ans = 0;
    rep(i, 1<<n) {
        int d[15] = {};
        rep(j, n) {
            if (i>>j&1) d[j] = 1;
        }
        bool ok = true;
        rep(j, n) {
            if (d[j]) {
                rep(k, n) {
                    if (g[j][k]==-1) continue;
                    if (g[j][k]!=d[k]) ok = false;
                }
            }
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979
#define sc ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9+7;
ll const INF = 1e18;

int main()
{
	sc;
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	long double rad = PI * 2 * (
	(long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

	long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

	printf("%20.20Lf\n", sqrtl(rsq));

	return 0;

}

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

int main(void)
{
	int i,j,k,N,D,d_1,d_2,ans=0;

	cin >> N >> D;

	int x[N][D];

	for(i=0;i<N;i++)
	{
		for(j=0;j<D;j++)
		{
			cin >> x[i][j];

		}

	}
	
	for(i=0;i<N-1;i++)
	{
		for(j=i+1;j<N;j++)
		{
			d_1=0;
			d_2=0;
			for(k=0;k<D;k++)
			{
				d_1+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}

			d_2=sqrt(d_1);

			if(d_1==d_2*d_2)
			{
				ans++;
			}
		}
	}
	
	cout << ans << endl;

}



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

int main(){

    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    /*for(int i=0; i<n; i++){
        cout << a.at(i) << endl;
    }
    cout << endl;*/

    vector<tuple<int,int>> bc(m);
    int b,c;
    for(int i=0; i<m; i++){
        cin >> b >> c;
        bc.at(i)=make_tuple(c,b);
    }
    sort(bc.begin(),bc.end(),greater<>());
    /*for(int i=0; i<m; i++){
        cout << get<0>(bc.at(i)) << ' ' << get<1>(bc.at(i)) << endl;
    }
    cout << endl;*/

    int i=0, j=0;
    while(1){
        if(a.at(i) < get<0>(bc.at(j))){
            a.at(i)=get<0>(bc.at(j));
            get<1>(bc.at(j))--;
            if(get<1>(bc.at(j))==0) j++;
        }
        i++;
        if(i==n || j==m) break;
            //cout << get<0>(bc.at(0)) << ' ' << get<1>(bc.at(0)) << endl;
            //cout << a.at(i) << endl;
    }

    long long int ans=0;
    for(int i=0; i<n; i++){
        ans+=a.at(i);
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4560
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String s = sc.next();

        int len = s.length();

        System.out.print(String.valueOf(s.charAt(0)));
        System.out.print(len-2);
        System.out.print(String.valueOf(s.charAt(len-1)));
    }
}

Measured memory_bytes: 35548
n = gets.to_i
array = gets.chomp.split(" ").map(&:to_i)
sum = 0

(0...array.length - 2).each do |number|
  local = array.slice(number..number+2)
  if local.max != local[1] && local.min != local[1]
    sum += 1
  end
end

puts sum

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

using namespace std;

#define ll long long

int cntD(ll i){
	int cnt = 0;
	if( i == 0) return 1;
	while(i>0){
		i /= 10;
		++cnt;
	}
	return cnt;
}

ll f (ll i, ll j){
	return max(cntD(i), cntD(j));
}

int main(){
	ll n; 
	cin >> n;
	ll d = cntD(n);
	for(ll a = 1; a*a<=n; ++a){
		if(n%a != 0) continue;
		ll b = n/a;
		d = min(d, f(a,b));
	}
	cout << d;
	return 0;
}


Measured memory_bytes: 3644
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
sita=0
mannaka=0
ue=0
for pi in p:
    if pi <= a:
        sita+=1
    elif a+1 <= pi<=b:
        mannaka+=1
    else:
        ue+=1
print(min(ue,min(sita,mannaka)))

Measured memory_bytes: 3064
import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    las = copy.copy(last)
    las[contestType] = day
    gain = s[day][contestType]
    lost = 0
    for i in range(8):
        for j in range(26):
            lost += c[j]*(i - las[j])
    return gain - 1.3*lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)
    x = random.randint(0,(d-1)-10)
    idx1 = x
    idx2 = x+random.randint(1,5)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    
    #ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.8):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x + 1)
    #print(evaluateSatisfaction(d,c,s,ans))

Measured memory_bytes: 9972
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: i32 = input();
    let mut ab: Vec<(i32, i32)> = (0..n).map(|_| (input(), input())).collect();
    ab.sort_by_key(|&(a, b)| (-a, -b));

    let mut w = std::collections::BinaryHeap::new();
    let mut t = 0;
    let mut ans = 0;
    for (a, b) in ab {
        if t + a <= m {
            t += 1;
            ans += b;
            w.push(Reverse(b));
        } else {
            if let Some(Reverse(x)) = w.pop() {
                if b > x {
                    ans += b - x;
                    w.push(Reverse(b));
                } else {
                    w.push(Reverse(x));
                }
            }
        }
    }

    println!("{}", ans);
}

#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
struct Reverse<T>(T);
impl<T: Ord> Ord for Reverse<T> {
    fn cmp(&self, other: &Reverse<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}
impl<T: PartialOrd> PartialOrd for Reverse<T> {
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> vec;
    for(int i=0; i<2*n ; i++){
        int a;
        cin >> a;
        vec.push_back(a);
    }
    sort(vec.begin(),vec.end());
    int cnt = 0;
    for(int i=0; i<2*n-1; i+=2){
        cnt += min(vec[i],vec[i+1]);
//        cout << vec[i] << " " << vec[i+1] << endl;
//        cout << cnt <<endl;
    }
    cout << cnt <<endl;
    return 0;
}

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

int H, W;
long long ans = 1e18;

void solve() {
	int h = H / 2;
	for (int i = 1; i < W; ++i) {
		// H
		long long s1 = 1LL * i * H;
		long long s2 = 1LL * (W - i) * h;
		long long s3 = 1LL * (W - i) * (H - h);
		long long cur = 0;
		cur = max(cur, abs(s1 - s2));
		cur = max(cur, abs(s2 - s3));
		cur = max(cur, abs(s3 - s1));
		ans = min(ans, cur);
	}
	if (W % 3 == 0) ans = 0;
	else ans = min(ans, (long long)H);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> H >> W;
	solve();
	swap(H, W);
	solve();
	cout << ans << endl;
}

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

double memo [101][102];
double mp[101][101];
double ans;
int n,m;
int cnt;

void saiki(double seki,double pseki,int mae,int kai) {
  //  cout <<"seki="<<seki<<" mae="<<mae<<" kai="<<kai<<endl;
  cnt++;
  
  if(kai == m && ans < seki) ans = seki;
  if(kai == m && mae != -1) memo[kai][mae] = 1;
  
  if(kai < m) {
    for(int i=1;i<=n;i++) {
      if(memo[kai+1][i] == -1) {
	saiki(seki*mp[mae][i],seki,i,kai+1);
	if(memo[kai][mae] < memo[kai+1][i]*mp[mae][i]) memo[kai][mae] = memo[kai+1][i]*mp[mae][i];
      }
      else {
	if(memo[kai][mae] < memo[kai+1][i]*mp[mae][i])memo[kai][mae] = memo[kai+1][i]*mp[mae][i];
	saiki(memo[kai][mae]*seki,-1,-1,m);
      }
    }
  }
}

int main(){
  
  while(1){
    cin >> n>> m;
    if(n == 0 && m == 0) break;
    
    for(int i=0;i<=n;i++)
      for(int j=0;j<=n;j++)
	if(i == 0 || j == 0) mp[i][j] = 1;
	else cin >> mp[i][j];

    
    for(int i=0;i<=m;i++)
      for(int j=0;j<=n;j++)
	memo[i][j] = -1;

    ans = 0;
    
    int ans2=0;
    for(int i=1;i<=n;i++) {
      saiki(1,1,i,1);
      for(int j=0;j<=n;j++){
	if(ans2 < memo[1][i]) ans2 = memo[1][i];
	memo[1][i] = memo[2][i]= -1;
      }
      for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
    } 
    

    
    //    cout << ans2 << endl;
    printf("%.2f\n",ans);
    //cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int N;
	get1int(N);

	int odd = N / 2;
	if (N % 2) odd++;

	printf("%.7lf\n", (double)odd / (double)N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll n;
        cin >> n;
        ll x, y;
        for(ll i = 1;i * i <= n;i++){
                if(n % i == 0){
                        x = i;
                        y = n/i;
                }
        }
        cout << x + y - 2 << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to, cor; };
int c[4005], a[4005];
int dp[2005][2005];
int bit[5000];
vector<P>B, W;
int n;
int sum(int i) {
	int s = 0;
	while (i) {
		s +=bit[i];
		i -= i&-i;
	}
	return s;
}
void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i&-i;
	}
}

signed main() {
	cin >> n;
	int q; cin >> q;
	rep(i, q) {
		int a, b, c; cin >> a >> b >> c;
		if (a == 0) {
			add(b, c);
		}
		else {
			cout << sum(c) - sum(b - 1) << endl;
		}
	}
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>swit(n,0);
    
    for(int i=0;i<m;i++){
        int g;
        cin>>g;
        for(int h=0;h<g;h++){
            int s;
            cin>>s;
            s--;
            swit[s] |= 1<<i;
        }
    }
    int p=0;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        p |= x<<i;
    }
    int ans=0;

    for(int s=0;s<(1<<n);s++){
        int t=0;
        for(int i=0;i<n;i++){
            if(s>>i&1){
                t^=swit[i];
            }
        }
        if(t==p){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int a[100];

int main() {
    int n;
    while(cin>>n, n) {
        for(int i=0; i<n; ++i) cin>>a[i];

        int rem = 32,cnt = 0;
        while(rem > 0) {
            rem -= (rem-1)%5;
            cout<<rem<<endl;
            if(rem == 0) break;
            rem -= min(rem,a[cnt%n]);
            cout<<rem<<endl;
            cnt++;
        }
    }
}

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

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		vector<string> ANS;
		for (int j = 1; j < S.size(); j++) {
			string A = S.substr(0, j), B = S.substr(j, S.size() - j);
			for (int k = 0; k < 4; k++) {
				if (k & 1) reverse(A.begin(), A.end());
				else if (k & 2) reverse(B.begin(), B.end());
				ANS.push_back(A + B);
				ANS.push_back(B + A);
			}
		}
		sort(ANS.begin(), ANS.end());
		ANS.erase(unique(ANS.begin(), ANS.end()), ANS.end());
		cout << ANS.size() << endl;
	}
}


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

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

int main()
{
    long long N, M;
    cin >> N >> M;
    long long n = 1;
    vector<long long> a(N), pow2Count(N, 0);
    bool is_ok = true;
    rep(i, N)
    {
        cin >> a[i];
        int b = a[i] / 2;
        while (a[i] % 2 == 0)
        {
            a[i] /= 2;
            pow2Count[i]++;
        }
        n = lcm(n, b);
        if (n > M)
        {
            is_ok = false;
        }
    }

    rep(i, N)
    {
        if (pow2Count[0] != pow2Count[i])
            is_ok = false;
    }
    if (!is_ok)
    {
        cout << 0 << endl;
        return 0;
    }
    long long ans = max((M + n - 1) / (2 * n), (ll)0);
    if (M == n)
        ans++;
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  if(n == 1 || n % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[i+n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    ll ans = INF;
    for(ll x=-100; x<=100; x++) {
        ll can = 0;
        rep(i, n) can += (x-a[i])*(x-a[i]);
        chmin(ans, can);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620