akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
	int x;
	cin >> x;
	if (x == 0)cout << 0;
	else cout << (x / 500 * 1000) + (x % 500 / 5 * 5);
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new ABC107().doIt();
//		new ABC108().doIt(); //Math
//		new ABC109().doIt(); //LCM
	}
	class ABC107{
		void doIt() {
			int N = sc.nextInt();
			int K = sc.nextInt() - 1;
			long x[] = new long[N];
			long ans = Integer.MAX_VALUE;
			for(int i = 0;i < N ;i++)x[i] = sc.nextLong();
			for(int i = 0;i < N - K;i++) {
				long dist = Math.abs(x[i] - x[i + K]);
				if(x[i + K] < 0)dist = dist + Math.abs(0 - x[i + K]);
				else if(x[i] > 0)dist = dist + Math.abs(0 - x[i]);
				else dist = dist + Math.min(Math.abs(x[i]),x[i+K]);
				ans = Math.min(ans, dist);
			}
			System.out.println(ans);
		}
	}
	class ABC108{
		void doIt() {
			int N = sc.nextInt();
			int K = sc.nextInt();
			long A = 0;
			long A_2 = 0;
			for(int i = 1;i <= N;i++) {
				if(i % K == 0)A++;
				else if(i*2 % K == 0)A_2++;
			}
			long ans = A*A*A + A_2*A_2*A_2;
			System.out.println(ans);
		}
	}
	class ABC109{
		int euqulid(int A,int B) {
			if(B > 0)return euqulid(B,A % B);
			else return A;
		}
		void doIt(){
			int n = sc.nextInt();
			int X = sc.nextInt();
			int ans = Integer.MAX_VALUE;
			for(int i = 0;i < n;i++) {
				int x = sc.nextInt();
				int dist = Math.abs(x - X);
				if(i == 0)ans = dist;
				else ans = euqulid(dist,ans);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 48380
#include <stdio.h>

void main(void){
  int N,A,B,i,a=0,b=0;
  char s[100000];
  
  scanf("%d %d %d",&N,&A,&B);
  scanf("%s",s);
  
  for(i=0;i<N;i++){
    if(s[i]=='a'){
      if(a+b<A+B){
        puts("Yes");
        a+=1;
      }
      else puts("No");
    }
    else if(s[i]=='b'){
      if(a+b<A+B && b<B){
        puts("Yes");
        b+=1;
      }
      else puts("No");
    }
    else puts("No");
  }
}

Measured memory_bytes: 1732
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int count = 0;
        for(int i = 1; i <= s[2]; i ++) {
            if(i%s[0]==0) count += s[1];
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int c,sum=0,d=0;
  cin>>c;
  if(c>=500){
    d=0;
    d=c/500;
    sum+=1000*d;
    c=c-(d*500);
  }
  if(c>=5){
    d=0;
    d=c/5;
    sum+=5*d;
    c=c-(d*5);
  }
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int arr[13][13];
void find(int c[],int n,int m,int pos,int cost,int &ans,int mask,int g)
{
   if(pos==n)
   {int val[m]={};
       for(int i=0;i<n;i++)
       {
           int x=1<<i;
           if(mask&x)
           {
               for(int j=0;j<m;j++)
                val[j]+=arr[i][j];
           }
       }
       int ok=1;
       for(int i=0;i<m;i++)
       {
           if(val[i]<g)
            ok=0;
       }
       if(ok)
        ans=min(ans,cost);
        return;
   }
   find(c,n,m,pos+1,cost+c[pos],ans,mask+(1<<pos),g);
    find(c,n,m,pos+1,cost,ans,mask,g);
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m,k;
cin>>n>>m>>k;

int c[n+1]={};
for(int i=0;i<n;i++)
{
    cin>>c[i];
    for(int j=0;j<m;j++)
    {
        cin>>arr[i][j];
    }
}
int ans=INT_MAX;
find(c,n,m,0,0,ans,0,k);
if(ans==INT_MAX)
    ans=-1;
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#define MAXN 500000
struct node{
	int key;
	node *ch[2],*fa;
};
node tree[MAXN+5];
node *Root,*NIL,*ncnt;
void Init(){
	NIL=&tree[0];
	NIL->fa=NIL->ch[0]=NIL->ch[1]=NIL;
	ncnt=&tree[1];
	Root=NIL;
}
inline node * NewNode(int val){
	node *p=++ncnt;
	p->key=val;
	p->fa=p->ch[0]=p->ch[1]=NIL;
	return p;
}
void Insert(node *&rt,node *fa,int val){
	if(rt==NIL){
		rt=NewNode(val);
		rt->fa=fa;
		return ;
	}
	int d=(val>=rt->key);
	Insert(rt->ch[d],rt,val);
}
void InOrder(node *rt){
	if(rt==NIL)return ;
	InOrder(rt->ch[0]);
	printf(" %d",rt->key);
	InOrder(rt->ch[1]);
}
void PreOrder(node *rt){
	if(rt==NIL)return ;
	printf(" %d",rt->key);
	PreOrder(rt->ch[0]);
	PreOrder(rt->ch[1]);
}
node *Find(node *rt,int val){
	if(rt==NIL)return NIL;
	if(rt->key==val)return rt;
	int d=(val>=rt->key);
	return Find(rt->ch[d],val);
}
int main(){
	int n,x;
	char op[100];
	Init();
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",op);
		if(op[0]=='p')
		{
			InOrder(Root);puts("");
			PreOrder(Root);puts("");
		}
		if(op[0]=='i')
		{
			scanf("%d",&x);
			Insert(Root,NIL,x);
		}
		if(op[0]=='f')
		{
			scanf("%d",&x);
			node *p=Find(Root,x);
			if(p==NIL)puts("no");
			else puts("yes");
		}
		if(op[0]=='d')
		{
			
		}
	}
	return 0;
}

Measured memory_bytes: 15080
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    rep(i,5) {
        int tmp;
        cin >> tmp;
        if (tmp == 0) 
            cout << i + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 2010;
int f[3*N][3][6*N],n,mod;
void upd(int &a,ll b){a=(a+b)%mod;}
int main(){
	read(n);read(mod);
	f[1][0][0]=1;
	for(int i=1;i<3*n;i++)
		for(int j=0;j<3;j++)
			for(int k=-i;k<=i;k++)
				if(f[i][j][k]){
					if(j<2){
						upd(f[i+1][j+1][k],1ll*f[i][j][k]*i);
					}
					upd(f[i+1][0][k+(j==0)-(j==1)],f[i][j][k]);
				}
	ll ans=0;
	for(int k=0;k<=3*n;k+=3)
		ans=(ans+f[3*n][0][k-1]+f[3*n][1][k+1]+f[3*n][2][k])%mod;
	cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 848256
n, init = map(int,input().split())
x = list(map(lambda x: abs(int(x)-init), input().split()))
g = x[0]
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)
for i in range(1,n):
    g = gcd(g,x[i])
print(g)


Measured memory_bytes: 14252
from collections import defaultdict

N,K = map(int,input().split())
A = list(map(int,input().split()))
position = 1
past_path = defaultdict(lambda : -1)
loop_pos = -1

def move(position):
	return A[position-1]

for i in range(1,K+1):
	if(past_path[position] != -1):
		loop_pos = past_path[position]
		break
	past_path[position] = i-1
	position = move(position)

new_past_path = defaultdict(lambda : -1)
for k,v in past_path.items():
	if v >= loop_pos:
		new_past_path[v-loop_pos] = k

if loop_pos != -1:
	print(new_past_path[(K-loop_pos)%len(new_past_path)])
else:
	print(position)

Measured memory_bytes: 42332
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;

int main() {
	string s;
	cin >> s;
	int y = stoi(s.substr(0, 4));
	int m = stoi(s.substr(5, 2));
	int d = stoi(s.substr(8, 2));



	if (y > 2019) {
		cout << "TBD" << endl;
	}
	else if (y == 2019 && m > 4) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=8005;
int cc[2][N],cnt[2];
char str[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

bool vld(int *v,int n,int tgt){
	static bool vld[N];
	memset(vld,0,sizeof(vld));
	if(!n) return tgt==0;
	int tot=0;
	for(int i=1; i<=n; ++i){
		tot+=v[i];
	}
	{
		int tmp=std::max(tgt,-tgt);
		if(tot<tmp||(tot-tmp)&1) return 0;
		tot=(tot-tmp)>>1;
	}
	vld[0]=1;
	int s=0;
	for(int i=1; i<=n; ++i){
		s+=v[i];
		for(int j=s; j>=v[i]; --j){
			vld[j]|=vld[j-v[i]];
		}
	}
	return vld[tot];
}

int main(){
	scanf("%s",str+1);
	int n=strlen(str+1),p0=0,p1=0;
	for(int p=0,st=1,i=1; i<=n+1; ++i){
		if(i>n||str[i]=='T'){
			if(st<i){
				if(st==1) p0=-i+1;
				else cc[p][++cnt[p]]=i-st;
			}
			p^=1,st=i+1;
		}
	}
	p0+=nxi(),p1+=nxi();
	puts(vld(cc[0],cnt[0],p0)&&vld(cc[1],cnt[1],p1)?"Yes":"No");
	return 0;
}


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

void solve() {
    int N, mod = 1e9 + 7;
    cin >> N;
    vector<vector<vector<vector<int>>>> dp(N + 1, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4))));
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                if (k == 0 && j == 2 && i == 1) continue;
                if (k == 2 && j == 0 && i == 1) continue;
                if (k == 0 && j == 1 && i == 2) continue;
                dp.at(3).at(i).at(j).at(k) = 1;
            }
        }
    }
    for (int i = 4; i <= N; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    for (int m = 0; m < 4; m++) {
                        if (l == 0 && k == 2 && j == 1) continue;
                        if (l == 2 && k == 0 && j == 1) continue;
                        if (l == 0 && k == 1 && j == 2) continue;
                        if (m == 0 && k == 2 && j == 1) continue;
                        if (m == 0 && l == 2 && j == 1) continue;
                        dp.at(i).at(j).at(k).at(l) += dp.at(i - 1).at(k).at(l).at(m);
                        dp.at(i).at(j).at(k).at(l) %= mod;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ans += dp.at(N).at(i).at(j).at(k);
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[100];
int main()
{
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	  for(int j=i+1;j<=n;j++)
	    ans+=a[i]*a[j];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    Rep(i, N) {
        cin >> p[i];
    }
    for (int i = 0; i <= X;i++) {
        int x = X - i;
        int y = X + i;
        bool j1 = true, j2 = true;
        Rep(k, N) {
            if (p[k] == x) {
                j1 = false;
            }
            if (p[k] == y) {
                j2 = false;
            }
        }
        if (j1) {
            cout << x << endl;
            return 0;
        }
        else if (j2) {
            cout << y << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
package main

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

func main() {
	wday := map[string]int{
		"SUN": 7,
		"MON": 6,
		"TUE": 5,
		"WED": 4,
		"THU": 3,
		"FRI": 2,
		"SAT": 1,
	}
	scanner := makeScanner(8192)
	s := eGetLine(scanner)
	fmt.Println(wday[s])
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
from math import factorial as frac

N, M = map(int, input().split())

MOD = 10**9 + 7

def nPk(n, k):
    r = 1
    while k > 0:
        r *= n
        r %= MOD
        n -= 1
        k -=  1
    return r

if abs(N-M) > 1:
    print(0)
elif N==M:
    print(((nPk(N,N)*nPk(M,M))*2)%MOD)
else:
    print(nPk(N,N)*nPk(M,M)%MOD)


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
public class Main {
   public static void main(String[] args) {
      
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try {
         String n = reader.readLine();
         
         if(n.equals("A")){
            System.out.println("T");
         }
         else if(n.equals("T")){
            System.out.println("A");
         }
         else if(n.equals("C")){
            System.out.println("G");
         }
         else{
            System.out.println("C");
         }
      }
      catch (IOException e) {
         System.out.println(e);
      }
   }
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

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

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    string s, t; cin >> s >> t;

    ll mn = INF;
    rep(i, s.size()-t.size()+1){
        ll ans = 0;
        rep(j, t.size()){
            if(s[i+j]!=t[j]) ans++;
        }
        chmin(mn, ans);
    }

    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; string s;
    cin >> n >> s;
    if (n%2) {
        cout << "No" << endl;
        return 0;
    }
    string t,u;
    rep(i,n/2) {
        t.push_back(s[i]);
    }
    for (int i = n/2; i < n; ++i) u.push_back(s[i]);
    if (t==u) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
  int64_t x;
  char a,b,c,d;
  cin >> x >> a >> b >> c >> d;
  int e=ctoi(a);
  int f=ctoi(c);
  int g=ctoi(d);
  int n=100*e+10*f+g;
  
  cout << fixed << setprecision(0);
  cout << (x*n)/100 << endl;

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int min(int a,int b)
{
    return a < b ? a : b;
}
int main()
{
    int n;  cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        for(int j : {i + 1, i + 2})
           if(j < n)
            dp[j] = min(dp[j], dp[i] + abs(arr[i]-arr[j]));
    }
    cout<<dp[n-1];
    return 0;

}


Measured memory_bytes: 3960
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
     long a = sc.nextLong();
     long b = sc.nextLong();
     long c = sc.nextLong();
     long k = sc.nextLong();

    if (k <= a) {
      System.out.println(k);
    } else if (k > a && k <= (a + b)){
      System.out.println(a);
    } else {
      System.out.println(a - (k - a - b));
    }
  }
}


Measured memory_bytes: 35788
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int n;cin>>n;
  bool exist[8];
  for(int i=0;i<8;i++)exist[i]=false;
  int red_count=0, count=0;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a >= 3200){red_count++;continue;}
    exist[a/400] = true;
  }
  for(int i=0;i<8;i++){
    if(exist[i])count++;
  }
  if(count==0)cout << "1 " << red_count << endl;
  else cout << count << " " << count + red_count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (int)pow(n, 3) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,x;
    cin>>n;
    int a[200005]={0};
    for(int i=2;i<=n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",a[i]);
    }
	return 0;
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	int ans = n;
	string s[200005];
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	sort(s, s+n);
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1]){
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int64_t x, y, z, k;
  std::cin >> x >> y >> z >> k;

  std::vector<int64_t> a(x), b(y), c(z);

  for (auto &i : a) {
    std::cin >> i;
  }
  for (auto &i : b) {
    std::cin >> i;
  }
  for (auto &i : c) {
    std::cin >> i;
  }

  std::vector<int64_t> sum;
  sum.reserve(x * y);

  for (int64_t i = 0; i < x; i++) {
    for (int64_t j = 0; j < y; j++) {
      sum.push_back(a[i] + b[j]);
    }
  }

  std::sort(sum.begin(), sum.end(), std::greater<int64_t>());

  std::vector<int64_t> ans;
  ans.reserve(k * z);

  for (int64_t i = 0; i < std::min(k, x * y); i++) {
    for (int64_t j = 0; j < z; j++) {
      ans.push_back(sum[i] + c[j]);
    }
  }

  std::sort(ans.begin(), ans.end(), std::greater<int64_t>());

  for (int64_t i = 0; i < k; i++) {
    std::cout << ans[i] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 31616
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;
    while(cin>>n,n){
        int h,w;
        cin>>w>>h;
        vvi v(h+2,vi(w+2,0));
        rep(i,n){
            pii hoge;
            cin>>hoge.first>>hoge.second;
            v[hoge.second][hoge.first]=1;
        }
        //cout<<endl;
        //loop(i,1,h+1){loop(j,1,w+1)cout<<v[i][j]; cout<<endl;}
        int s/*???*/,t/*??????*/; cin>>s>>t;
        int ans=0;
        loop(i,1,h+1)
        loop(j,1,w+1){
            if(j+s>w+1||i+t>h+1)continue;
            int flag=0;
            for(int k=i;k<i+t;k++)
                for(int m=j;m<j+s;m++)if(v[k][m])flag++;
            ans=max(ans,flag);
        }
        cout<<ans<<endl;
    }
}

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

int main() {
	int N;
	cin >> N;
	N %= 10;

	switch(N) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout << "hon" << endl;
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			cout << "pon" << endl;
			break;
		case 3:
			cout << "bon" << endl;
			break;
	}

	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    if (n < 10) {
        int m = 0;
        cout << m << endl;
        for (int i = 0; i < k; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                cout << j << endl;
                string s;
                cin >> s;
                if (s == "Yes") {
                    break;
                }
            }
        }
    }
    else {
        int a = 8;
        vector<vector<int>> edge(n + 1);
        int m = 0;
        for (int i = n, l = 1; i > n - a; i--, l <<= 1)
        {
            for (int j = 1; j <= n - a; j++)
            {
                if ((j & l) > 0) {
                    edge[j].push_back(i);
                    ++m;
                }
            }
        }
        cout << m << endl;
        for (int i = 1; i <= n - a; i++)
        {
            for (auto& item : edge[i]) {
                cout << i << ' ' << item << endl;
            }
        }
        for (int i = 0; i < k; i++)
        {
            int ans = 0;
            for (int j = n, l = 1; j > n - a; j--, l <<= 1)
            {
                cout << j << endl;
                string s;
                cin >> s;
                if (s == "Yes") {
                    goto A;
                }
                else if (s == "Near") {
                    ans |= l;
                }
            }
            cout << ans << endl;
            {
                string s;
                cin >> s;
                assert(s == "Yes");
            }
            A: continue;
        }
    }
    return 0;
}



Measured memory_bytes: 3304
/* kadai5_3
   Saikyo_Kazune
*/
#include <stdio.h>
#include <stdbool.h>

 
int main(void){
    int row_num, col_num, i, j;
    //行、列を読むか読まないを記録する配列
    bool judge_row[101]={0}, judge_col[101]={0};
    char table[101][101];
    //行、列数を入力
    scanf("%d %d", &row_num, &col_num);
    //初期マスを入力
    for(i = 0; i < row_num; i++){
        for(j = 0; j < col_num; j++){
            
            scanf(" %c", &table[i][j]);
            //黒が存在した場合その行、列は読まないようにする
            if(table[i][j]=='#'){
                judge_row[i] = true;
                judge_col[j] = true;
            }
        }
    }
    //falseのマスを飛ばして出力
    for(i = 0; i < row_num; i++){
        if(judge_row[i] == false)
            continue;
        for(j = 0; j < col_num; j++){
            if(judge_col[j] == false)
                continue;
            printf("%c", table[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

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

  long long N;

  cin>>N;

  long long L[N+1];
  L[0]=2;
  L[1]=1;

  for(int i=2;i<=N;i++){
      L[i]=L[i-1]+L[i-2];
  }

  cout<<L[N]<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main(){
  int T; cin >>T;
  REP(casenum, T){
    printf("Case %d: ", casenum + 1);
    int W, H;
    cin >> W >> H;
    int r[20][20];
    if(H <= W){
      REP(y, H) REP(x, W) cin >> r[y][x];
    }else{
      swap(H, W);
      REP(x, W) REP(y, H) cin >> r[y][x];
    }
    static int dp[2][1 << 20] = {};
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 0;
    dp[0][1] = r[0][0];
    int prevN = 1;
    FOR(i, 1, W + H - 1){
      vector<int> v;
      REP(y, H) REP(x, W){
        if(x + y == i) v.push_back(r[y][x]);
      }
      //printf("v[%d]: ", i); debug(v.begin(), v.end());
      int N = v.size();
      vector<int> sum(1 << N, 0);
      for(int S = 0; S < 1 << N; S++){
        for(int i = 0; i < N; i++){
          if(S >> i & 1){
            sum[S] += v[i];
          }
        }
      }
      for(int S = 0; S < 1 << N; S++){
          if(prevN <= N){
            int mask = ((1 << prevN) - 1);
            int S0 = S & mask;
            int S1 = (S >> 1) & mask;
            int PS = ~(S0 | S1) & mask;
            //printf("-> S: %d S0: %d S1: %d PS: %d\n", S, S0, S1, PS);
            dp[i & 1][S] = max(dp[i & 1][S], dp[(i - 1) & 1][PS] + sum[S]);
          }else{
            int mask = ((1 << prevN) - 1);
            int S0 = S & mask;
            int S1 = (S << 1) & mask;
            int PS = ~(S0 | S1) & mask;
            //printf("<- S: %d S0: %d S1: %d PS: %d\n", S, S0, S1, PS);
            dp[i & 1][S] = max(dp[i & 1][S], dp[(i - 1) & 1][PS] + sum[S]);
          }
        }
      // dp[S] = max({dp[T]| T \subset S})
      REP(j, N)REP(S, 1 << N){
        dp[i & 1][S | 1 << j] = max(dp[i & 1][S | 1 << j], dp[i & 1][S]);
      }
      memset(dp[(i - 1) & 1], 0, sizeof(dp[(i - 1) & 1]));
      /*
      printf("dp[%d]: ", i);
      debug(dp[i], dp[i] + (1 << N));
      */
      prevN = N;
    }
    cout << max(dp[(W + H - 2) & 1][0], dp[(W + H - 2) & 1][1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 15408
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	cnt := 0
	j := len(S) - 1

	for i := len(S) - 1; i >= 0; i-- {
		if j-i > len("dreamer") {
			break
		}
		for _, dd := range []string{"dream", "dreamer", "erase", "eraser"} {
			if S[i:j+1] == dd {
				j = i - 1
				cnt += len(dd)
			}
		}
	}
	if len(S) == cnt {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 1280
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if (a == b) {
            out.println("a == b");
        } else if (a > b ) {
            out.println("a > b");
        } else {
            out.println("a < b");                                               
        }
    }
}

Measured memory_bytes: 26284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define x first
#define y second
const ll MOD = 1e9+7, N = 1e5+9, INF = INT_MIN;
bool trait(pair<int, int>& a, pair<int, int>& b)
{
    return a.y > b.y;
}
int main() {
    fast;
    int n;
    cin>>n;
    unordered_map<string, int> arr;
    string temp;
    for (int i = 0; i < n; ++i) {
        cin>>temp;
        arr[temp]++;
    }
    int max = 0;
    for (auto it:arr) {
        if(it.y > max)
            max = it.y;
    }
    vector<string> result;
    for (auto it:arr) {
        if(it.y == max)
            result.push_back(it.x);
    }
    sort(result.begin(), result.end());
    for (int i = 0; i < result.size(); ++i) {
        cout<<result[i]<<'\n';
    }
}

Measured memory_bytes: 25284
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0,dp[100000];
  int t[1000000];
  cin>>n;
  t[0]=10000000;
  for(int i=1;i<=n;i++){
    cin>>t[i];
  }
  for(int i=2;i<=n;i++){
    if(i!=2){
      dp[i]=min(abs(t[i]-t[i-1])+dp[i-1],abs(t[i]-t[i-2])+dp[i-2]);
  }
    else
      dp[i]=min(abs(t[i]-t[i-1]),abs(t[i]-t[i-2]));
}
  cout<<dp[n]<<endl;
  return(0);
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef  long long int ll;
using namespace std;
const int M=1e9+7;
const int N=1e5+5;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
ll a[105][N];
ll n,w;
int main()
{
    cin>>n>>w;
    ll ans=0;
    ll V[n+1],W[n+1];
    a[0][0]=0;
    for(ll i=1;i<=n;++i)
    {
         cin>>W[i]>>V[i];
         for(ll j=0;j<=w;++j)
         {
           if(j<W[i])
           {
               a[i][j]=a[i-1][j];
           }
           else
           if(j==W[i])
           {
               a[i][j]=max(V[i],a[i-1][j]);
           }
           else
           {
               if(a[i-1][j-W[i]])
               {
                   a[i][j]=max(a[i-1][j],a[i-1][j-W[i]]+V[i]);
               }
               else
               a[i][j]=a[i-1][j];
           }
           ans=max(ans,a[i][j]);
         }
    }
    cout<<ans;
}


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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    int ans = T.size();
    for (int i = 0; i < S.size() - T.size() + 1; i++){
        int cnt = 0;
        for (int j = 0; j < T.size(); j++){
            if (S[i + j] != T[j])
                cnt++;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;
}

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

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        boolean ok = true;
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < n; ++i) {
            if (arr[i] % 2 == 0 && (arr[i] % 3 != 0 && arr[i] % 5 != 0)) {
                ok = false;
                break;}
//             else if (arr[i] % 2 == 0 && (arr[i] % 3 == 0 || arr[i] % 5 == 0)) {
//                ok = true;
//            }
        }
        if (ok == true) System.out.println("APPROVED");
        else System.out.println("DENIED");

    }
}


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

struct point {
    double x, y;
    point() : x(0), y(0) {};
    point(double x, double y) : x(x), y(y) {}
    point &operator+=(const point &rhs) {
        x += rhs.x, y += rhs.y;
        return *this;
    }
    point &operator-=(const point &rhs) {
        x -= rhs.x, y -= rhs.y;
        return *this;
    }
    point &operator*=(double rhs) {
        x *= rhs, y *= rhs;
        return *this;
    }
    point &operator/=(double rhs) {
        x /= rhs, y /= rhs;
        return *this;
    }
    point operator+() const { return *this; }
    point operator-() const { return {-x, -y}; }
    point operator+(const point &rhs) const { return point(*this) += rhs; }
    point operator-(const point &rhs) const { return point(*this) -= rhs; }
    point operator*(double rhs) const { return point(*this) *= rhs; }
    point operator/(double rhs) const { return point(*this) /= rhs; }
};
constexpr double EPSQ = 1e-16;
point polar(double r, double th) { return {r * cos(th), r * sin(th)}; }
double dot(const point &a, const point &b) { return a.x * b.x + a.y * b.y; }
double det(const point &a, const point &b) { return a.x * b.y - a.y * b.x; }
double norm(const point &a) { return dot(a, a); }
double abs(const point &a) { return sqrt(norm(a)); }
double arg(const point &a) { return atan2(a.y, a.x); }
point revolved(const point &a, double th) { return {a.x * cos(th) - a.y * sin(th), a.x * sin(th) + a.y * cos(th)}; }
bool operator==(const point &a, const point &b) { return norm(a - b) < EPSQ; }
bool operator!=(const point &a, const point &b) { return std::rel_ops::operator!=(a, b); }
int ccw(point a, point b, point c) {
    b -= a, c -= a;
    if (det(b, c) > EPSQ) { return 1; }
    if (det(b, c) < -EPSQ) { return -1; }
    if (dot(b, c) < 0) { return 2; }
    if (norm(b) < norm(c)) { return -2; }
    return 0;
}
std::vector<point> convex_hull(std::vector<point> ps) {
    std::sort(ps.begin(), ps.end(),
              [](const point &a, const point &b) -> bool { return a.x < b.x || a.x == b.x && a.y < b.y; });
    int n = ps.size(), k = 0;
    std::vector<point> qs(n * 2);
    for (int i = 0; i < n; qs[k++] = ps[i++]) {
        while (k > 1 && det(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < -EPSQ) { k--; }
    }
    for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--]) {
        while (k > t && det(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) < -EPSQ) { k--; }
    }
    qs.resize(k - 1);
    return qs;
}

int main() {
    int n;
    cin >> n;
    vector<point> ps(n);
    for (int i = 0; i < n; i++) { cin >> ps[i].y >> ps[i].x; }
    vector<point> ch = convex_hull(ps);
    rotate(ch.begin(), ch.begin() + 1, ch.end()), reverse(ch.begin(), ch.end());
    cout << ch.size() << endl;
    for (int i = 0; i < ch.size(); i++) { cout << (int) ch[i].y << " " << (int) ch[i].x << endl; }
}


Measured memory_bytes: 9184
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N,ans;
    cin >> N;
    double child = N/2+N%2;
    P(child/double(N));
}

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

const int inf = 1<<24;
const int size = 101;
int n, p;
int CN[size][size];
int CNcnt[size];
int MC[size];

typedef pair <int, int> Node;
typedef priority_queue <Node, vector <Node>, greater <Node> > QUEUE;

void dijkstra( int start, int goal, int ttl ) {
    QUEUE Q;
    Node start_node( 1, start );
    MC[start] = 1;
    Q.push( start_node );

    while ( !Q.empty() ) {
        Node node = Q.top();
        Q.pop();

        int router = node.second;
        int cost = node.first;

        if ( router == goal ) {
            cout << cost << endl;
            return;
        }

        for ( int i = 0; i < CNcnt[router]; i++ ) {
            int next_router = CN[router][i] - 1;
            int next_cost = cost + 1;
            
            if ( next_cost >= ttl + 1 ) continue;
            if ( next_cost >= MC[next_router] ) continue;
            MC[next_router] = next_cost;
            Node next_node( next_cost, next_router );
            Q.push( next_node );
        }
    }

    cout << "NA" << endl;
}

void init() {
    for ( int i = 0; i < size; i++ ) {
        MC[i] = inf;
    }
}

void solve() {
    cin >> p;
    for ( int i = 0; i < p; i++ ) {
        int start, goal, ttl;
        cin >> start >> goal >> ttl;
        init();
        dijkstra( start-1, goal-1, ttl );
    }
}

void input() {
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        int r, k;
        cin >> r >> k;
        CNcnt[r-1] = k;
        for ( int j = 0; j < k; j++ ) {
            cin >> CN[r-1][j];
        }
    }
}

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

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    //static string S;
      static int[] N;
      static int[] A;
//    static int[] C;
    static void INPUT()
    {
        N = LineInt();
        A = new int[N[2]];
        for(var i = 0; i < N[2]; i++)
            A[i] = NextInt();
    }
    static void OUTPUT()
    {
        var K = N[1];
        var Q = N[2];
        var kk = Q - K;
        var AA = new int[N[0]];
        foreach (var a in A)
        {
            AA[a - 1]++;
        }
        foreach (var aa in AA)
        {
            Console.WriteLine(aa <= kk ? "No" : "Yes");
        }
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 18756
#include <stdio.h>

int main(void){
  int n;
  int i,j;
  int t,y;
  while(scanf("%d",&n)!=EOF){
    if(n==0) break;
    else{
      int m[n][n];
      for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	  m[i][j]=-1;
	}
      }
      t=1+n/2;
      y=n/2;
      m[t][y]=1;
      for(i=2;i<=n*n;i++){
	t++; y++;
	//printf("%d\n",i);
	//printf("/%d %d\n",t,y);
	if(t>n-1) t=0;
	if(y>n-1) y=0;
	if(m[t][y]!=-1){
	  //printf("?????¶???%d %d\n",t,y);
	  t++; y--;
	  if(t>n-1) t=0;
	  if(y>n-1) y=0;
	  else if(y<0) y=n-1;
	}
	m[t][y]=i;
	//printf("%d %d\n",t,y);
      }

      for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	  printf("%4d",m[i][j]);
	}
	printf("\n");
      }

    }
  }
  return 0;
}

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

int main(){
int n;
int ca=0;
while(cin>>n&&n!=0){
int m=1000-n;
if(m>=500){
	m-=500;
	ca++;
		}
		if(m>=100){
			int i=m/100;
			ca+=i;
			m-=i*100;
			}
			if(m>=50){
				ca++;
				m-=50;
				}
				if(m>=10){
					int i=m/10;
					ca+=i;
					m-=i*10;
					}
					if(m>=5){
						ca++;
						m-=5;
						}
						if(m>=1){
							int i=m;
							ca+=i;
							}
						
		cout<<ca<<endl;
		ca=0;
		}
		return 0;					
		}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N, 0);
    REP(i, N) cin >> A[i];

    map<ll, ll> sumMap;
    vector<ll> sumA(N, 0);
    sumA[0] = A[0];
    sumMap[sumA[0]]++;
    REP(i, N - 1)
    {
        sumA[i + 1] = sumA[i] + A[i + 1];
        sumMap[sumA[i + 1]]++;
    }
    ll ans = 0;
    REPV(iter, sumMap)
    {
        if (iter->first == 0) ans += iter->second;
        ans += iter->second * (iter->second - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b;
    cin >> a >> b;
    if(a == b) cout << a + b << endl;
    else if(a > b) cout << a*2-1 << endl;
    else cout <<b*2-1 << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};

    #define mod 1000000007
    long long dp[110][5][5][5]; //dp[n][ACGT][ACGT][ACGT]

    int main()
    {
        int n; cin >> n;
        dp[0][0][0][0] = 1;
        for (int i = 0; i < n; i++) {
            for (int a = 0; a < 5; a++) {
                for (int b = 0; b < 5; b++) {
                    for (int c = 0; c < 5; c++) {
                        // dp[i][a][b][c]
                        for (int d = 1; d <= 4; d++) {
                            if (b == 1 && c == 3 && d == 2) continue;
                            if (a == 1 && c == 3 && d == 2) continue;
                            if (b == 3 && c == 1 && d == 2) continue;
                            if (b == 1 && c == 2 && d == 3) continue;
                            if (a == 1 && b == 3 && d == 2) continue;
                            dp[i+1][b][c][d] = (dp[i+1][b][c][d] + dp[i][a][b][c]) % mod;
                        }
                    }
                }
            }
        }
        long long ans = 0;
        for (int a = 0; a < 5; a++) {
            for (int b = 0; b < 5; b++) {
                for (int c = 0; c < 5; c++) {
                    ans = (ans + dp[n][a][b][c]) % mod;
                }
            }
        }
        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 384