akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;

int main(){
	int c[3];
	int cards[10];
	
	while(cin >> c[0] >> c[1] >> c[2]){
		fill(cards, cards+10, 1);
		if(c[0] == 0)break;
		for(int i = 0; i < 3; i++){
			cards[c[i]]--;
		}
		int count = 0;
		for(int i = 0; i < 10; i++){
			if(c[0]+c[1]+i+1 <= 20){
				count += cards[i];
			}
		}
		if((double)count/(10-3) >= 0.5){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 1152
n = int(input())
a = list(map(int, input().split()))

ans = 0

def div_2(n):
    ret = 0
    while n % 2 != 1:
        ret += 1
        n /= 2
    return ret

for i in range(n):
    ans += div_2(a[i])

print(ans)

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

int main() {
	int N;
	cin >> N;
	long long count =0;
	map< string , int> sent;
	for (int i=0;i<N;i++){
		string S;
		cin >> S;
		sort(S.begin(),S.end());
		if(!(sent.count(S))){
			sent[S]=1;
		}
		else {
			sent[S]++;
			count = count + sent[S]-1;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 11136
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper
t, x = inl()
print(t/x)


Measured memory_bytes: 3572
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = np.array(read().split(), np.int64)
I = np.argsort(A)[::-1].tolist()
A = A[I].tolist()

dp = np.zeros(1, np.int64)

for n, (i, x) in enumerate(zip(I, A)):
    newdp = np.zeros(len(dp) + 1, np.int64)
    left_ind = np.arange(len(dp))
    right_ind = N - 1 - n + left_ind
    left_cost = x * np.abs(left_ind - i)
    right_cost = x * np.abs(right_ind - i)
    np.maximum(newdp[:-1], dp + right_cost, out=newdp[:-1])
    np.maximum(newdp[1:], dp + left_cost, out=newdp[1:])
    dp = newdp

print(dp.max())


Measured memory_bytes: 28004
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		inf
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    f(i,0,n)cin>>a[i];
    ll dp[n];
    f(i,0,n){ dp[i]=MAX;}
    dp[0]=0;
    for(int i=1;i<n;i++){ 
    	
       for(int j=max(i-k,0);j<=i;j++){
       	 dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
       	 
       }
    }
        cout<<dp[n-1]<<endl;
 	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define ll             long long 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define bs             binary_search    // binary_search(a,a+n,x);
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define lower(x)         transform(x.begin(), x.end(), x.begin(), ::tolower);           
#define upper(x)          transform(x.begin(), x.end(), x.begin(), ::toupper);
#define lb             lower_bound      // lower_bound(a,a+n,x) - a; => For Index
#define up             upper_bound      // upper_bound(a,a+n,x) - a; => For Index       
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif   
}    

void solution()
{
    int n;
    cin>>n;
    string s;
    while(n--)
    {
        s+="ACL";
    }

    cout<<s<<endl;
}

int32_t main()
{
    c_p_c();
    FIO;
 
    // int t;
    // cin>>t;
 
    // while(t--)
    // {
         solution();
    //}
 
    return 0;
}

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

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	long N;	
	
	Main() {
		N = in.nextLong();
		long min = (long)1e18;
		for (long i = 1; i * i <= N; i++)
			if (N %i == 0) {
				long j = N / i;
				min = min(min, i + j - 2);
			}
		out.println(min);
		out.close();
	}

	
	
	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }

		void intArr(int sz, int[] x) { for (int i = 0; i < sz; i++) x[i] = nextInt(); }
		void longArr(int sz, long[] x) { for (int i = 0; i < sz; i++) x[i] = nextLong(); }
		void doubleArr(int sz, double[] x) { for (int i = 0; i < sz; i++) x[i] = nextDouble(); }
	}
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve(){
	
	int n, m, k;
	cin >> n >> m >> k;
	
	vector<ll> a(n+1), b(m);
	
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] = a[i-1] + a[i];
	}
	
	for(int i = 0; i < m; i++){
		cin >> b[i];
		if(i)
			b[i] = b[i-1] + b[i];
	}
	b.push_back(1e18);
	
	
	int ans = 0;
	for(int i = 0; i <= n; i++){
		if(a[i] > k)
			break;
		//cout << i << " "  << ans << endl;
		ans = max(ans, i + (int)(upper_bound(b.begin(), b.end(), k - a[i]) - b.begin()));
		
		//cout << i << " "  << ans << endl;
	}
	
	cout << ans << endl;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	//cin >> tc;
	while(tc--)
		solve();
}


Measured memory_bytes: 7952
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define INF 10000000
#define WHITE 0
#define BLACK 1

int main(){
  int i,j,n,count=0,v,c,v1,c1;
  int G[N][N],color[N],d[N],pi[N],mincost,u;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      G[i][j] = -1;
    }
  }
    scanf("%d",&n);

    for(i=0;i<n;i++){
      scanf("%d%d",&v,&c);
      for(j=0;j<c;j++){
	scanf("%d%d",&v1,&c1);
	G[v][v1] = c1;
      }
    }

    for(i=0;i<n;i++){
      color[i] =WHITE;
      pi[i] = -1;
      d[i]=INF;
    }

    d[0]=0;

    while(1){
      mincost = INF;
      for(i=0;i<n;i++){
	if(color[i]!=2 && d[i]<mincost){
	  mincost = d[i];
	  u = i;
	}
      }
      if(mincost == INF) break;
      color[u] = 2;

      for(i=0;i<n;i++){
	if(G[u][i]!=-1&&color[i]!=2&&(G[u][i]+d[u])<d[i]){
	  pi[i]= u;
	  d[i] = G[u][i]+ d[u];
	  color[i] = BLACK;
	}
      }
    }

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

}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  
  int s[10000];
  int t[500];
  int n,q,i,j,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(t[i]==s[j]){
	count++;
	break;
      }
    }
  }

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

  return 0;
  
}

Measured memory_bytes: 640
import java.util.Scanner;

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

    int iA = 0;
    while (s.charAt(iA) != 'A') ++iA;

    int iZ = s.length() - 1;
    while (s.charAt(iZ) != 'Z') --iZ;

    int ans = iZ - iA + 1;

    System.out.println(ans);
    
    sc.close(); 
  }
}


Measured memory_bytes: 26576
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(n):
    A=list(map(int,input().split()))
    val=c
    for j in range(m):
        val+=A[j]*B[j]
    if val>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int n,i;
	double a[102],ans=0;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=1;i<=n;i++) ans=ans+1.0/a[i];
	printf("%.20lf\n",1.0/ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define min(a, b) (a < b ? a : b)

int main( void ) {
	int n;
	scanf("%i", &n);
	
	int S[n];
	for( int i = 0; i < n; i++ ) {
		scanf("%i", &S[i]);
	}
	
	int best = 1<<30;
	for( int j = -100; j <= 100; j++ ) {
		int cost = 0;
		for( int i = 0; i < n; i++ ) {
			cost += (S[i] - j) * (S[i] - j);
		}
		
		best = min(best, cost);
	}
	
	printf("%i\n", best);
	
	return 0;
}

Measured memory_bytes: 256
from queue import deque

n = int(input())
li = [[] for _ in range(n+1)]

for i in range(n-1):
    a,b = map(int,input().split())
    li[a] += [b]
    li[b] += [a]

def width_prime(start,li,n):
    inf = 10**10
    visited = [False]*(n+1)
    length = [inf]*(n+1)
    length[start] = 0
    visited[start] = True
    work_queue = deque([])
    work_queue.append(start)
    while work_queue:
        now = work_queue.popleft()
        visited[now] = True
        for i in li[now]:
            if visited[i]:
                continue
            work_queue.append(i)
            visited[i] = True
            if length[i] > length[now]+1:
                length[i] = length[now]+1
    return length

le_fe = width_prime(1,li,n)
le_su = width_prime(n,li,n)

su = 0
fe = 0
for i in range(1,n+1):
    if le_fe[i] <= le_su[i]:
        fe += 1
    else:
        su += 1

if fe > su:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 30712
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

W, A, B = map(int, input().split())

x = 0 if A <= B <= A + W or A <= B + W <= A + W or B <= A <= B + W or B <= A + W <= B + W else 1 << 28
y = abs(A - (B + W))
z = abs(B - (A + W))
print(min(x, y, z))

Measured memory_bytes: 9504
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

void _main(istream &inp){
	ll N,K;
	inp >> N >> K;
	if(K%2==1){
		ll v= 0;
		FOR(i,1,N+1) if(i%K==0)v++;
		cout << v*v*v << endl;
	}
	else{
		ll v1=0, v2=0;
		FOR(i,1,N+1){
			if(i%K==0)v1++;
			if(i%K==K/2)v2++;
		}
		cout << v1*v1*v1+v2*v2*v2 << endl;

	}

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

long long f(long long n)
{
    return (n%2==0) ? (n / 2) : (3 * n + 1);
}

int main()
{
    int s;
    std::cin >> s;

    long long ai_1 = s;
    int ans = 0;
    long long res[10000000] = {0};
    res[s]++;
    for (int i = 2; i < 100000000; i++) {
        int ai = f(ai_1);
        if (res[ai] > 0) {
            ans = i;
            break;
        }

        res[ai]++;
        ai_1 = ai;
     }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 78336
import sys

def isPalin(s):
    return s == s[::-1]

s = input()
n = len(s)
a = s[::(n - 1) // 2]
b = s[(n + 3) // 2 - 1:]

if isPalin(s) and isPalin(a) and isPalin(b):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N, X, Y, Z = map(int, input().split())
MOD = 10**9 + 7

# X-Y-Zを含まない数列を数える
D = 2**(X + Y + Z - 1)  # 直前のX+Y+Zビットを保持する

# ビットが立っている部分で数列を区切れる
XYZ = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1))  # X-Y-Z

dp = [[0] * D for _ in range(N + 1)]
dp[0][0] = 1

for right in range(N):
    for mask in range(D):
        for nextA in range(1, 11):
            # 110 + 10 = 110 10
            newMask = (mask << (nextA)) | (1 << (nextA - 1))
            if newMask & XYZ != XYZ:  # X-Y-Zを含まない
                dp[right + 1][newMask % D] += dp[right][mask]
                dp[right + 1][newMask % D] %= MOD

ans = pow(10, N, MOD) - sum(dp[-1])
print(ans % MOD)

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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	LL n; cin >> n;
	cout << (n * (n - 1)) / 2LL << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
 
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
 
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",&s);
 
  long long  rc=0,gc=0,bc=0;
  for(int i=0;i<n;i++){
	if(s[i]=='R')rc++;
    if(s[i]=='G')gc++;
    if(s[i]=='B')bc++;
  }
  long long ans=rc*gc*bc;
  for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
	int k=j+j-i;			//i-jとj-kの距離が同じに
      if(k>n-1)continue;
      if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])ans--;
    }
  }
  
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 1732
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	// i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	x := []float64{}

	for i := 0; i < n; i++ {
		x = append(x, float64(nextInt()))
	}

	sort.Float64s(x)

	ave := (x[0] + x[1]) / 2
	for i := 2; i < len(x); i++ {
		ave = (ave + x[i]) / 2
	}

	fmt.Println(ave)
}


Measured memory_bytes: 640
N = int(input())
ans = []
ac = 0
wa = 0
tle = 0
re = 0

for k in range(N):
    s = input()
    if s == 'AC':
        ac +=1
    elif s == 'WA':
        wa +=1
    elif s == 'TLE':
        tle +=1
    else:
        re +=1

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)


Measured memory_bytes: 8860
def main():
    n = int(input())
    ans = solve(n)
    print(ans)


def solve(n):
    ans = 0
    for i in range(1, n +1, 2):
        tmp = 0
        for j in range(1, i + 1):
            if i % j == 0:
                tmp += 1
        if tmp == 8:
            ans += 1
    return ans


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n=int(input())
d,x=map(int,input().split())
sum=0
tmp=0
a=[0]*n
for i in range(0,n):
    a[i] = int(input())
    while True:
        sum+=1
        tmp+=1
        if tmp*a[i]+1 > d:
            tmp=0
            break
print(sum+x)

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

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

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  cout << 1110 - n << endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main (int argc, char*argv[]) {
  string a, b ,c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] &&
     b[b.size()-1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;

int brute(int argc, char *argv[]) {
   return 0;
}

int tests(int argc, char *argv[]) {
   return 0;
}

int _main(int argc, char *argv[]) {
   string s;
   cin >> s;
   cin >> s;
   cout << "A" << s[0] << "C" << endl;
   return 0;
}

int main(int argc, char *argv[]){
   if(argc >= 2 && argv[1][0] == '1') {
      brute(argc, argv);
   } else if(argc >= 2 && argv[1][0] == '2') {
      tests(argc, argv);
   } else {
      _main(argc, argv);
   }
   return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <map>

using namespace std;
const char N = 'N';
const char E = 'E';
const char S = 'S';
const char W = 'W';

template<typename T>
struct ring4 {
    T elem[4];

    ring4() {}
    ring4(T a, T b, T c, T d) {
        elem[0] = a;
        elem[1] = b;
        elem[2] = c;
        elem[3] = d;
    }

    T operator[](int x) {
        return elem[x % 4];
    }

    int indexOf(T v) {
        for (int i = 0; i < 4; ++i) {
            if (elem[i] == v) return i;
        }
        return -1;
    }
};

template<typename T>
struct dice {
    map<T, ring4<T> > faces;
    T u;
    T s;

    dice(T f1, T f2, T f3, T f4, T f5, T f6) {
        u = f1;
        s = f2;
        faces[f1] = ring4<T>(f5, f4, f2, f3);
        faces[f2] = ring4<T>(f1, f4, f6, f3);
        faces[f3] = ring4<T>(f1, f2, f6, f5);
        faces[f4] = ring4<T>(f1, f5, f6, f2);
        faces[f5] = ring4<T>(f1, f3, f6, f4);
        faces[f6] = ring4<T>(f2, f4, f5, f3);
    }

    T U() {
        return u;
    }

    T S() {
        return s;
    }

    T E() {
        return faces[u][faces[u].indexOf(s) + 1];
    }

    T N() {
        return faces[u][faces[u].indexOf(s) + 2];
    }

    T W() {
        return faces[s][faces[s].indexOf(u) + 1];
    }

    T D() {
        return faces[s][faces[s].indexOf(u) + 2];
    }

    void rollTo(char direction) {
        T tmpS = s, tmpU = u;
        switch (direction) {
            case 'N':
                s = D();
                u = tmpS;
                break;
            case 'E':
                u = W();
                break;
            case 'S':
                u = N();
                s = tmpU;
                break;
            case 'W':
                u = E();
                break;
            default:;
        }
    }
};

int main() {
    int face[6];
    string cmd;
    for (int i = 0; i < 6; ++i) cin >> face[i];
    cin >> cmd;
    dice<int> D(face[0], face[1], face[2], face[3], face[4], face[5]);
    for (int i = 0; i < cmd.size(); ++i) {
        D.rollTo(cmd[i]);
    }
    cout << D.u << endl;
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=1<<17;
int n,A,B,bit[N+10],Max;

void dfs(int ed,int x,int ban)
{
	if(bit[ban^Max]==1)return printf("%d %d ",x^A,x^ed^A),void();
	fo(i,0,n-1)if(ed>>i&1){
		if(ban>>i&1)continue;
		fo(j,0,n-1)if(i!=j){
			if(ban>>j&1)continue;
			dfs(1<<j,x,ban|(1<<i));
			dfs(ed^(1<<j)^(1<<i),x^(1<<j)^(1<<i),ban|(1<<i));
			return;
		}
	}
}

int main()
{
	n=rd();A=rd();B=rd();Max=(1<<n)-1;
	fo(i,1,Max)bit[i]=bit[i>>1]+(i&1);
	if(bit[A^B]&1)return puts("YES"),dfs(A^B,0,0),0;
	puts("NO");
	return 0;
}


Measured memory_bytes: 1664
n,m=list(map(int,input().split()))
if n!=1:
    ans=[1]+[0]*(n-1)
    checks=[0]*n
    check=0

    for _ in range(m):
        s,c=list(map(int,input().split()))
        s-=1
        if s==0:
            if c==0:
                check+=1
                break
            elif checks[s]!=0 and ans[s]!=c:
                check+=1
                break
            else:
                checks[s]+=1
                ans[s]=c
        else:
            if checks[s]!=0 and ans[s]!=c:
                check+=1
                break
            else:
                checks[s]+=1
                ans[s]=c
else:
    ans=[0]
    checks=[0]
    check=0
    for _ in range(m):
        s,c=list(map(int,input().split()))
        s-=1
        if checks[s]!=0 and ans[s]!=c:
            check+=1
            break
        else:
            checks[s]+=1
            ans[s]=c

if check>0:
  print(str(-1))
else:
  ans=list(map(str,ans))
  print("".join(ans))


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

int dir[][2] = {0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,-1,-1,1};
int h, w;
string s[55];
int dfs(int x, int y)
{
    int res = 0;
    int xx, yy;
    for(int i = 0; i < 8; ++i)
    {
        xx = x + dir[i][0];
        yy = y + dir[i][1];
        if(xx < 0 || yy < 0 || xx >= h || yy >= w)  continue;
        else if(s[xx][yy] == '#')   ++res;
    }
    return res;
}
int main()
{
    cin >> h >> w;
    for(int i = 0; i < h; ++i)  cin >> s[i];
    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            if(s[i][j] == '#')  cout << s[i][j];
            else
            {
                int t = dfs(i, j);
                cout << t;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1e9;
int n, k;
int heights[100000];
int memo[100000];

int dp(int i)
{
	if (i < 0)
		return INF;
	if (i == 0)
		return 0;
	if (memo[i] > -1)
		return memo[i];

	int cur = heights[i];
	int res = INF;
	for (int j = 1; j <= k; j++)
	{
		if (i - j < 0)
			continue;
		int res1 = dp(i - j) + abs(cur - heights[i - j]);
		res = min(res, res1);
	}
	memo[i] = res;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> heights[i];
	}
	memset(memo, -1, sizeof(memo));
	cout << dp(n - 1);
}

Measured memory_bytes: 10640
x = int(input())
ans = 0
if x <= 6:
    ans = 1
elif 6 < x < 11:
    ans = 2
else:
    if x % 11 > 6:
        ans = ((x // 11) * 2) + 2
    elif 0 < x % 11 <= 6:
        ans = ((x // 11) * 2) + 1
    elif x % 11 == 0:
        ans = (x // 11) * 2
print(ans)

Measured memory_bytes: 3060
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	D = defaultdict(int)
	AC = 0
	WA = 0
	for i in range(M):
		p, S = list(input().split())
		if S == "AC":
			if D[p] != -1:
				AC += 1
				WA += D[p]
				D[p] = -1
		else:
			if D[p] != -1:
				D[p] += 1

	print(AC, WA)


if __name__ == '__main__':
	main()

Measured memory_bytes: 59352
N, K = map(int, raw_input().split())
A_N  = map(int, raw_input().split())
sum = 0

N_m_K     = N - K
N_m_K_div = (N_m_K - 1) / (K - 1)
#div   = N/K
#rem   = N%K

if N == K:
    print 1
else:
    print (N_m_K_div + 1) + 1

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
}

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


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
using namespace std;
int a[100050];
int main()
{
	int n,ans=0;
	//6cout<<ans;
	cin>>n;
	for(int i=1;i<=n;i++)
	 {
	 	cin>>a[i];
	 }
	 for(int i=1;i<=n;i++)
	 {
	  	
	  	ans+=abs(a[i]-a[i-1]);
	}
	ans+=abs(a[n]);
	for(int i=1;i<=n;i++)
	{
		int t;
		t=ans+abs(a[i-1]-a[i+1]);
		t=t-abs(a[i]-a[i-1])-abs(a[i+1]-a[i]);
		cout<<t<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
import java.util.*;
import java.lang.*;

class UnionFind{
    private int size;
    private int[] parent;
    private int[] blockSize;
    public UnionFind(int size){
        this.size = size;
        parent = new int[size];
        blockSize = new int[size];
        for(int i=0;i<size;i++){
            parent[i]=i;
            blockSize[i]=1;
        }
    }
    boolean isRoot(int node){
        return node==parent[node];
    }
    int getRoot(int node){
        if(isRoot(node)) return node;
        else{
            parent[node] = getRoot(parent[node]);
            return parent[node];
        }
    }
    public void union(int node1, int node2){
        if(find(node1, node2)) return;
        if(blockSize[node1]>blockSize[node2]){
            blockSize[getRoot(node1)] = blockSize[getRoot(node1)]+blockSize[getRoot(node2)];
            parent[getRoot(node2)] = getRoot(node1);
        } else{
            blockSize[getRoot(node2)] = blockSize[getRoot(node2)]+blockSize[getRoot(node1)];
            parent[getRoot(node1)] = getRoot(node2);
        }
    }
    public boolean find(int node1, int node2){
        return getRoot(node1)==getRoot(node2);
    }
    public int countGroup(){
        int ans = 0;
        for(int i=0;i<size;i++) if(isRoot(i)) ans++;
        return ans;
    }
    public int blockSize(int node){
        return blockSize[getRoot(node)];
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M], b = new int[M];
        for(int m=0; m<M; m++){
            a[m] = sc.nextInt()-1;
            b[m] = sc.nextInt()-1;
        }

        int ans = 0;

        for(int m=0; m<M; m++){
            UnionFind graph = new UnionFind(N);
            for(int i=0; i<M; i++) if(i!=m) graph.union(a[i], b[i]);
            if(graph.blockSize(0)<N) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24532
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>
#include <regex>
#include <sstream>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll a, b, c, x, y;

    cin >> a >> b >> c >> x >> y;

    ll maxi = max(x * 2, y * 2);
    ll sum = 1e+16;
    for (ll cnum = 0; cnum <= maxi; cnum++)
    {
        ll bnum = max(y - cnum, 0ll);
        ll anum = max(x - cnum, 0ll);
        ll current = anum * a + bnum * b + cnum * c * 2;
        if (sum > current)
        {
            sum = current;
        }
    }
    cout << sum << "\n";

    return 0;
}


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

typedef long long ll;

ll a[200005],b[200005];
ll min1;

int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll sum1=0,sum2=0;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<=n;i++){
		if(sum1+a[i]<=k){
			sum1+=a[i];
			sum2=i;
		}
		else {
			break;
		}
	}
	for(ll i=1;i<=m;i++){
		cin>>b[i];
	}
	if(sum2==0){
		ll sum123=0,sum246=0;
		for(ll i=1;i<=m;i++){
			if(sum123+b[i]<=k){
				sum123+b[i];
				sum246=i;
			}
			else {
				break;
			}
		}
		cout<<sum246<<endl;
		return 0;
	}
	ll sum3=sum1,sum4=sum2;
	ll max1=sum2;
	ll rem=1;
	while(sum2>=1&&rem<=m){
		while(sum2>=1&&sum3+b[rem]>k){
			sum3-=a[sum2--];
			sum4--;
		}
		while(rem<=m&&sum3+b[rem]<=k){
			sum3+=b[rem++];
			sum4++;
		}
		max1=max(max1,sum4);
//		cout<<sum2<<" "<<rem<<" "<<max1<<" "<<sum3<<endl;
		
	}
	cout<<max1<<endl;
	return 0;
}

Measured memory_bytes: 6680
#include <stdio.h>
#include <algorithm>

using namespace std;

#define N 1100

int n, m;
int a[N], b[N];

int main() {
    while (scanf("%d%d%d%d", &n, &m, &a[0], &b[0]) != EOF) {
        for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
        for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
        sort(a, a + n + 1); sort(b, b + m + 1);
        //printf("%d %d\n", a[n], b[0] -1);
        if (a[n] < b[0]) puts("No War");
        else puts("War");
    }
    return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    cout << (count(s.begin(), s.end(), 'R') > 
        count(s.begin(), s.end(), 'B') ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
S = input()
n = len(S)
res = 0
for i in range(1 << n-1):
    subres = 0
    subst = S[0]
    for j in range(n-1):
        if i >> j & 1:
            subres += int(subst)
            subst = S[j+1]
        else:
            subst += S[j+1]
        if j == n - 2:
            subres += int(subst)
    res += subres
if n == 1:
    print(int(S))
else:
    print(res)




Measured memory_bytes: 9052
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))

struct node {
	ll id;
	bool done;
	vector<ll> link;
};
struct edge {
	ll n1, n2;
};
ll N;
vector<node> nod;
vector<edge> ed;
vector<ll> usededge;

ll nxt(ll node_idx, ll edge_idx) {
	if (ed[edge_idx].n1 == node_idx) return ed[edge_idx].n2;
	else return ed[edge_idx].n1;
}

ll biton(ll src, ll n) {
	return (src | (1LL << n));
}

ll dfs(ll ind, ll goal, ll f){
	nod[ind].done = true;
	if (nod[ind].id == goal)return f;
	for (ll e : nod[ind].link) {
		ll c = nxt(ind, e);
		if (nod[c].done) continue;
		ll ret = dfs(c, goal, biton(f, e));
		if (ret != -1)return ret;
	}
	return -1;
}

void addconst(ll u, ll v) {
	REP(i, 0, N)nod[i].done = false;
	ll used = dfs(u, v, 0);
	usededge.push_back(used);
}

ll popcnt(ll b) {
	ll ans = 0;
	while (b > 0) {
		if ((b & 1) > 0)++ans;
		b >>= 1;
	}
	return ans;
}

ll merge(ll apply_const) {
	ll ret = 0;
	ll c = 0;
	while (apply_const > 0) {
		if ((apply_const & 1) > 0) ret |= usededge[c];
		++c;
		apply_const >>= 1;
	}
	return ret;
}

ll f(ll apply_const) {
	return (1LL << (N - 1 - popcnt(merge(apply_const))));
}


int main() {
	cin >> N;
	nod.resize(N);
	REP(i, 0, N)nod[i].id = i;
	REP(i, 0, N-1) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		nod[a].link.push_back(i);
		nod[b].link.push_back(i);
		ed.push_back({ a,b });
	}
	ll M;
	cin >> M;
	REP(i, 0, M) {
		ll u, v;
		cin >> u >> v;
		--u; --v;
		addconst(u, v);
	}
	ll mx = (1LL << M) - 1;
	ll cnt = 0;
	for(ll i = 1; i <= mx; ++i){
		cnt += f(i) * ((popcnt(i) - 1) % 2 == 0 ? 1 : -1);
	}
	ll ans = (1LL << (N - 1)) - cnt;
	PRI(ans);
	return 0;
}




Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    
    while(1){
        bool niko=false;
        ll maki=ll(sqrt(x));
        for(int i=2;i<=maki;i++){
            if(x%i==0)niko=true;
        }
        if(niko){x++;}
        else{cout << x<<endl;break;}
    }
    return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  n = n % 10;

  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    cout << "hon" << endl;
  }else if(n == 3){
    cout << "bon" << endl;
  }else{
    cout << "pon" << endl;
  }

  
  return 0;
}


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

int main(){
    int N, cnt = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    for (int i = 0; i < N-1; i++){
        for (int j = N-1; j > i; j--){
            if (A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                cnt++;
            }
        }
    }
    for (int i = 0; i < N-1; i++){
        cout << A[i] << " ";
    }
    cout << A[N-1] << endl << cnt << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  vector<vector<bool>> q(h, vector<bool>(w));

  //横
  rep(i,h) {
    rep(j,w) {
      if (a[i][j] == '#') break;
      if (j == w-1 && a[i][j] == '.') {
        rep(k,w) {
          q[i][k] = true;
        }
      }
    }
  }

  //縦
  rep(i,w) {
    rep(j,h) {
      if (a[j][i] == '#') break;
      if (j == h-1 && a[j][i] == '.') {
        rep(k,h) {
          q[k][i] = true;
        }
      }
    }
  }

  ll c = 0;
  rep(i,h) {
    rep(j,w) {
      if (q[i][j] == false) {
        cout << a[i][j];
        ++c;
      }
    }
    if (c == 0) continue;
    else {
      cout << '\n';
      c = 0;
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;

ll n,m,k,a,b,c,t=1;
void solve()
{ll cnt=0;
   cin>>n>>m>>k;
   for(ll i=n;i<=m;i++)
   {
       if(i%k==0)cnt++;
   }
   cout<<cnt;
 //cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 // cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

typedef complex<double> P;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
#define mp(a, b) make_pair(a, b)
const double eps = 1e-9;

double cross(const P &a, const P &b){
    return imag(conj(a) * b);
}

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

int ccw(P a, P b, P c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct L:vector<P>{
    L(const P &a, const P &b){
        push_back(a); push_back(b);
    }
};

bool interSS(const L &s, const L &t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

P xptLL(const L &l, const L &m){
    double d = cross(l[1] - l[0], m[1] - m[0]);
    if(abs(d) < eps)return l[0];
    return m[0] + (m[1] - m[0]) * cross(l[1] - l[0], l[1] - m[0]) / d;
}

int solve(vector<pair<int, int> > info, int l){
    int res = 0;
    for(auto x: info){
        if(x.second & 2){
            res += l != (x.second & 1);
            l = x.second & 1;
        }else{
            res += l == (x.second & 1);
            l = x.second ^ 1;
        }
    }
    return res;
}

int main(){
    int T;
    cin >> T;
    while(T--){
        int xa, ya, xb, yb;
        cin >> xa >> ya >> xb >> yb;
        L linear(P(xa, ya), P(xb, yb));
        int n;
        cin >> n;
        vector<L> line;
        vector<pair<int, int> > info;
        rep(i, n){
            int xs, ys, xt, yt, o, l;
            cin >> xs >> ys >> xt >> yt >> o >> l;
            if(!interSS(linear, L(P(xs, ys), P(xt, yt))))continue;
            line.push_back(L(P(xs, ys), P(xt, yt)));
            info.push_back(mp((int)line.size() - 1, o << 1 | l << 0));
        }
        sort(all(info), [&](const pair<int, int> &a, const pair<int, int> &b){
                return abs(linear[0] - xptLL(linear, line[a.first]))
                           < abs(linear[0] - xptLL(linear, line[b.first]));});
        cout << min(solve(info, 0), solve(info, 1)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int W;
    int H;
    int N;
    int[] x;
    int[] y;
    int[] a;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.W = sc.nextInt();
        this.H = sc.nextInt();
        this.N = sc.nextInt();
        x = new int[N];
        y = new int[N];
        a = new int[N];
        for (int i=0; i<N; i++) {
        	x[i] = sc.nextInt();
        	y[i] = sc.nextInt();
        	a[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        
        int lx = 0; //長方形左下のx座標
        int ly = 0; //長方形左下のy座標
        int rx = W; //長方形右上のx座標
        int ry = H; //長方形右上のy座標
        //右下と左上は(W,0)、(0,H)
        
        for(int i=0; i<N; i++){
          if(a[i] == 1){ //x[i]>xの領域を塗りつぶす
            lx = Math.max(lx, x[i]);
          }else if(a[i] == 2){ //x[i]<xの領域を塗りつぶす
            rx = Math.min(rx, x[i]);
          }else if(a[i] == 3){ //y[i]>yの領域を塗りつぶす
            ly = Math.max(ly, y[i]);
          }else if(a[i] == 4){ //y[i]<yの領域を塗りつぶす
            ry = Math.min(ry, y[i]);
          }
        }
        
        answer = (rx-lx) * (ry-ly);
        if ((rx-lx) < 0 || (ry-ly) < 0) {
        	answer = 0;
        }
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 36204
#include<stdio.h>
#define N 100

int main()
{
  int i, j, k, n, v, arr[N];

  while(1){
    scanf("%d", &n);
    if(n >= 1 || n <= 100) break;
  }

  for(i = 0; i < n; i++){
    scanf("%d", &arr[i]);
    if(arr[i] < 0 || arr[i] >1000) i--;
  }

  for(i = 0; i < n - 1; i++){
    printf("%d ", arr[i]);
  }
  printf("%d\n", arr[i]);

  for(i =1; i < n; i++){
    v = arr[i];
    j = i - 1;
    while(j >= 0 && arr[j] > v){
      arr[j + 1] = arr[j];
      j--;
    }

    arr[j + 1] = v;
    for(k = 0; k < n - 1; k++){
      printf("%d ", arr[k]);
    }
    printf("%d\n", arr[k]);
  }

  return 0;
}

Measured memory_bytes: 600
//@author yash
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	fast();
	string s;
	cin>>s;
	int cnt=0;
	int cnt1=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='A')
		cnt++;
		else
		cnt1++;
	}
	if(cnt==s.length()||cnt1==s.length())
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
}



Measured memory_bytes: 256