akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int field[22][22];
int num;

const int RED = 0;
const int BLACK = 1;

void dfs(int x, int y) {
	++num;
	field[y][x] = RED;


	if(field[y-1][x] == BLACK) {
		dfs(x, y-1);
	}

	
	if(field[y][x-1] == BLACK) {
		dfs(x-1, y);
	}
	
	if(field[y][x+1] == BLACK) {
		dfs(x+1, y);
	}
	
	if(field[y+1][x] == BLACK) {
		dfs(x, y+1);
	}
}

int main() {
	int w, h;

	while(cin >> w >> h, w, h) {
		REP(i, 22) {
			REP(j, 22) {
				field[i][j] = RED;
			}
		}

		int startx, starty;

		FOR(i, 1, h+1) {
			FOR(j, 1, w+1) {
				char c;
				cin >> c;
				if(c == '.') {
					field[i][j] = BLACK;
				} else if(c == '#') {
					field[i][j] = RED;
				} else {
					startx = j, starty = i;
					field[i][j] = BLACK;
				}
			}
		}

		num = 0;
		dfs(startx, starty);

		cout << num << endl;
	}
}

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

int main(){
  int n,k;  
  cin>>n>>k;
  int p[1005];
  rep(i,n) cin>>p[i];
  sort(p,p+n);
  int ans=0;
  rep(i,k) ans+=p[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3648
N, K = map(int, input().split())
sunuke_list = [False for n in range(N)]

for k in range(K):
    d = int(input()) 
    kasi = list(map(int, input().split()))
    
    for j in kasi:
        sunuke_list[j-1] = True

print(N-sum(sunuke_list))

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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var a = ReadLong();
		Console.WriteLine(a + a * a + a * a * a);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 27524
#include <iostream>

using namespace std;

int N;
bool open[10];
bool F[100][10];
long P[100][11];

long benefit() {
	long sum = 0;

	for (int i = 0; i < N; i++) {
		int n = 0;
		for (int j = 0; j < 10; j++) {
			if (F[i][j] && open[j]) n++;
		}

		sum += P[i][n];
	}

	return sum;
}

int main(int argc, char *argv[]) {
	cin >> N;

	for (int i = 0; i < N; i++)
		for (int j = 0; j < 10; j++)
			cin >> F[i][j];
	for (int i = 0; i < N; i++)
		for (int j = 0; j <= 10; j++)
			cin >> P[i][j];

	long ans = -10000000000;
	for (long i = 1; i < (1 << 10); i++) {
		for (int j = 0; j < 10; j++) 
			open[j] = (i & (1L << j)) ? true : false;

		ans = max(ans, benefit());
	}

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

Measured memory_bytes: 256
N,x=map(int,input().split())
a=sorted(map(int,input().split()))
c=0
if x>sum(a):
  print(N-1)
  exit()

while x>0 and c<=N-1:
  if x-a[c]>=0:
    x-=a[c]
    c+=1
  else:
    break


print(c)

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   int a[n] , val = 0;
   for(int i = 0 ; i < n ; i++){
      cin >> a[i];
      val ^= a[i];
   }
   for(int i = 0 ; i < n ; i++)
      cout << (val ^ a[i]) << " ";
   return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    set<int> a = {1, 3, 5, 7, 8, 10, 12};
    set<int> b = {4, 6, 9, 11};
    set<int> c = {2};

    if (a.find(x) != a.end() && a.find(y) != a.end())
        cout << "Yes";
    else if (b.find(x) != b.end() && b.find(y) != b.end())
        cout << "Yes";
    else if (c.find(x) != c.end() && c.find(y) != c.end())
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	
	vector<vector<int>> to(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	
	vector<int> a(n-1);
	rep(i,n-1) a[i] = i+1;
	
	ll res = 0;
	do{
		bool isNG = false;
		auto result = find(to[0].begin(), to[0].end(), a[0]);
		if(result == to[0].end()) isNG = true;
		rep(i,n-2){
			result = find(to[a[i]].begin(), to[a[i]].end(), a[i+1]);
			if(result == to[a[i]].end()){
				isNG = true;
				break;
			}
		}
		
		if(!isNG) res++;
	}while(next_permutation(a.begin(),a.end()));
	
	
	cout << res << endl;
	return 0;
}

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

avg = sum(X) // N

c1 = avg
c2 = avg + 1

ans1 = 0
ans2 = 0
for xi in X:
    ans1 += (xi - c1) ** 2
    ans2 += (xi - c2) ** 2

ans = min(ans1, ans2)
print(ans)




Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int n;
int x[10], y[10];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx*dx+dy*dy, 0.5);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

	double ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {	
			ans += dist(i, j) * 2 / n;
		}
	}

	printf("%8lf\n", ans);
    return 0;
}


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

typedef struct _elem {
  struct _elem *next;
  int data;
} elem;

elem head = { &head, -1 };

void insert(int data) {
  elem *new;
  new = (elem *)malloc(sizeof(elem));

  new->data = data;
  new->next = head.next;
  head.next = new;
}

int search(int data) {
  elem *p;
  p = head.next;

  head.data = data;

  while(p->data != data)
    p = p->next;

  return p != &head;
}

int main() {
  int n, q, i, tmp, cnt;
  cnt = 0;

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%d", &tmp);
    insert(tmp);
  }

  scanf("%d", &q);
  for(i = 0;i < q;i++) {
    scanf("%d", &tmp);
    if(search(tmp))
      cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}



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

int n, M[MAX][MAX];

int prim() {
	int d[MAX], p[MAX], vmin, u, color[MAX];
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}
	d[0] = 0;
	while (true) {
		vmin = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (d[i] < vmin && color[i] != BLACK) {
				vmin = d[i];
				u = i;
			}
		}
		if (u == -1) {
			break;
		}
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (M[u][v] != INFTY && color[v] != BLACK) {
				if (M[u][v] < d[v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}

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


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

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				M[i][j] = INFTY;
			}
		}

		for (int i = 0; i < m; i++) {
			int a, b, c;
			char d, e;
			cin >> a >> d >> b >> e >> c;
			M[a][b] = c / 100 - 1;
			M[b][a] = c / 100 - 1;
		}

		cout << prim() << endl;
	}
	return 0;

}


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

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

int main(){
	int N, M, num;
	cin >> N >> M;
	vector<int> vec(N);
	num = 0;
	rep(i, N) { 
		cin >> vec.at(i); 
		num += vec.at(i);
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	if (vec.at(M - 1) * 4 * M < num) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

using namespace std;

// input
int n;
vector<int> vec;

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

    cin >> n;

    int next = 1;
    vec.push_back(1);

    for(int i = 1;next < 100;i++){
        vec.push_back(pow(2,i));
        
        next = pow(2,i);
    }

    int index = 0;

    while(true){
        if(n < vec[index]){
            break;
        }
        index++;
    }

    cout << vec[index-1] << "\n";
}

Measured memory_bytes: 256
import java.util.*

fun Double.ceil() : Int {
    return Math.ceil(this).toInt()
}

fun main(args : Array<String>){
    val cin = Scanner(System.`in`)
    val x : Double = cin.nextInt().toDouble()

    val n = ((-1 + Math.sqrt(1 + 8 * x)) / 2).ceil()

    println(n)
}

Measured memory_bytes: 21680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>b.second;
}

int h,w;
int a[510][510];
int c;
int ans[300000][4];
int main(){
    cin >> h >> w;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 1; i <= h; i++){
        if(i%2 == 1){
            for(int j = 1; j <= w; j++){
                if(a[i][j] % 2 != 0){
                    if(j != w){
                        ans[c][0] = i;
                        ans[c][1] = j;
                        ans[c][2] = i;
                        ans[c][3] = j+1;
                        ++a[i][j+1];
                    }
                    else{
                        if(i == h)  break;
                        ans[c][0] = i;
                        ans[c][1] = j;
                        ans[c][2] = i+1;
                        ans[c][3] = j;
                        ++a[i+1][j];                        
                    }
                    ++c;
                }
            }
        }
        else{
            for(int j = w; j >= 1; j--){
                if(a[i][j] % 2 != 0){
                    if(j != 1){
                        ans[c][0] = i;
                        ans[c][1] = j;
                        ans[c][2] = i;
                        ans[c][3] = j-1;
                        ++a[i][j-1];
                    }
                    else{
                        if(i == h)  break;
                        ans[c][0] = i;
                        ans[c][1] = j;
                        ans[c][2] = i+1;
                        ans[c][3] = j;
                        ++a[i+1][j];                        
                    }
                    ++c;
                }
            }
        }
    }

    cout << c << endl;
    for(int i = 0; i < c; i++){
        for(int j = 0; j < 3; j++){
            cout << ans[i][j] << ' ';
        }
        cout << ans[i][3] << '\n';
    }
}

Measured memory_bytes: 5120
A=[0 for  d in range(26)]
while True:
	try:
		s=list(input())
		for n in range(len(s)):
			c=ord(s[n])
			if 97 <= c and c <= 122:
				A[c-97]+=1
			elif 65 <= c and c <= 90:
				A[c-65]+=1
	except EOFError:
		break
for n in range(26):
	print(f"{chr(97+n)} : {A[n]}")




Measured memory_bytes: 5580
import java.util.Arrays;
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();

    long min = minDiff3(divide3(H), W);
    min = Math.min(min, minDiff3(divide3(W), H));
    min = Math.min(min, minDiff2(divide2(H), W));
    min = Math.min(min, minDiff2(divide2(W), H));
    System.out.println(min);
  }

  private static long minDiff3(int[] d, long o) {
    Arrays.sort(d);
    return Math.max(d[1] - d[0], d[2] - d[1]) * o;
  }

  private static long minDiff2(int[] d, long o) {
    long diff = Long.MAX_VALUE;
    for (long i = 1; i < o; i++) {
      diff = Math.min(diff, maxDiff(d[0] * i, d[1] * i, (d[0] + d[1]) * (o - i)));
    }
    return diff;
  }

  private static long maxDiff(long a, long b, long c) {
    if (a > b) return maxDiff(b, a, c);
    if (b > c) return maxDiff(a, c, b);
    return c - a;
  }

  private static int[] divide2(int n) {
    return new int[]{n / 2, n - n / 2};
  }

  private static int[] divide3(int n) {
    int[] d1 = new int[]{0, 0, n / 3};
    int[] d2 = divide2(n - n / 3);
    System.arraycopy(d2, 0, d1, 0, 2);
    return d1;
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dat[100000];
ll rui[100001];
ll r2[100001];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	for (int i = 0; i < num; i++)scanf("%lld", &dat[i]);
	for (int i = 0; i < num; i++)
	{
		rui[i + 1] = rui[i] + dat[i];
		if (dat[i] >= 0)r2[i + 1] = r2[i] + dat[i];
		else r2[i + 1] = r2[i];
	}
	ll maxi = 0;
	for (int i = 0; i < num - kai + 1; i++)
	{
		maxi = max(maxi, (r2[i] - r2[0]) + (max(0LL,rui[i + kai] - rui[i])) + (r2[num] - r2[i + kai]));
	}
	printf("%lld\n", maxi);
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  double l,r;
  int al=0,ar=0,bl=0,br=0,cl=0,cr=0,dl=0,dr=0;
  
  while(scanf("%lf%lf",&l,&r)!=EOF){
    if(l>=1.1){
      al++;
    }
    else if(l>=0.6){
      bl++;
    }
    else if(l>=0.2){
      cl++;
    }
    else{
      dl++;
    }
    if(r>=1.1){
      ar++;
    }
    else if(r>=0.6){
      br++;
    }
    else if(r>=0.2){
      cr++;
    }
    else{
      dr++;
    }
  }
  printf("%d %d\n%d %d\n%d %d\n%d %d\n",al,ar,bl,br,cl,cr,dl,dr);
  return 0;
}

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

#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define MOD 998244353
#define MAXN 3005

typedef long long ll;

long long modinverse(long long a, long long mod) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll dp[MAXN][MAXN];
int main(){
    int n,s;cin >> n >> s;
    vector<int> v(n); rep(i,n) cin >> v[i];
    rep(i,MAXN) dp[0][i] = 0;
    dp[0][0] = myPow(2,n,MOD);
    for(int i=1; i < n+1;i++){
        int c= v[i-1];
        rep(j,s+1) dp[i][j] = dp[i-1][j];
        rep(j,s){
            if(j + c <= s){
                dp[i][j + c] = (dp[i][j + c] + ((dp[i-1][j] * modinverse(2, MOD)) % MOD)) % MOD;
            }
        }
    }


    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73992
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int N = s.size();
  int fr, ed;
  for(int i = 0; i < N; i++){
    if(s[i] == 'A') {fr = i;
    break;}
  }
  for(int i= 0; i < N; i ++){
    if(s[i] == 'Z') ed = i;
  }
  cout << ed +1 -fr << endl;
}

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

int main() {
    int sum=0, t;
    for (int i = 0; i < 5; i++) {
        scanf("%d", &t);
        (t > 40) ? sum+= t : sum+=40;
    }
    printf("%d\n", sum/5);
    return 0;
}



Measured memory_bytes: 2692
// AOJ 1227: 77377
// 2017.10.17 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 500

int n;
char word[102][52]; int len[102];
char seq[303];
char ans[303];

char tr['z'];

void parse(char *ans, int w, char *s, int sz)
{
	int i, j, k;
	char *p, *q, *u, *v;

	for (i = 0; i < n; i++) if ((j = len[i]) <= sz) {
		p = word[i], q = s;
		while (*p && *q && tr[*p] == *q) p++, q++;
		if (*p) continue;
		if (*q) {
			u = v = malloc(MAX), k = w;
			if (k > 0) {
				memcpy(v, ans, k); v += k;
				*v++ = ' ', k++;
			}
			strcpy(v, word[i]);
			parse(u, k+j, s+j, sz-j);
			free(u);
		} else {
			v = ans + w; if (w > 0) *v++ = ' ';
			strcpy(v, word[i]), v += j;
			*v++ = '.', *v = 0;
			puts(ans);
		}
	}
}

int main()
{
	int i;

	tr['a']=tr['b']=tr['c'] = '2'; tr['d']=tr['e']=tr['f'] = '3';
	tr['g']=tr['h']=tr['i'] = '4'; tr['j']=tr['k']=tr['l'] = '5';
	tr['m']=tr['n']=tr['o'] = '6'; tr['p']=tr['q']=tr['r']=tr['s'] = '7';
	tr['t']=tr['u']=tr['v'] = '8'; tr['w']=tr['x']=tr['y']=tr['z'] = '9';
	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%s", word[i]), len[i] = strlen(word[i]);
		scanf("%s", seq);
		parse(ans, 0, seq, strlen(seq));
		puts("--");
	}
	return 0;
}

Measured memory_bytes: 1840
import bisect

n = int(input())
s = input()

dic = {}
dic['R'] = []
dic['G'] = []
dic['B'] = []

for i in range(n):
    dic[s[i]].append(i)

rem = {}

rem['G'] = ['R', 'B']
rem['B'] = ['R','G']
rem['R'] = ['B', 'G']

res=0

for i in range(n):
    neigh1 = rem[s[i]][0]
    neigh2 = rem[s[i]][1]
    ind = bisect.bisect_right(dic[neigh1],i)
    for j in range(ind, len(dic[neigh1])):
        node = dic[neigh1][j]
        nind = bisect.bisect_right(dic[neigh2],node)

        l = max(0,len(dic[neigh2])-nind)

        diff = node-i
        if node+diff>=nind and node+diff<n and s[node+diff]==neigh2:
            l-=1

        res+=l

    ind = bisect.bisect_right(dic[neigh2],i)
    for j in range(ind, len(dic[neigh2])):
        node = dic[neigh2][j]
        nind = bisect.bisect_right(dic[neigh1],node)

        l = max(0,len(dic[neigh1])-nind)

        diff = node-i
        if node+diff>=nind and node+diff<n and s[node+diff]==neigh1:
            l-=1

        res+=l

print(res)

    
        





Measured memory_bytes: 75644
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    rep(i, (n-1)/2){
        
    }
    string f, b;
    f = s.substr(0, (n-1)/2);
    b = s.substr((n+3)/2-1);
    string ans = "No";
    string f1 = f;
    reverse(f.begin(), f.end());
    string b1 = b;
    reverse(b.begin(), b.end());
    string s1 = s;
    reverse(s.begin(), s.end());
    if(f == f1 && b == b1 && s == s1){
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	int odd_count = N / 2 + (N % 2 == 1);

	cout.setf(ios::fixed);
	cout.precision(10);

	cout << static_cast<float>(odd_count) / static_cast<float>(N);

	return 0;
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  int result=0;
  for(int i=0; i<1000; i++){
    string p=to_string(i);
    while(p.size()<3){
      p='0'+p;
    }
    int m=0;
    for(int j=0; j<N; j++){
      if(S[j]==p[m]) m++;
      if(m==3) break;
    }
    if(m==3) result++;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	for(int i=0;i<4;i++){
		int a,b;
		cin>>a>>b;
		if(a==1){
			cout<<b*6000<<endl;
		}
		if(a==2){
			cout<<b*4000<<endl;
		}
		if(a==3){
			cout<<b*3000<<endl;
		}
		if(a==4){
			cout<<b*2000<<endl;
		}
	}
	return 0;
}		



Measured memory_bytes: 3092
import kotlin.math.*

//private val inp = java.io.File("in")
private val inp = System.`in`
private val reader = inp.bufferedReader()
private val wr = java.io.PrintWriter(System.out.bufferedWriter())

private fun readLn(): String = reader.readLine()
private fun readInt(): Int = readLn().toInt()
private fun readStrs(): List<String> = readLn().split(" ")
private fun readInts(): IntArray = readStrs().map { it.toInt() }.toIntArray()
private fun readChars(): CharArray = readStrs().map { it.single() }.toCharArray()

fun main() {
    var (a, b, c, d) = readInts()
    var takashi = true
    while (a > 0 && c > 0) {
        if (takashi) {
            c -= b
        } else {
            a -= d
        }
        takashi = !takashi
    }
    println(if (a <= 0) "No" else "Yes" )
}

Measured memory_bytes: 36372
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
ans = 0
state = 0

for i in range(N-1):
    if A[i+1]-A[i]>0:
        if state==2:
            ans += 1
            state = 0
        elif state==0:
            state = 1
    elif A[i+1]-A[i]<0:
        if state==1:
            ans += 1
            state = 0
        else:
            state = 2

ans += 1
print(ans)

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

using namespace std;

class UnionFind {
    public:
        UnionFind(int N) : root(N), tree_rank(N, 0), tree_size(N, 1) {
            for(int i = 0; i < N; i++) root[i] = i;
        }

        int FindRoot(int x) {
            if (root[x] == x) return x;

            root[x] = FindRoot(root[x]);
            return root[x];
        }

        bool IsSameTree(int x, int y) {
            return (FindRoot(x) == FindRoot(y));
        }

        void MergeTree(int x, int y) {
            x = FindRoot(x);
            y = FindRoot(y);
            if (x == y) return;

            if (tree_rank[x] < tree_rank[y]) swap(x, y);
            root[y] = x;
            tree_size[x] += tree_size[y];
            if (tree_rank[x] == tree_rank[y]) tree_rank[x]++;
        }

        int GetTreeSize(int x){
            return tree_size[FindRoot(x)];
        }

    private:
        vector<int> root;
        vector<int> tree_rank;
        vector<int> tree_size;
};


int main() {
    // Input
    int N, M, K;
    vector<int> A, B, C, D;

    cin >> N >> M >> K;
    A = vector<int>(M);
    B = vector<int>(M);
    C = vector<int>(K);
    D = vector<int>(K);
    for (int i = 0; i < M; i++) cin >> A[i] >> B[i];
    for (int i = 0; i < K; i++) cin >> C[i] >> D[i];

    // Process
    UnionFind tree(N);
    for (int i = 0; i < M; i++){
        tree.MergeTree(A[i] - 1, B[i] - 1);
    }

    vector<int> ans = vector<int>(N);
    for (int i = 0; i < N; i++){
        ans[i] = tree.GetTreeSize(i) - 1;
    }

    for (int i = 0; i < M; i++){
        ans[A[i] - 1]--;
        ans[B[i] - 1]--;
    }

    for (int i = 0; i < K; i++){
        if (tree.IsSameTree(C[i] - 1, D[i] - 1)){
            ans[C[i] - 1]--;
            ans[D[i] - 1]--;
        }
    }

    // Output
    for (int i = 0; i < N; i++){
        if (i == 0) printf("%d", ans[i]);
        else printf(" %d", ans[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3968
N, Y = map(int,input().split())
for i in range(2001):
    for j in range(2001):
        k = N - i -j
        if (k < 0):
            break
        if (10000 * i + 5000 * j + 1000 * k == Y):
            print(str(i) + ' ' + str(j) + ' ' + str(k))
            quit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::sort;
using std::min;
const int MAXN=400010;
const int INF=2e9;
struct Edge {
    int u,v,w;
    friend bool operator<(Edge a,Edge b) {
        return a.w<b.w;
    }
}ed[MAXN];
int cnt=0;
inline void join(int x,int y,int z) {
    ed[++cnt].u=x;
    ed[cnt].v=y;
    ed[cnt].w=z;
    return;
}
int f[MAXN];
inline void init(int n) {
    for(int i=0;i<=n;++i) {
        f[i]=i;
    }
}
int find(int x) {
    return x==f[x]?x:(f[x]=find(f[x]));
}
int best[MAXN];
int main() {
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<=n;++i) {
        best[i]=INF;
    }
    int x,y,z;
    for(int i=1;i<=q;++i) {
        scanf("%d%d%d",&x,&y,&z);
        join(x,y,z);
        best[x]=min(best[x],z+1);
        best[y]=min(best[y],z+2);
    }	
    for(int i=0;i<n*2;++i) {
        best[(i+1)%n]=min(best[(i+1)%n],best[i%n]+2); //n*2防止更新了n-1到0 
    }
    for(int i=0;i<n;++i) {
        if(best[i]!=INF) join(i,(i+1)%n,best[i]);
    }
    init(n);
    sort(ed+1,ed+1+cnt);
    long long ans=0;
    for(int i=1;i<=cnt;++i) {
        int a=find(ed[i].u),b=find(ed[i].v);
        if(a!=b) {
            ans+=ed[i].w;
            f[a]=b;
        }
    }
    printf("%lld",ans);
    return 0;
}
//rt


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

int main() {
	string s;
	cin >> s;
	if (s == "SSS")
		cout << 0 << "\n";
	else if (s == "RRR")
		cout << 3 << "\n";
	else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR")
		cout << 1 << "\n";
	else
		cout << 2 << "\n";
	return 0;
}


Measured memory_bytes: 3616
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int main(){
  int A, B; cin >> A >> B;
  cout << A * B << " " << (A + B) * 2 << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
#define ll long long
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    int tmp=0;
    int cnt4=0,cnt2=0,cntodd=0;
    rep(i,N){
        cin>>tmp;
        if(tmp%2!=0){
            cntodd++;
        }else if(tmp%4!=0){
            cnt2++;
        }else{
            cnt4++;
        }
    }
//    cout << cnt4 << ":" << cnt2 << ":" << cntodd << endl;
    //Nが偶数の時⇒奇数が過半数ならOUT;
    //Nが奇数の時⇒奇数が過半数+1ならOUT;
    if(N%2==0){
        if(cntodd>N/2){
            cout << "No" << endl;
            return 0;
        }
    }
    if(N%2!=0){
        if(cntodd>N/2+2){
            cout << "No" << endl;
            return 0;
        }
    }
    //奇数の隣は4の倍数が必須
    //逆に言うとそれさえ守れていればあとは偶数偶数で並ぶのでOK
    //4の倍数の個数>=奇数の個数なら無条件でOK
    if(cnt4>=cntodd){
        cout << "Yes" << endl;
        return 0;
    }
    //4の倍数の個数+1<奇数の個数なら強制OUT
    if(cnt4+1<cntodd){
        cout << "No" << endl;
        return 0;
    }
    //4の倍数の個数+1=奇数の個数の場合
    //き、４、き、４、き...と並べていき最後にきが来るので偶数が残ってたらOUT
    if(cnt4+1==cntodd){
        if(cnt2!=0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstring>
using namespace std;
typedef long long int LL;
char ca[1000005];


int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	LL s[100][2];
	LL t[5];
	cin>>n;
	cin>>ca;
	cin>>m;
	memset(s,0,sizeof(s));
	for(i=0;i<m;i++){
		cin>>s[i][0];
	}
	for(i=0;i<m;i++){
		memset(t,0,sizeof(t));
		for(j=0;j<n;j++){
			if(ca[j]=='D')break;
		}
		if(j==n){
			cout<<0<<endl;
			continue;
		}
		c=j;
		for(j=c+1;j<n&&j<c+s[i][0];j++){
			if(ca[j]=='M')t[1]++;
			if(ca[j]=='C')t[2]+=t[1],t[3]++;
		}
		s[i][1]+=t[2];
		for(j=c+1;j<n;j++){
			k=j+s[i][0]-1;
			if(k<n){
				if(ca[k]=='M')t[1]++;
				if(ca[k]=='C')t[2]+=t[1],t[3]++;
			}
			if(ca[j]=='D')s[i][1]+=t[2];
			if(ca[j]=='M')t[1]--,t[2]-=t[3];
			if(ca[j]=='C')t[3]--;
			//cout<<t[1]<<" "<<t[2]<<" "<<t[3]<<endl;
		}
		cout<<s[i][1]<<endl;
	}
}




Measured memory_bytes: 1280
import math
a,b,x = [int(x) for x in input().split()]
c = 2*b/a - 2*x/a**3
if c > 2*x/a**3:
  print(math.degrees(math.atan(a*b**2/(2*x))))
else:
  print(math.degrees(math.atan(c)))

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  vector<ll> a;
  cin >> n;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    if(i == 0)a.pb(x);
    else a.pb(a[i-1] + x);
  }
  a.pb(0);
  sort(a.begin(), a.end());
  ll res = 0;
  ll curr = 0;
  for(int i = 0; i <= n; i++){
    if(i == 0 || a[i] != a[i - 1]){
      res += curr * (curr - 1) / 2;
      curr = 1;
    }else{
      curr++;
    }
  }
  res += curr * (curr - 1) / 2;
  cout << res << endl;
	return 0;
}


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

int d;
int x[12][12];

int is_integer(int i, int j) {
  int dist = 0, inc = 1;
  rep (k, d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
  rep (inc, 10000) if (inc * inc == dist) return 1;
  return 0;
}

int main() {
  int n;
  cin >> n >> d;
  int ans = 0;
  rep (i, n) rep (j, d) cin >> x[i][j];
  rep (i, n) rep (j, i) ans += is_integer(i, j);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = (r/d)-((l+d-1)/d);
    cout << ans+1 << "\n";
  }
}



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

using namespace std;

typedef vector<vector<int> > graph;
vector<int> color;
graph G;

bool dfs(int s, int c) {
    color[s] = c;
    for (int i = 0; i < G[s].size(); i++) {
        int v = G[s][i];
        if (color[v] == c)
            return false;
        else if (color[v] == 0 && !dfs(v, -c))
            return false;
    }
    return true;
}

int main() {
    long long n, m;   cin >> n >> m;
    G = graph(n);
    color.resize(n);
    for (int i = 0; i < n; i++)
        color[i] = 0;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    if (dfs(0, 1)) {
        long long B = 0, W = 0;
        for (int i = 0; i < n; i++) {
            if (color[i] == 1)
                B++;
            else if (color[i] == -1)
                W++;
            
        }
        cout << B * W - m << endl;
    }
    else {
        cout << ((n*(n-1))/2) - m << endl;
    }

    return 0;
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k; cin>>k;
	string s; cin>>s;
	if (s.size()>k) cout<<s.substr(0,k)<<"..."<<endl;
	else cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000

int main()
{
    ll x,y;
    cin >> x >> y;
    if(abs(x)==abs(y)){
        if(x+y==0){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        ll count=0;
        if(abs(x)<abs(y)){
            count+=abs(y)-abs(x);
            if(x<0&&y>0){
                count++;
            }else if(x<0&&y<0){
                count+=2;
            }else if(x>=0&&y<0){
                count++;
            }
        }else{
            count+=abs(x)-abs(y);
            if(x>0&&y>0){
                count+=2;
            }else if(x>0&&y<=0){
                count+=1;
            }else if(x<0&&y>0){
                count++;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
long long int n,a[100];

int main(){
    cin>>n;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<100;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;


}


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


/**
 * AIZU ONLINE JUDGE
 * 1554
 *  2020/5/10
 */
public class Main {

    PrintStream log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    PrintStream result = System.out;
    Scanner sc = new Scanner(System.in);


    int get13f(int y2, int m2, int d2) {

        int y = 0;
        int m = 1;
        int d = 1;
        int w = 6;
        int cnt = 0;

        for(;;) {
            if (d == 13 && w == 5)
                cnt++;
            if (y == y2 && m == m2 && d == d2) {
                return cnt;
            }

            d++;
            w = (w + 1) % 7;
            int md = 31;
            if (m == 2) {
                if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
                    md = 29;
                else
                    md = 28;
            }
            else if (m == 4 || m == 6 || m == 9 || m == 11) {
                md = 30;
            }
            if (d > md) {
                d = 1;
                m++;
                if (m > 12) {
                    m = 1;
                    y++;
                }
            }
        }
    }


    void main() throws IOException {

        long y1 = sc.nextLong();
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();

        long y2 = sc.nextLong();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();

        long y1s = y1 / 400;
        int y1a = (int)(y1 % 400);
        if (d1 == 13)
            d1 = 12;
        long c1 = get13f(y1a, m1, d1);

        long y2s = y2 / 400;
        int y2a = (int)(y2 % 400);
        long c2 = get13f(y2a, m2, d2);

        // 400年間に13日の金曜日は688回ある
        result.println(688 * (y2s - y1s) + c2 - c1);
    }


    public static void main(String[] args) throws IOException {
        new Main().main();
    }


}




Measured memory_bytes: 26452
#include <stdio.h>

int main(void){
  int a, b;

  scanf("%d %d", &a, &b);
  if(a > b){
    printf("a > b\n");
  } else if(a < b){
    printf("a < b\n");
  } else if(a == b) {
    printf("a == b\n");
  }

  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<int> ten(n);
    rep(i,n) cin >> ten[i];
    vector<int> c(n,0);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        if(ten[a]==ten[b]){
            c[a]++;
            c[b]++;
        }
        else if(ten[a]>ten[b]) c[b]++;
        else c[a]++;
    }
    int ans=0;
    rep(i,n){
        if(!c[i]) ans++;
    }
    cout << ans << endl;
return 0;
}
 

Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s[0] == s[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from collections import defaultdict
input = stdin.readline
setrecursionlimit(200000)
N, M = map(int, input().split())
# d = [0] * (N + 1)
adj = defaultdict(list)
for _ in range(M):
    x, y = map(int, input().split())
    adj[x].append(y)
    # d[y] += 1

dp = [-1] * (N + 1)


def lp(x: 'int') -> 'int':
    if dp[x] >= 0:
        return dp[x]
    else:
        dp[x] = 0
        for y in adj[x]:
            dp[x] = max(dp[x], lp(y) + 1)
        return dp[x]


print(max(lp(i) for i in range(1, N + 1)))


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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll n,a,b;
int main()
{
    fast_io;
    cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let v: Vec<u64> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    
    let mut fst = vec![];
    let mut snd = vec![];
    for i in 0..n {
        if i % 2 == 0 {fst.push(v[i]);}
        else {snd.push(v[i]);}
    }
    
    let fst_freqsec = freq_sec(&fst);
    let snd_freqsec = freq_sec(&snd);
    let ret = if fst_freqsec[0].1 == snd_freqsec[0].1 {
        std::cmp::min(
            calc(&fst, 0) + calc(&snd, 1),
            calc(&fst, 1) + calc(&snd, 0)
        )
    } else {
        calc(&fst, 0) + calc(&snd, 0)
    };
    println!("{}", ret);
}

fn freq_sec(fst: &[u64]) -> Vec<(usize, u64)> {
    let freq = count_series(fst);
    let mut freqsec: Vec<_> = freq.iter().map(|(&key, &value)| (value, key)).collect();
    freqsec.sort();
    freqsec.reverse();
    freqsec
}

fn calc(fst: &[u64], rank: usize) -> usize {
    let freqsec = freq_sec(fst);
    let mut sum = 0;
    for &(value, key) in &freqsec {
        if freqsec.len() <= rank || freqsec[rank].1 != key {
            sum += value;
        }
    }
    sum
}

#[allow(dead_code)]
fn count_series<T: Eq + std::hash::Hash + Clone>(
    series: &[T],
) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in series {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

Measured memory_bytes: 13196
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int N;
double dp[310][310][310];
bool memo[310][310][310];
double dfs(int x, int y, int z){
    if(x==0 && y==0 && z==0) return 0.0;
    if(memo[x][y][z]) return dp[x][y][z];
    int w=x+y+z;
    double res=(double)N/w;
    if(x!=0) res+=(double)x/w*dfs(x-1,y,z);
    if(y!=0) res+=(double)y/w*dfs(x+1,y-1,z);
    if(z!=0) res+=(double)z/w*dfs(x,y+1,z-1);
    memo[x][y][z]=true;
    return dp[x][y][z]=res;
}

int main(){
    rep(i,310){
        rep(j,310){
            rep(k,310) memo[i][j][k]=false;
        }
    }
    cin>>N;
    vec n(5,0);
    rep(i,N){
        int a; cin>>a;
        n[a]++;
    }
    printf("%.15lf\n",dfs(n[1],n[2],n[3]));
    return 0;
}

Measured memory_bytes: 256256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int a,b;cin>>a>>b;
    for(int i =0;i<10000;i++){
        int t8 =i*0.08;
        int t10=i*0.1;
        if(t8==a&&b==t10){
            cout<<i<<endl;
            return 0;
        }

    }

    cout<<-1<<endl;


}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	char s[4];
	char t[4];
	int n=0;
	scanf("%s%s",s,t);
	
	for(int i=0; i<3; i++){
		if(s[i]==t[i])
		n++;
	}
	
	printf("%d",n);
	
	return 0;
}

Measured memory_bytes: 1732
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
print((180 * (n-2)))


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

int main(){
  int n;
  cin>>n;
  vector<string> s(10);
  s[0]="pon";
  s[1]="pon";
  s[2]="hon";
  s[3]="bon";
  s[4]="hon";
  s[5]="hon";
  s[6]="pon";
  s[7]="hon";
  s[8]="pon";
  s[9]="hon";
  cout<<s[n%10]<<endl;
}

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

int main() {
    int n;
    cin >> n;
    int ret = 0;
    int top = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (top <= tmp) {
            top = tmp;
            ret++;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N, V[20], C[20];
    int ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {  
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    for (int i = 0; i < N; i++) {
        int M = V[i] - C[i];
        ans = M > 0 ? ans + M : ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool func(const char* p, int n)
{
	if (*(p + n) == '\0') {
		return false;
	}

	if (*p == *(p + n)) {
		if (n == 2) {
			return true;
		}
		return func(p, n + 1);
	}
	return false;
}

int main(void) {

	string N;
	cin >> N;

	bool good = func(N.c_str(), 1);
	if (!good) {
		good = func(N.c_str() + 1, 1);
	}

	cout << (good ? "Yes": "No") << endl;

	return 0;
}


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

typedef long long int ll;
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)

int arr[200001];

int main() {
	FASTIO;
	int N;
	ll sum = 0;
	cin >> N;
	FOR(i, 1, N)
		cin >> arr[i];
	FOR(i, 1, N - 1) {
		if (arr[i] > arr[i + 1]) {
			sum += arr[i] - arr[i + 1];
			arr[i + 1] = arr[i];
		}
	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vv;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  int n, a;
  cin >> n;
  vi e;
  rep(i, n) {
    cin >> a;
    e.push_back(a);
  }
  sort(e.begin(), e.end());
  int ans = 0;
  rep(i, n - 2) for (int j = i + 1; j < n - 1;
                     j++) for (int k = j + 1; k < n;
                               k++) if (e[i] + e[j] > e[k]) ans++;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);++i)
#define out(v) cout<<v<<"\n"

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

  map<int, int> m;
  ++m[0];
  rep(i, N) {
    int d; cin >> d;
    ++m[min(d, 24-d)];
  }
  vector<int> v, v2;
  rep(i, 13) {
    if (m[i] == 0)
      continue;
    if (m[i] >= 3) {
      out(0);
      return 0;
    }
    if (m[i] == 2) {
      if (i == 24 - i || i == 0) {
        out(0);
        return 0;
      }
      v2.push_back(i);
      v2.push_back(24-i);
    } else {
      v.push_back(i);
    }
  }
  sort(all(v));
  rep(i, v.size()) {
    if (i % 2 != 0)
      v2.push_back(24-v[i]);
    else
      v2.push_back(v[i]);
  }
  sort(all(v2));
  int ans = 100;
  rep(i, v2.size()-1) {
    ans = min(ans, v2[i+1] - v2[i]);
  }
  ans = min(ans, v2[0] - v2.back() + 24);
  out(ans);

  return 0;
}


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

int main(void)
{
    char c[8];
    while(1){
        gets(c);
        int n=atoi(c);
        if( n<=0 ) break ;
        char s[255];
        for( int i=0;i<255;i++ ) s[i]=i;
        for( int i=0;i<n;i++ ){
            gets(c);
            s[c[0]]=c[2];
        }
        gets(c);
        n=atoi(c);
        for( int i=0;i<n;i++ ){
            gets(c);
            printf("%c",s[c[0]]);
        }
        printf("\n");
    }
    return 0 ;
}

Measured memory_bytes: 920
#include <stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    
    if(a>b){
if(a<c) printf("%d %d %d\n", b, a, c);
else if(b>c) printf("%d %d %d\n", c, b, a);
else printf("%d %d %d\n", b, c, a);
} else if(a<b){
if(b<c) printf("%d %d %d\n", a, b , c);
else if(a>c) printf("%d %d %d\n", c, a, b);
else printf("%d %d %d\n", a, c, b);
}

    return 0;
}



Measured memory_bytes: 2104
n = int(input())
a = list(map(int, input().split()))
b = [None]*n
for i in range(n, 0, -1):
    s = 0
    for j in range(2*i, n+1, i):
        s += b[j-1]
    b[i-1] = a[i-1]^(s%2)
print(sum(b))
print(*[ind+1 for ind, i in enumerate(b) if i])


Measured memory_bytes: 13112