akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=b;i>=a;i--)
#define sc(x) scanf("%d",&x)
#define pb push_back
#define ll long long
const ll mod=998244353;
int a[200005];
int vis[200005];
int now[200005];
ll ad(ll a,ll b)
{
	return (((a%mod+b%mod)%mod)+mod)%mod;
}
ll ap(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll ksm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)
		{
			res=ap(res,a);}
			a=ap(a,a);
			b/=2;
		
	}
	return res;
}
ll jc[200005];
ll C(int n,int m)
{
	if(m==0)return 1;
	return ap(jc[n],ap(ksm(jc[n-m],mod-2),ksm(jc[m],mod-2)));
}
int main(int argc, char** argv) {
	int n,m,k;
	cin>>n>>m>>k;
	int cb=n-1-k;
	ll ans=0;
	jc[0]=1;
	rep(i,1,n)
	{
		jc[i]=ap(jc[i-1],i);
	} 
	rep(i,cb+1,n)
	{
		ans=ad(ans,ap(C(n-1,i-1),ap(ksm(m-1,i-1),m)));
//		cout<<ap(C(n-1,i-1),ap(ksm(m-1,i-1),m))<<endl;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5156
n=int(input())

result = [0] * (n+1)
for x in range(1,99):
  for y in range(1,99):
    for z in range(1,99):
      fn = x*x + y*y + z*z + x*y + y*z + z*x
      if fn > n:
        break
      result[fn] += 1

for i in range(1,n+1):
  print(result[i])


Measured memory_bytes: 73904
N, K = map(int, input().split())
p = list(map(int, input().split()))

rp = sum(list(p[0:K]))
rm = 0
ans = rp
for i in range(N-K):
  rp += p[i+K]
  rm += p[i]
  if rp - rm > ans:
    ans = rp - rm

print((ans+K)/2)

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

#define MAXN 100010

int n,a[MAXN];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",a+i);
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=1;i<=n;++i)
		if(a[i]<=i)
		{
			int k=0;
			while(a[i+k]==i)++k;
			puts((k&1||a[i-1]-(i)&1)?"First":"Second");
			return 0;
		}
}

Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<math.h>
#include<vector>
using namespace std;


//素因数分解
map<long long, long long> prime_factor(long long n){
    map<long long,long long> mp;
    for(long long i = 2; i*i <= n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

//basic
class IsPrimeSearch {
    private :
        static const int Maximum = 1e6;
        bool isPrime[Maximum+1];

    public :
        void init(){
            for(int i = 1; i <= Maximum; i++){
                isPrime[i] = true;
            }
        }

        bool IsPrimeSetting(int InputNumber){
            if(InputNumber < 2) return false;
            if(InputNumber == 2) return true;
            if(InputNumber % 2 == 0) return false;

            for(int i = 3; i*i <= sqrt(InputNumber); i += 2){
                if(InputNumber % i == 0) return false;
            }
            return true;
        }

        int PrimeCheck(){
            for(int i = 1; i < Maximum; i++){
                if(isPrime[i]){
                    return i;
                }
            }
            return -1;
        }

        void Eratosthenes(){
            isPrime[0] = false;
            isPrime[1] = false;
            for(int i = 2; i <= Maximum; i++){
                if(isPrime[i] == 1){
                    for(int j = 2*i; j <= Maximum; j += i){
                        isPrime[j] = false;
                    }
                }
            }
        }
        bool IsPrimeNumber(int InputNumber){
            if (isPrime[InputNumber]){
                return true;
            } else {
                return false;
            }
        }
};

const int N = 1e5;
bool isprime(int N){
    if(N < 2) return false;
    if(N == 2) return true;
    if(N % 2 == 0) return false;

    for(int i = 3; i*i <= sqrt(N); i += 2){
        if(N % i == 0) return false;
    }
    return true;
}

//Sieve of Eratosthenes

bool isPrime[N+1];
void init(){
    for(int i = 1; i <= N; i++){
        isPrime[i] = true;
    }
}
int Prime_check(){
    for(int i = 1; i < N; i++){
        if(isPrime[i]){
            return i;
        }
    }
    return -1;
}

void Eratosthenes(int N){
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i <= N; i++){
        if(isPrime[i] == 1){
            for(int j = 2*i; j <= N; j += i){
              isPrime[j] = false;
            }
        }
    }
}


int main(){
    IsPrimeSearch isp = IsPrimeSearch();
    isp.init();
    isp.Eratosthenes();
    int N; cin >> N;
    while (true){
        if (isp.IsPrimeNumber(N)){
            cout << N << endl;
            break;
        }
        N++;
    }
}



Measured memory_bytes: 1280
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;
typedef vector<ll> VL;
#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++)
const long long INF = 999999999;
ll N,a[100010],b[100010],c[100010],dp[100010][3],ans;
// dp[i][0]はAを選んでいる dp[i][1]はBを選んでいる　dp[i][2]はCを選んでいる

int main(){
  cin >> N;
  REP(i,N){
    cin >> a[i]>>b[i]>>c[i];
  }
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  FOR(i,1,N){
    dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
  }
  ans=max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
  cout <<ans<<endl;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int sum;
    int cnt = 0;
    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                sum = 500 * i + 100 * j + 50 * k;
                if (sum == X) cnt += 1;
            }
            
        }
        
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    LL h; cin >> h;
    LL num = 0;
    while(h) {
        h /= 2;
        num *= 2;
        num++;
    }
    cout << num;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int max = 0;
        int tmp = 0;
        for (int i = 0; i < s.length(); ++i) {
            char ch = s.charAt(i);
            if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') ++tmp;
            else tmp = 0;
            if (tmp > max) max = tmp;
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <map>
using namespace std;

int N, K[2],p[2][200010];
map<pair<int, int>, int> chk;

int find(int *p, int x)
{
	if (p[x] != x) p[x] = find(p, p[x]);
	return p[x];
}

int main()
{
	scanf("%d", &N);
	scanf("%d %d", &K[0], &K[1]);
	for (int k = 0; k < 2; k++){
		int M = K[k];
		for (int i = 0; i < N; i++) p[k][i] = i;
		for (int i = 0; i < M; i++){
			int x, y; scanf("%d %d", &x, &y); x--; y--;
			p[k][find(p[k], x)] = find(p[k], y);
		}
	}

	for (int i = 0; i < N; i++) chk[{find(p[0], i), find(p[1], i)}]++;
	for (int i = 0; i < N; i++) printf("%d ", chk[{find(p[0], i), find(p[1], i)}]);
	puts("");

	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

ll solve() {
    int N, K;
    cin >> N >> K;
    int a;
    REP(i, N) cin >> a;
    ll ans = (N-1+K-1-1)/(K-1);
    
    return ans;
}

int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<int> x1(n), y1(n), x2(n), y2(n);
    for (int i = 0; i < n; i++){
      cin >> x1[i] >> y2[i] >> x2[i] >> y1[i];
    }
    vector<int> xc;
    for (int i = 0; i < n; i++){
      xc.push_back(x1[i]);
      xc.push_back(x2[i]);
    }
    sort(xc.begin(), xc.end());
    xc.erase(unique(xc.begin(), xc.end()), xc.end());
    int xcnt = xc.size();
    map<int, int> mpx;
    for (int i = 0; i < xcnt; i++){
      mpx[xc[i]] = i;
    }
    for (int i = 0; i < n; i++){
      x1[i] = mpx[x1[i]];
      x2[i] = mpx[x2[i]];
    }
    vector<int> yc;
    for (int i = 0; i < n; i++){
      yc.push_back(y1[i]);
      yc.push_back(y2[i]);
    }
    sort(yc.begin(), yc.end());
    yc.erase(unique(yc.begin(), yc.end()), yc.end());
    int ycnt = yc.size();
    map<int, int> mpy;
    for (int i = 0; i < ycnt; i++){
      mpy[yc[i]] = i;
    }
    for (int i = 0; i < n; i++){
      y1[i] = mpy[y1[i]];
      y2[i] = mpy[y2[i]];
    }
    vector<vector<vector<bool>>> ok(ycnt + 1, vector<vector<bool>>(xcnt + 1, vector<bool>(4, true)));
    for (int i = 0; i < n; i++){
      for (int j = x1[i] + 1; j < x2[i] + 1; j++){
        ok[y1[i]][j][0] = false;
        ok[y2[i]][j][0] = false;
        ok[y1[i] + 1][j][2] = false;
        ok[y2[i] + 1][j][2] = false;
      }
      for (int j = y1[i] + 1; j < y2[i] + 1; j++){
        ok[j][x1[i]][1] = false;
        ok[j][x2[i]][1] = false;
        ok[j][x1[i] + 1][3] = false;
        ok[j][x2[i] + 1][3] = false;
      }
    }
    vector<vector<int>> c(ycnt + 1, vector<int>(xcnt + 1, -1));
    int ans = 0;
    for (int i = 0; i <= ycnt; i++){
      for (int j = 0; j <= xcnt; j++){
        if (c[i][j] == -1){
          c[i][j] = ans;
          queue<pair<int, int>> Q;
          Q.push(make_pair(i, j));
          while (!Q.empty()){
            int y = Q.front().first;
            int x = Q.front().second;
            Q.pop();
            for (int k = 0; k < 4; k++){
              if (ok[y][x][k]){
                int y2 = y + dy[k];
                int x2 = x + dx[k];
                if (0 <= y2 && y2 <= ycnt && 0 <= x2 && x2 <= xcnt){
                  if (c[y2][x2] == -1){
                    c[y2][x2] = ans;
                    Q.push(make_pair(y2, x2));
                  }
                }
              }
            }
          }
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3960
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;

	return 0;
}

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

using namespace std;

typedef long long LL;

const int MAXN = 1e05 + 10;
const int MAXM = 1e05 + 10;

int N, M;
LL que[MAXM]= {0};
int tail = 0;

LL suffix[MAXM]= {0};
int value[MAXM]= {0};
int findpos (int limit, LL delta) {
	if (delta < que[1]) return delta;
	int posi = upper_bound (que + 1, que + limit, delta) - que - 1;
	LL add = delta / que[posi], rest = delta % que[posi];
	suffix[posi] += suffix[limit] * add;
	return findpos (limit, rest);
}
LL subsum[MAXN]= {0};
void solve () {
	value[1] = que[1], suffix[tail] = 1;
	for (int i = tail; i >= 2; i --) {
		int val = findpos (i, que[i]);
		value[i] = val;
	}
	for (int i = tail; i >= 1; i --)
		subsum[value[i]] += suffix[i];
	for (int i = N - 1; i >= 1; i --)
		subsum[i] += subsum[i + 1];
}

template<typename T>
T getnum () {
	T num = T ();
	char ch = getchar ();

	while (! isdigit (ch))
		ch = getchar ();
	while (isdigit (ch))
		num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();

	return num;
}
inline void write (LL x) {
	if (x >= 10) write (x / 10);
	putchar (x % 10 + '0');
}
inline void println (LL x) {
	write (x), puts ("");
}

int main () {
	// freopen ("SS.in", "r", stdin);
	// freopen ("SS.out", "w", stdout);

	N = getnum<int> (), M = getnum<int> ();
	que[++ tail] = N;
	for (int i = 1; i <= M; i ++) {
		LL posi = getnum<LL> ();
		while (tail >= 1 && que[tail] >= posi) tail --;
		que[++ tail] = posi;
	}
	solve ();
	for (int i = 1; i <= N; i ++)
		println (subsum[i]);

	return 0;
}

/*
5 3
6
4
11
*/

/*
10 10
9
13
18
8
10
10
9
19
22
27
*/

/*
10 10
15
22
12
18
16
2
18
18
10
18
*/

/*
10 10
6
26
2
12
12
2
8
10
6
20
*/

/*
10 10
10
24
2
18
18
18
16
18
6
4
*/

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b; cin >> a >> b;
	string str; cin >> str;
	vector<pair<int, int> > V;
	int tmp = 1;
	for(int i=1; i<a; i++)
	{
		if(str[i] != str[i - 1])
		{
			V.push_back(make_pair(tmp, (str[i - 1] - '0')));
			tmp = 1;
			continue;
		}
		tmp ++;
	}
	V.push_back(make_pair(tmp, (str[a - 1] - '0')));
	tmp = 0;
	int ans = 0, left = 0, cnt = 0;
	for(int i=0; i<V.size(); i++)
	{
		if(V[i].second == 0)
		{
			cnt ++;
			if(cnt > b)
			{
				while(V[left].second == 1)
					tmp -= V[left++].first;
				tmp -= V[left++].first;
				cnt --;
			}
		}
		tmp += V[i].first;
		ans = max(ans, tmp);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 1528
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Dice dice = new Dice(sc.nextLine().split(" "));
			int num = sc.nextInt();
			for(int i=0;i<num;i++) {
				dice.toTop(sc.nextInt());
				dice.toFront(sc.nextInt());
				System.out.println(dice.showN(2));
			}
		}
	}
	static class Dice{
		
		private int[] face;
		
		public Dice(int[] face) {
			this.face = face;
		}
		public Dice(String[] face) {
			this.face = new int[6];
			for(int i=0;i<this.face.length;i++) {
				this.face[i] = Integer.parseInt(face[i]);
			}
		}
		
		/**
		 * 東西南北EWSN+右左RLでさいころを回転させます
		 * @param to 回転向き?
		 */
		public void rotate(char to){
			int buf;
			switch(to) {
			case 'E':
				buf = this.face[0];
				this.face[0] = this.face[3];
				this.face[3] = this.face[5];
				this.face[5] = this.face[2];
				this.face[2] = buf;
				break;
			case 'W':
				buf = this.face[0];
				this.face[0] = this.face[2];
				this.face[2] = this.face[5];
				this.face[5] = this.face[3];
				this.face[3] = buf;
				break;
			case 'S':
				buf = this.face[0];
				this.face[0] = this.face[4];
				this.face[4] = this.face[5];
				this.face[5] = this.face[1];
				this.face[1] = buf;
				break;
			case 'N':
				buf = this.face[0];
				this.face[0] = this.face[1];
				this.face[1] = this.face[5];
				this.face[5] = this.face[4];
				this.face[4] = buf;
				break;
			case 'R':
				buf = this.face[1];
				this.face[1] = this.face[2];
				this.face[2] = this.face[4];
				this.face[4] = this.face[3];
				this.face[3] = buf;
				break;
			case 'L':
				buf = this.face[1];
				this.face[1] = this.face[3];
				this.face[3] = this.face[5];
				this.face[5] = this.face[2];
				this.face[2] = buf;
				break;
			}
		}
		
		/**
		 * 指定した数字を上面に持ってきます
		 * @param num
		 */
		public void toTop(int num) {
			if(this.showTop()==num) return;
			int i;
			for(i=0;i<4;i++) {
				this.rotate('N');
				if(this.showTop() == num) {
					return;
				}
			}
			for(i=0;i<4;i++) {
				this.rotate('W');
				if(this.showTop() == num) {
					return;
				}
			}
		}
		
		/**
		 * 指定した数字を手前に持ってきます
		 * 水平一線のみ可
		 * @param num
		 */
		public void toFront(int num) {
			if(this.showN(1)==num) return;
			for(int i=0;i<4;i++) {
				this.rotate('R');
				if(this.showN(1) == num) {
					return;
				}
			}
		}
		public int showTop() {
			return this.face[0];
		}
		public int showN(int n) {
			return this.face[n];
		}
	}
}


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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(i, c) ((c).find(i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define repa(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)

//=========================

void run_test() {
	int a, b; cin >> a >> b;
	cout << a * b << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//int t = 1, _t; cin >> _t; while(t <= _t) { cout << "Case #" << t++ << ": "; run_test(); }
	//int t; cin >> t; while(t--) run_test();
	run_test();
	return 0;	
}



Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define m 1000000007
#define N 200005
#define modinv(a) power(a,m-2)
#define gcd(a,b) __gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define popb pop_back
#define all(v) v.begin(),v.end()
#define nl "\n"
typedef long long ll;
ll power(ll a,ll b)
{
    ll res;
    if(b==0)return 1;
    if(b==1)return a%m;
    if(b&1)
    {
        res=power(a,b-1)%m;
        res=((a%m)*(res%m))%m;
    }
    else
    {
        res=power(a,b/2)%m;
        res=((res%m)*(res%m))%m;
    }
    return res;
}
void solve()
{
    ll n,i,a[N],ans=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(i=1;i<n;i++)
    {
        ans+=a[n-(i/2)];
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 5184
N = int(input())
L = len(str(N))
A,B=int(str(N)[L-1]),int(str(N)[0])
c = 0
for i in range(1,N+1):
    I = str(i)
    l = len(I)
    a,b = int(I[0]),int(I[l-1])
    if a == 0 or b == 0:
        continue
    else:
        if a == b:
            c += 1
        for m in range(max(L-2,0)):
            c += 10**m
        if L == 1:
            continue
        if b > B:
            continue
        elif b < B:
            c += 10**(L-2)
        elif L > 2 and a <= A:
            c += int(str(N)[1:L-1])+1
        elif L > 2:
            c += int(str(N)[1:L-1])
        elif L == 2:
            c += 1
print(c)

Measured memory_bytes: 3064
'''
DPで解く
操作を以下2パターンとして考える
 6 ** 0(= 1), 6 ** 1, 6 ** 2...
 9 ** 0(= 1), 9 ** 1, 9 ** 2...
'''

N = int(input())

# DPテーブル
dp = [10 ** 5] * (N + 1)

# 6 or 9 の累乗のリスト
six = []
c = 0
while True:
    w = 6 ** c
    if w > N:
        break
    six.append(w)
    c += 1
nine = []
c = 0
while True:
    w = 9 ** c
    if w > N:
        break
    nine.append(w)
    c += 1

# 初期値
dp[0] = 0

# ループ
for i in range(N + 1):
    # 6の累乗を引き出すケース
    for s in six:
        if i + s > N:
            break
        dp[i + s] = min(dp[i + s], dp[i] + 1)
    # 9の累乗を引き出すケース
    for n in nine:
        if i + n > N:
            break
        dp[i + n] = min(dp[i + n], dp[i] + 1)

# 解を出力
print(dp[N])


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    string s;cin>>s;
    ll i = s.size();
    char a = s[i-1];
    string ans;
    // cout<<a<<endl;
    if(a=='3') ans = "bon";
    else if(a=='0' || a=='1' || a=='6' || a=='8') ans = "pon";
    else ans = "hon";
    cout<<ans<<endl;
    return 0;

}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dp[3010][3010];

signed main(){

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

	dp[0][0]=0;

	for(lli i=0;i<s.size();i++){
		for(lli j=0;j<t.size();j++){
			if(s[i]==t[j])dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
			dp[i+1][j+1] = max(dp[i+1][j],dp[i+1][j+1]);
			dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j+1]);
		}
	}

	lli d = dp[s.size()][t.size()];
	lli y = s.size();
	lli x = t.size();
	string ans ="";
	while(true){
		if(d==0)break;
		if(dp[y-1][x]==d)y--;
		else if(dp[y][x-1]==d)x--;
		else{
			ans += s[y-1];
			x--,y--,d--;
		}
	}

	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 70784
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e5 + 120;
 
double res;
int main(){FAST;
    int n ,k;
    cin >> n >> k;
    
    for(int i  = 1, now; i <= n; i++){
        double tmp = 1.0/n;
        now = i;
        while(now < k)
            now *= 2,tmp /= 2;
        res += tmp;
    }
        cout << setprecision(12) << fixed << res << endl;
   return 0;
}
 












Measured memory_bytes: 256
S=input()
A=int(S[:2])
B=int(S[2:])

YM=MY=False
if 0<B<=12: YM=True
if 0<A<=12: MY=True

if MY and YM: print("AMBIGUOUS")
elif MY: print("MMYY")
elif YM: print("YYMM")
else: print("NA")

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	string s;
	cin >> s;
	SREP(i,s) if(s[i]==',') s[i]=' ';
	cout << s << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
const int maxn=2e5+10;
int b[30];
int a[30][30];
int main()
{
	int n,m,c;
	cin>>n>>m>>c;
	for(int i=1;i<=m;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int ans=0;
		for(int j=1;j<=m;j++)
		{
			ans+=a[i][j]*b[j];
		}
		ans+=c;
		if(ans>0)
			sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

vector < vector <int> > v(100005);
int dp[100005];
int dhundhle(int i)
{

    if (v[i].empty())return 0;

    if(dp[i]>=0)return dp[i];

    int ans =-1;
    for(int j=0;j<v[i].size();j++)
    {
        ans=max(ans,dhundhle(v[i][j])+1);
        dp[i]=ans;
    }
    return ans;

}

int main()
{
    fio
   long long int n,m,i,j,x,y;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));

    int ans=-1;
    for(i=1;i<=n;i++)
    {
        ans=max(ans,dhundhle(i));
    }
    cout<<ans;

}





Measured memory_bytes: 8192
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int n;
  cin >>n;
  int i=1;
  while(i<=n) i *= 2;
  cout <<i/2<<endl;
}

Measured memory_bytes: 256
$s = <STDIN>;
 
my @dat =  split(/ /,$s);
 
my $A = $dat[0];
my $B = $dat[1];
my $C = $dat[2];

$L = 4 * $A * $B;
$M = ($C-$A-$B)* ($C-$A-$B);
if( ($C-$A-$B <0) ){ print "No";exit;}

if($L< $M){
  print "Yes";
}else{
  print "No";
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}


void solve(){

    ll n;
    cin >> n;
    ll a[n+1];
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }

    ll suf[n+1];
    suf[n] = a[n];
    for(int i=n-1;i>=1;i--){
        suf[i] = (suf[i+1] + a[i])%mod;
    }
    
    ll ans=0;
    for(int i=1;i<n;i++){
        ans += (a[i]*suf[i+1])%mod;
        ans %= mod;
    }
    cout << ans;
        
}

int32_t main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 6760
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll MOD=1e+9+7;
map<ll,ll> a;
ll ans(ll n){
	if(a[n]) return a[n];
	else return a[n]=(ans(n>>1)%MOD+ans((n-1)>>1)%MOD+ans((n-2)>>1)%MOD)%MOD;
}
int main(){
	ll N;
	scan(N);
	a[0]=1,a[1]=2;
	prin(ans(N));
	return 0;
}


Measured memory_bytes: 256
n = 10**4
ans = [0]*10**4
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            a = (x+y+z)**2 -(x*y+y*z+z*x)
            if a <= n:
                ans[a-1] += 1
for i in range(int(input())):
    print(ans[i])

Measured memory_bytes: 9436
def solve():
  ans = 0
  N = int(input())
  stacks = [list(map(lambda x:int(x)-1, input().split()))[::-1] for _ in range(N)]
  lis = [0]*N
  cnt = 0
  now = 0
  flag = 0
  while cnt<N*(N-1)//2:
    while not stacks[now]:
      now = (now+1)%N
    a = stacks[now][-1]
    while not stacks[a]:
      now = (now+1)%N
      a = stacks[now][-1]
    if stacks[a][-1] == now:
      lis[now] = max(lis[now],lis[a])+1
      lis[a] = lis[now]
      stacks[a].pop(-1)
      stacks[now].pop(-1)
      cnt += 1
      flag = 0
    else:
      now = a
      flag += 1
    if flag==2*N:
      return -1
  ans = max(lis)
  return ans
print(solve())

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

using namespace std;

int main()
{
        int n, T;
        cin >> n >> T;
        vector<int> t(n);
        for (int i = 0; i < n; ++i) {
                cin >> t[i];
        }

        int ans = 0;
        for (int i = 1; i < n; ++i) {
                if (t[i] - t[i - 1] >= T) {
                        ans += T;
                } else {
                        ans += t[i] - t[i - 1];
                }
        }
        ans += T;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
char buf[20000];sz;
inline int rd()
{
	int ret=buf[sz++]-'0';
	if(buf[sz]>='0')
	{
		ret=ret*10+buf[sz++]-'0';
		if(buf[sz]>='0')
		{
			ret=ret*10+buf[sz++]-'0';
			if(buf[sz]>='0')
			{
				ret=ret*10+buf[sz++]-'0';
				if(buf[sz]>='0')
				{
					ret=ret*10+buf[sz++]-'0';
				}
			}
		}
	}
	sz++;
	return ret;
}
int d[3001],d2[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=1;i<=N;i++)
	{
		d[S]=i;
		int A=rd();
		if(S>=A)memcpy(d2+A,d+A,(S-A+1)*4);
		for(int j=0;j<=S-A;j++)
		{
			d[j]+=d2[j+A];
			d[j]-=mod*(d[j]>=mod);
		}
		ans+=d[0];
		ans-=mod*(ans>=mod);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
# O(n * log(n)) で解く

def g(i, n, t) $a_sums[i] + h(i+1, n, t) end    # O(n)
def h(i, n, t) (i..n).inject(0) do |s,j| s + t / $fs[j] end end    # O(n)
def afs(i) $as[i] * $fs[i] end    # O(1)
def nlr(n, l, i) [n - i, l - $a_sums[i], $rs[i+1]] end    # O(1)

n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
fs = gets.split.map(&:to_i)
 
l = as.sum - k

if (l <= 0)
  p 0
  exit
end

# O(n * log(n))
as.sort!
fs.sort_by! {|f| -f}

max_f = fs[0]

# O(n * log(n))
$as, $fs = as.zip(fs).push([0,1]).sort_by do |a,f| a*f end.transpose

a_acc = 0
# O(n)
$a_sums = $as.map do |a| a_acc += a end

max_af = $as[n] * $fs[n]
q = max_f + max_af
$rs = []
# O(n)
n.downto(1).inject(0) do |r,i| $rs[i] = r + q / $fs[i] end

lb = ub = nil
ilb = nil

# O(n + log(n))
m = (0..n).bsearch do |i|
  next false if (i == 0)
  next true if (i == n)

  af = afs(i)
  nn, ll, r = nlr(n, l, i)

  next false if (af * (r + nn) / q < ll)
  next true if ((af * r + q - 1) / q - nn >= ll)

  next false if (lb)
  next true if (ub)

  # O(n)
  if (h(i+1, n, af) < ll)
    lb, ilb = af, i
    next false
  else
    ub = af
    next true
  end
end

# O(n)
if (lb)
  af = afs(m-1)
  ub = af if (g(m-1, n, af) > l)
elsif (ub)
  af = afs(m)
  lb, ilb = af, m if (g(m, n, af) < l)
end

# O(1)
unless (lb && ub)
  ilb = m-1

  nn, ll, r = nlr(n, l, m-1)

  af = afs(m)
  ub = [ub || max_af, (ll + nn) * q / r, af].min

  rr = r + nn
  af = afs(m-1)
  lb = [lb || 0, (ll * q + rr - 1)/ rr, af].max
end

ilb = 1 if (ilb == 0)
r = $a_sums[ilb-1]
xs = []
# O(n)
# push の回数は 3 * n を超えないはず
(ilb..n).each do |i|
  a, f = $as[i], $fs[i]
  aa = [ub / f, a].min
  r += aa
  (aa * f).step(lb, -f) do |x| xs.push(x) end
end

k = xs.length

raise if (k > 3 * n)

kk = r - l

# O(n) のアルゴリズムもあるが、この問題のサイズでは組み込みの sort を使った方が速いようだ
# O(n * log(n))
p xs.sort[k - 1 - kk]

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

int main(void){
    int n, k;
    cin>>n>>k;
    int i=0;
    while(n>=pow(k, i)){
        i++;
    }
    cout<<i<<endl;
}



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

typedef long long ll;
const ll MOD=998244353;

ll po[302][302];
ll C[602][602];
void init(){
	for(int i=0;i<302;i++){
		po[i][0]=1;
		for(int j=0;j+1<302;j++){
			po[i][j+1]=po[i][j]*i;
			po[i][j+1]%=MOD;
		}
	}
	for(int i=0;i<602;i++){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<=i-1;j++){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			C[i][j]%=MOD;
		}
	}
}

int main(){
	init();
	string s;
	ll k;
	cin>>s>>k;
	
	ll n=0;
	ll c[302];
	ll cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			c[n++]=cnt;
			cnt=0;
		}
		else cnt++;
	}
	c[n++]=cnt;
	
	/*cout<<n<<endl;
	for(int i=0;i<n;i++){
		cout<<c[i]<<" ";
	}cout<<endl;*/
	
	static ll dp[4][302][302]={};
	static ll t=0,t_=1;
	dp[t][0][0]=1;
	for(int x=0;x<n;x++){
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				dp[t_][i][j]=dp[2][i][j]=dp[3][i][j]=0;
			}
		}
		for(int i=0;i<302;i++){
			if(i+c[x]+1>=302)continue;
			for(int j=0;j<302;j++){
				if(dp[t][i][j]==0)continue;
				for(int y=1;y<=j;y++){
					dp[3][i+c[x]+1][y]+=MOD-dp[t][i][j]*C[j-y+c[x]][j-y]%MOD;
				}
			}
		}
		/*for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[3][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");*/
		for(int i=1;i<302;i++){
			for(int j=300;j>=1;j--){
				dp[2][i][j]=dp[t][i-1][j]+dp[2][i-1][j]+dp[2][i][j+1];
				dp[2][i][j]%=MOD;
			}
			for(int j=1;j<=300;j++){
				dp[2][i][j]+=dp[3][i][j];
				dp[2][i][j]%=MOD;
			}
		}
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				dp[t_][i][j]=dp[2][i][j];
				if(j>0){
					dp[t_][i][j]+=dp[t][i][j-1];
					if(dp[t_][i][j]>=MOD)dp[t_][i][j]-=MOD;
				}
			}
		}
		swap(t,t_);
		/*for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[t][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");*/
	}
	
	ll ret=0;
	for(int i=0;i<=min(k,(ll)301);i++){
		for(int j=1;j<=301;j++)ret+=dp[t][i][j];
	}
	cout<<ret%MOD<<endl;
	
	/*ll dp[2][302][302]={};
	ll t=0,t_=1;
	dp[t][0][0]=1;
	for(int x=0;x<n;x++){
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				dp[t_][i][j]=0;
			}
		}
		for(int i=0;i<302;i++){
			for(int j=0;j<302;j++){
				if(dp[t][i][j]==0)continue;
				dp[t_][i][j]+=dp[t][i][j];
				dp[t_][i][j+1]+=MOD-dp[t][i][j]*(x+1-i)%MOD;
				dp[t_][i+1][j+1]+=dp[t][i][j]*(x-i)%MOD;
				dp[t_][i+1][j+c[x]+1]+=MOD-dp[t][i][j]*po[x-i][c[x]+1]%MOD;
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[t_][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");
		for(int i=0;i<302;i++){
			dp[t_][i][0]%=MOD;
			for(int j=0;j+1<302;j++){
				dp[t_][i][j+1]+=dp[t_][i][j]*(x+1-i);
				dp[t_][i][j+1]%=MOD;
			}
		}
		swap(t,t_);
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				cout<<dp[t][i][j]<<" ";
			}cout<<endl;
		}
		puts("==========");
	}
	
	ll ret=0;
	for(int i=0;i<302;i++){
		for(int j=0;j<=k;j++){
			ret+=dp[t][i][j];
		}
	}
	cout<<ret%MOD<<endl;*/
}



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

using namespace std;

int n;
int main()
{
    cin >> n;
    int tot = 0;
    if(n <= 9) cout << n << endl;
    else 
    {
        tot += 9;
        if(n <= 999) cout << tot + max(0, n-100+1) << endl;
        else 
        {
            tot += 900;
            if(n <= 99999) cout << tot + max(0, n-10000+1) << endl;
            else
            {
                tot += 90000;
                cout << tot << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{//你是我最爱的小饼干
	int N, a[100],i;//a[i]用来储存健康值（应该说数组a用来储存健康值）
	int sum=0;//用来储存所有的健康值（两两相乘的和）
	scanf("%d",&N);//输入小饼干的个数（对啦）
	for( i=0;i<N;i++){//第一个小饼干（不是的哦）
		//通过循环读取每个小饼干的健康值，一共N个
		scanf("%d",&a[i]);
	}
	int j;
	for(i=0;i<N;++i){//这是个二重循环
		for(j=i+1;j<N;++j){
			sum+=a[i]*a[j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
F = []
P = []
ans = -10**9
def cal_same_num(F,temp):
    num_same = 0
    for i in range(10):
        if temp[i] == "1" and F[i] == 1:
            num_same += 1
    return num_same

for i in range(N):
    F.append(list(map(int,input().split(" "))))
for i in range(N):
    P.append(list(map(int,input().split(" "))))

for i in range(1,2**10):
    sum_point = 0
    temp = str(format(i,"b")).zfill(10)
    for j in range(N):
        num_same = cal_same_num(F[j],temp)
        point = P[j][num_same]
        sum_point += point
    ans = max(ans,sum_point)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,x) for(long long i=1;i<=x; i++)
#define INF 1000100
typedef long long  ll;
using namespace std;


int main(){
	int K;
  cin>>K;
  
  auto Uk = [&](int p, int q){
  	while(q != 0){
    	int r = p%q;
      p=q;
      q=r;
    }
    return p;
  };
  
  ll ans=0;
  
  rep(a,K){
  	rep(b,K){
    	rep(c,K){
          	int ab = Uk(a,b);
        	ans+= Uk(ab,c);
        }
   	}
  }
  cout<< ans;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  double ans=0;
  rep(i,n){
    double a;cin>>a;
    ans+=1/a;
  }
  ans=1/ans;
  coutd(ans);
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0] * (n + 1)
dp[0] = 1
for obstacle in a:
    dp[obstacle] = -1

for i in range(n):
    if dp[i + 1] >= 0 and dp[i] >= 0:
        dp[i + 1] += dp[i]
    if i >= 1 and dp[i + 1] >= 0 and dp[i - 1] >= 0:
        dp[i + 1] += dp[i - 1]

print(dp[-1] % 1000000007)


Measured memory_bytes: 468728
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n, a[100005]; 
int dp[100005]; 
 
int func(int ind) {
	if(ind==(n-1)) return 0; 
	if(ind>=n) return INT_MAX; 
 
	if(dp[ind]!=-1) return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + func(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + func(ind+2); 
	}
 
	return dp[ind] = min(left, right); 
}
signed main() {
	
	cin >> n;
 
	memset(dp, -1, sizeof dp); 
	
	for(int i = 0;i<n;i++) {
		cin >> a[i]; 
	}
 
	cout << func(0); 
}

Measured memory_bytes: 9768
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin>>N;
    string s;
    cin>>s;
    int count =0;
    for(int i = 0;i<N;i++){
        if(s.at(i)=='R'){
            count ++;
        }
    }
    if(count>N/2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
        
}

Measured memory_bytes: 3584
// AOJ 0179: Mysterious Worm
// 2017.8.22 bal4u@uu
// 2017.11.1 retry

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

#define MAX 0xaaaaa

char chk[MAX+5];
int q[MAX+5], *top, *end;

int nxt[16] = { 0,10,5,0,10,5,0,0,5,0,10 };

int main()
{
	int s, r, g, b, step, N, K, mask;
	int i, k;
	char buf[16], *bp;

	while (fgets(buf, 15, stdin) && *buf != '0') {
		memset(chk, 0, sizeof(chk));
		for (N = s = 0, bp = buf; *bp > ' '; bp++, N += 2) {
			if      (*bp == 'r') k = 0;
			else if (*bp == 'g') k = 1;
			else                 k = 2;
			s = (s << 2) | k;
		}
		mask = (1 << N) - 1, r = 0, g = 0x55555 & mask, b = 0xaaaaa & mask;
		top = end = q;
		*end++ = s, *end++ = -1, chk[s] = 1, step = 0, K = N-4;
		while (top + 1 < end) {
			s = *top++;
			if (s < 0) { step++; *end++ = -1; continue; }
			if (s == r || s == g || s == b) goto done;
			for (i = 0; i <= K; i += 2) {
				int s2, k2;
				k = (s >> i) & 0xf;
				if ((k2 = nxt[k]) == k) continue;
				s2 = (s & ~(0xf << i)) | (k2 << i);
				if (!chk[s2]) chk[s2] = 1, *end++ = s2;
			}
		}
		puts("NA"); continue;
done:	printf("%d\n", step);
	}
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n,m,q; 
vll a,b,c,d;

ll ans=0;
void dfs(vll v, ll cnt){
  if(cnt>=n-1){
    // cout<<111<<endl;
    ll tmp=0;
    rep(i,q){
      if(v[b[i]]-v[a[i]]==c[i]){
        tmp+=d[i];
      }
    }
    chmax(ans,tmp);
    // cout<<ans<<endl;
    return;
  }
  cnt++;
  reps(i,m){
    if(v[cnt-1]>i) continue;
    v[cnt]=i;
    dfs(v,cnt);
  }
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m>>q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--,b[i]--;
  }
  
  vll v(n);
  reps(i,m){
    // cout<<i<<endl;
    v[0]=i;
    dfs(v, 0);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<int, lld> pil;
typedef pair<pii, int> piii;
int n, m;
char a[100009];
char b[100009];
int main()
{
	int i, j, k, l;
	int t = 1, tv = 0;
	while(t--)
	{
		scanf("%s", a);
		scanf("%s", b);
		for (n = 0; a[n]; n++);
		for (m = 0; b[m]; m++);
		for (i = 0; i < n; i++) {
			if (a[i] != b[i])break;
		}
		if (i == n && m == n + 1) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
}

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

int main(){
	string s;
	bool flag1=false;
	bool flag2=false;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			flag1=true;
		}
		if(flag1==true && s[i]=='F'){
			flag2=true;
		}
	}
	if(flag2==true){
		cout << "Yes"<<endl;
	}else{
		cout << "No"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;

class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n;
        string s;
        cin >> s;
        if(s[2] == s[3] and s[4] == s[5])cout << "Yes";
      else cout << "No";
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int A[2010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, Q;
    cin >> N >> K >> Q;
    rep(i, N) cin >> A[i];
    int ans = INF;
    rep(i, N) {
        vector<int> v1;
        vector<int> v2;
        int X = 0;
        rep(j, N) {
            if (A[i] <= A[j]) {
                v1.push_back(A[j]);
            }
            if (j == N - 1 || A[i] > A[j]) {
                sort(v1.begin(), v1.end());
                rep(k, (int)v1.size() - K + 1) {
                    v2.push_back(v1[k]);
                }
                v1.clear();
            }
        }
        if (v2.size() >= Q) {
            sort(v2.begin(), v2.end());
            rep(j, Q) {
                X = max(X, v2[j]);
            }
            ans = min(ans, X - A[i]);
        }
        // cout << v2.size() << " " << X << " " << A[i] << endl;
        // rep(j, v2.size()) {
        //     cout << v2[j] << " ";
        // }
        // cout << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
static const int LEN = 1000005;

struct P {
    char name[100];
    int t;
};

P que[LEN];

int head, tail;

void enqueue(P x) {
    que[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = que[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b; }

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

    for (int i = 1; i <= n; ++i) {
        cin >> que[i].name >> que[i].t;
    }

    head = 1;
    tail = n + 1;
    int elaps = 0;

    while (head != tail) {
        P u = dequeue();
        int c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else cout << u.name << " " << elaps << endl;
    }

    return 0;
}


Measured memory_bytes: 22212
#include <iostream>
//#include <string>
//#include <vector>
//#include <cstdlib>
//#include <algorithm>
//include <cmath>
//#include <math.h>
using namespace std;
 
 int findSumOfDigits(int n){
    int sum = 0;
    
    while(n != 0){
        sum += n % 10;    
        n /= 10;
    }    
     //cout << "sum=" << sum << endl;
     return sum;
  }
 
int main() {
    int N;
    
    cin >> N;
    
    if(N % findSumOfDigits(N) == 0){
         cout << "Yes" << endl;
    }else{
    cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616