akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/
int n, x;
vector<int> w;
vector<int> v;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    cin>>n>>x;
    w.resize(n);v.resize(n);
    int s = 0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        s += v[i];
    }
    vector<vector<ll> > dp(n+1, vector<ll> (s+1, INT_MAX));
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=s;j++){
            if((v[i-1])<=j)
                dp[i][j] = min(dp[i-1][j], w[i-1] + dp[i-1][j-v[i-1]]);
            else
                dp[i][j] = dp[i-1][j];
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    for(int i=s;i>=0;i--)
    {
        if(dp[n][i]<=x)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 82972
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i;
	long long ans = 0;
	cin >> num;
	vector<int> d(3 * num);
	for (i = 0; i < 3 * num; i++)
		scanf("%d", &d[i]);
	sort(d.begin(), d.end());
	for (i = 3 * num - 2; num > 0; num--) {
		ans += d[i];
		i -= 2;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
ll dp[105][305], ndp[105][305];
int main() {
	int n, W;
	scanf("%d%d", &n, &W);
	vector<int> w(n), v(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &w[i], &v[i]);
	}
	for (int i = 0; i < n; ++i) {
		int d = w[i] - w[0];
		for (int j = 0; j <= i; ++j)
			for (int k = 0; k <= 3 * j; ++k) {
				ndp[j][k] = max(ndp[j][k], dp[j][k]);
				ndp[j + 1][k + d] = max(ndp[j + 1][k + d], dp[j][k] + v[i]);
			}
		swap(dp, ndp);
	}
	ll ans = 0;
	for (int j = 0; j <= n; ++j)
		for (int k = 0; k <= 3 * j; ++k) {
			if ((ll)j * w[0] + k <= W) ans = max(ans, dp[j][k]);
		}
	printf("%lld\n", ans);
}


Measured memory_bytes: 768
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	cin >> H >> W;
	vector<vector<int>>field(H, vector<int>(W));
	for (auto &i : field)for (auto &j : i)cin >> j;
	vector<vector<vector<int>>>dp(W, vector<vector<int>>(W, vector<int>(H + W - 2)));
	dp[1][0][1] = field[0][0] + field[0][1] + field[1][0];
	for (int i = 1; i < H + W - 3; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < j; k++) {
				int ax = j, bx = k, ay = i - ax, by = i - bx;
				if (ax < 0 || bx < 0 || by < 0 || ay < 0)continue;
				if (ax >= W || ay >= H || bx >= W || by >= H)continue;
				if (ay + by != 1) {
					dp[ax][bx + 1][i + 1] = max(dp[ax][bx + 1][i + 1], dp[j][k][i] + field[ay + 1][ax] + field[by][bx + 1]);
				}
				if (ax + 1 < W) {
					dp[ax + 1][bx + 1][i + 1] = max(dp[ax + 1][bx + 1][i + 1], dp[j][k][i] + field[ay][ax + 1] + field[by][bx + 1]);
				}
				if (by + 1 < H) {
					dp[ax][bx][i + 1] = max(dp[ax][bx][i + 1], dp[j][k][i] + field[ay + 1][ax] + field[by + 1][bx]);
				}
				if (ax + 1 < W&&by + 1 < H) {
					dp[ax + 1][bx][i + 1] = max(dp[ax + 1][bx][i + 1], dp[j][k][i] + field[ay][ax + 1] + field[by + 1][bx]);
				}
			}
		}
	}
	cout << dp[W - 1][W - 2].back() + field.back().back() << endl;
}

Measured memory_bytes: 67120
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,ta;
	cin>>n>>ta;
	int c[110],t[110];
	fori(n){cin>>c[i]>>t[i];}
	
	int ans=INF;
	bool f=true;
	fori(n){
		if(t[i]>ta){
			continue;
		}
		f=false;
		ans=min(c[i],ans);
	}
	if(f){
		cout<<"TLE";return 0;
	}
	cout<<ans;
}

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

int main() {
	char a[3], b[3];
	cin >> a[0] >> a[1] >> a[2];
	cin >> b[0] >> b[1] >> b[2];
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0])cout << "YES";
	else cout << "NO";
}

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

int p, a[3000], ans[3000];

int main() {
  scanf("%d", &p);
  for (int i = 0; i < p; i++) scanf("%d", &a[i]);
  ans[0] = a[0];
  for (int i = 0; i < p-1; i++) {
    for (int j = 0; j < p; j++) ans[p-1-i] += a[j], a[j] = (a[j] * j) % p;
    ans[p-1-i] = ans[p-1-i] % p * (p-1) % p;
  }
  for (int i = 0; i < p; i++) printf("%d%c", ans[i], (i == p-1) ? '\n' : ' ');
}


Measured memory_bytes: 256
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
a.sort()
half=float(a[-1])/2
len=float("inf")
ans=a[0]
for i in range(n-1):
    if len>abs(half-a[i]):
        ans=a[i]
        len=abs(half-a[i])
print(a[-1])
print(ans)

Measured memory_bytes: 62832
#include <vector>
#include <string>
#include <iostream>
using namespace std;

#define ROT(a,b,c,d) tmp = o[(a)]; o[(a)]=o[(b)]; o[(b)]=o[(c)]; o[(c)]=o[(d)]; o[(d)]=tmp 


class Dice
{
public:
	vector<int> label;

	Dice(int l[6]) : label(7)
	{ for(int i=1; i<7; ++i) label[i] = l[i-1]; }
	Dice(const Dice &d) = default;
	Dice &operator=(const Dice &d) = default;

	Dice &rotate(int face) {
		auto &o = label;
		int tmp;

		switch(face) {
		case 1: ROT(2,3,5,4); break;
		case 2: ROT(1,4,6,3); break;
		case 3: ROT(1,2,6,5); break;
		case 4: ROT(1,5,6,2); break;
		case 5: ROT(1,3,6,4); break;
		case 6: ROT(2,4,5,3); break;
		}

		return *this;
	}

	friend bool test_cur(const Dice &a, const Dice &b) {
		bool equal = true;
		for(int i=1; i<7; ++i) equal &= a.label[i] == b.label[i];
		return equal;
	}

	friend bool operator==(Dice dice1, Dice dice2) {
		for(int a=0; a<6; ++a) {
			for(int i=0; i<4; ++i) {
				dice1.rotate(1);
				if(test_cur(dice1, dice2))
					return true;
			}
			if(a<4) dice1.rotate(4);

			if(a==3) dice1.rotate(2);
			else if(a==4) dice1.rotate(2).rotate(2);
		}

		return false;
	}

};


int main()
{
	int n; cin >> n;
	vector<Dice> v;

	int label[6];
	while(n--) {
		for(auto &l : label) cin >> l;
		v.emplace_back(label);
	}

	bool diff = false;
	for(auto d1=v.cbegin(); d1 != v.cend(); ++d1) {
		for(auto d2 = d1+1; d2 != v.cend(); ++d2) {
			diff |= (*d1 == *d2);
			if(diff) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	
	return 0;
}



Measured memory_bytes: 3172
#include <iostream>
typedef unsigned long long ULL;
ULL factorial(ULL n)
{
    if (n == 0) {
        return 1;
    } 
    else {
        return n * factorial(n-1);
    }
}
int main()
{
    ULL n;
    std::cin  >> n;
    std::cout << factorial(n) << std::endl;
}

Measured memory_bytes: 1148
using System;
using System.IO;
using System.Text;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var arr = new int[N];
        for (int i = 0; i < N; i++) arr[A[i] - 1] = i + 1;
        var sb = new StringBuilder();
            for (int i = 0; i < N; i++){
                sb.Append(arr[i]).Append(' ');}
        var answer = sb.ToString();
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 36444
N = int(input())
s = input()
def solve(ans):
    for i in range(2,N):
        if ans[i-2]=='S' and ans[i-1]=='S':
            if s[i-1]=='o':
                ans += 'S'
            else:
                ans += 'W'
        elif ans[i-2]=='S' and ans[i-1]=='W':
            if s[i-1]=='o':
                ans += 'W'
            else:
                ans += 'S'
        elif ans[i-2]=='W' and ans[i-1]=='S':
            if s[i-1]=='o':
                ans += 'W'
            else:
                ans += 'S'
        else:
            if s[i-1]=='o':
                ans += 'S'
            else:
                ans += 'W'
    if (ans[0]=='S' and s[0]=='o') or (ans[0]=='W' and s[0]=='x'):
        if ans[-1]!=ans[1]:
            return
    elif (ans[0]=='S' and s[0]=='x') or (ans[0]=='W' and s[0]=='o'):
        if ans[-1]==ans[1]:
            return
    if (ans[-1]=='S' and s[-1]=='o') or (ans[-1]=='W' and s[-1]=='x'):
        if ans[-2]!=ans[0]:
            return
    elif (ans[-1]=='S' and s[-1]=='x') or (ans[-1]=='W' and s[-1]=='o'):
        if ans[-2]==ans[0]:
            return
    return ans

C = ['SS','SW','WS','WW']

for c in C:
    if solve(c):
        print(solve(c))
        break
else:
    print(-1)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int a=N%10;
  if(a==3)
    cout<<"bon"<<endl;
  else if(a==1 || a==6 || a==0 || a==8)
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
   return 0;
}

Measured memory_bytes: 3600
import java.util.*;
public class Main {
    public static void main(String[] args) {
      
        Scanner input=new Scanner(System.in);
        
        int n=input.nextInt();
        int arr[]=new int[n];
        int f[]=new int[n+1];
        for(int i=0;i<n;i++)
        {
            arr[i]=input.nextInt();
            f[arr[i]]++;
        }
        long sum=0;
        for(int i=1;i<=n;i++)
        {
            long p=f[i];
            if(f[i]>1)
            sum=sum+((p)*(p+1)/2)-p;
        }
        for(int k=0;k<n;k++)
        {
            if(f[arr[k]]<=1)
                System.out.println(sum);
            else
            {
                int p=f[arr[k]];
//                System.out.println("Index:"+k+" "+sum);
                long v=sum-(((p)*(p+1)/2)-p);
//                System.out.println(v);
               v= v+((p-1)*p/2)-p;
//               System.out.println(v);
                if(v>=0)
                    System.out.println(v+1);
                else
                    System.out.println("0");
                
                
            
            }
            
        
        }
        
    }
}

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

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

const int N = 500001;
int n, q, t;
string s;

struct ST {
  int v[N << 2];
  void update(int cur, int value, int l, int r, int ql, int qr) {
    if (l == r) {
      v[cur] = value;
      return;
    }
    int m = (r - l) / 2 + l;
    if (ql <= m)
      update(cur * 2, value, l, m, ql, qr);
    if (qr >= m + 1)
      update(cur * 2 + 1, value, m + 1, r, ql, qr);
    v[cur] = v[cur * 2] | v[cur * 2 + 1];
  }

  int query(int cur, int l, int r, int ql, int qr) {
    int m = (r - l) / 2 + l, res = 0;
    if (ql <= l && r <= qr)
      return v[cur];
    if (ql <= m)
      res |= query(cur * 2, l, m, ql, qr);
    if (qr >= m + 1)
      res |= query(cur * 2 + 1, m + 1, r, ql, qr);
    return res;
  }
};

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

    ST st;
    cin >> n >> s >> q;
    for (int i = 1; i <= n; ++i) {
      st.update(1, 1 << (s[i - 1] - 'a'), 1, n, i, i);
    }
    int j, l, r; char c;
    for (int i = 0; i < q; ++i) {
      cin >> t;
      if (t == 1) {
        cin >> j >> c;
        st.update(1, 1 << (c - 'a'), 1, n, j, j);
      } else if (t == 2) {
        cin >> l >> r;
        int ans = st.query(1, 1, n, l, r);
        cout << __builtin_popcount(ans) << endl;
      }
    }
    
    return 0;
}


Measured memory_bytes: 6940
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use num_integer::*;
use proconio::marker::*;
use proconio::*;
use std::cmp::Ordering;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    // annotate for rust-analyzer
    let n: usize = n;
    let mut a: Vec<usize> = a;

    a.sort();
    let mx = *a.last().unwrap();
    let mut dp = vec![true; mx + 1];

    let mut prev = 0;
    for &i in &a {
        if !dp[i] {
            prev = i;
            continue;
        }
        for j in (i..mx + 1).step_by(i) {
            //println!("{} {}", prev, i);
            if i != j || prev == i {
                dp[j] = false;
            }
        }
        prev = i;
    }
    let ans = a.iter().filter(|&&x| dp[x]).count();

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


Measured memory_bytes: 6024
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a,b,c;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a>>b>>c;
	cout<<(a-b)%c;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

ll gcd(ll a, ll b, vector<vector<ll>> &cache) {
    if (cache[a][b] >= 0) {
        return cache[a][b];
    }
    if (b == 0) {
        cache[a][b] = a;
        return cache[a][b];
    }
    cache[a][b] = gcd(b, a % b, cache);
    return cache[a][b];
}

int main() {
    ll K;
    cin >> K;
    vector<vector<ll>> cache(K + 1, vector<ll>(K + 1, -1));
    ll total = 0;
    for (ll a = 1; a <= K; a++) {
        for (ll b = 1; b <= K; b++) {
            for (ll c = 1; c <= K; c++) {
                total += gcd(gcd(a, b, cache), c, cache);
            }
        }
    }
    print(total);
}


Measured memory_bytes: 3928
A, B, K = map(int, input().split(" "))

who = 0
for i in range(K):
    if who%2 == 0:
        if A%2 != 0:
            A -= 1
        A //= 2
        B += A
    else:
        if B%2 != 0:
            B -= 1
        B //= 2
        A += B
    who += 1

print(A, B)


Measured memory_bytes: 2940
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll d, t, s;
  cin >> d >> t >> s;
  cout << (t * s >= d ? "Yes" : "No") << '\n';
  return 0;
}


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

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

    if (abs(A-B) % 2 == 0) {
        cout << min(A,B)+abs(A-B)/2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

for i in range(2**n):
    pika = 0
    for j in range(m):
        count = 0
        for k in range(1, ks[j][0]+1):
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            pika += 1
    if pika == m:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import itertools

n = int(input())
p_list = tuple(map(int, input().split()))
q_list = tuple(map(int, input().split()))

seq = [i for i in range(1,n+1)]
seq_list = list(itertools.permutations(seq))
sorted_seq = sorted(seq_list)

for i in range(len(sorted_seq)):
  if p_list == sorted_seq[i]:
    a = i
  if q_list == sorted_seq[i]:
    b = i
print(abs(a - b))

Measured memory_bytes: 8308
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n, h, w;
	cin >> n >> h >> w;
  	cout << (n-h+1)*(n-w+1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
  int N,M,i,j,x,k;
  scanf("%d %d",&N,&M);
  int A[M],B[M][N],score[N];
  for(i=0;i<M;i++)
  {
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++) score[i]=0;
  for(i=0;i<M;i++)
    for(j=0;j<N;j++)
      scanf("%d",&B[i][j]);
  for(i=0;i<M;i++)
  {
    for(j=0;j<N;j++)
    {
      if(A[i]==B[i][j])
      {
        score[j]=score[j]+1;
      }
      else
      {
        x++;
      }
    }
    score[A[i]-1]+=x;
    //for(k=0;k<N;k++) printf(" %d:%d ",k,score[k]);
    x=0;
  }
  for(i=0;i<N;i++)
  {
    printf("%d\n",score[i]);
  }
  return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int
main ()
{
  int a;
  cin >> a;
  int s[13]={0};
  int h[13]={0};
  int c[13]={0};
  int d[13]={0};
  for (int i = 0; i < a; i++){
      string mark;
      int k;
      cin >> mark >>k;
      
      if (mark == "S"){
	  
	  s[k - 1] = k;
	}else if (mark == "H"){
	 
	  h[k - 1] = k;
	}
      else if (mark == "C"){
	  
	  c[k - 1] = k;
	}
      else{
	 
	  d[k - 1] = k;
	}
    }

  for (int i = 0; i < 13; i++){
      if (s[i] != i+1){
	  cout << "S " << i+1 << endl;
	  }
    }
    
    for(int i=0; i<13; i++){
       
        if (h[i]!=i+1){
            cout << "H "<< i+1<<endl;  
        }
    }
    for(int i=0; i<13; i++){
      
        if (c[i]!=i+1){
            cout << "C "<< i+1<<endl;  
        }
    }
    for(int i=0; i<13; i++){
       
        if (d[i]!=i+1){
            cout << "D "<< i+1<<endl;  
        }
    }
  return 0;
}


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

int main(){
  ll n;
  cin >> n;
  ll a[n];
  vector<ll> v(MAX);
  ll sum = 0;
  rep(i,n) {
    cin >> a[i];
    v[a[i]]++;
    sum += a[i];
  }
  vector<ll> ans;
  int q;
  cin >> q;
  rep(i,q) {
    ll b, c;
    cin >> b >> c;
    sum += (c-b)*v[b];
    v[c] += v[b];
    v[b] = 0;
    ans.push_back(sum);
  }
  for(auto x : ans) cout << x << endl;
  return 0;
}


Measured memory_bytes: 5812
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;
int main() {
	int ans = 0, c = 0;
	string S;
	cin >> S;
	for (int i = S.size()-2; i >= 0; i--)
	{
		if (i%2==0)
		{
			c = 0;
			for (int j = 0; j < i / 2; j++)
			{
				if (S[j] == S[i / 2+j]) {
					c++;
				}
				else break;
			}
			if (c == i / 2) {
				ans = i;
				break;
			}
		}
	}
	cout << ans;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

// primary judge O(sqrt(n))
bool is_prime(long long n) {
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1; // exclude 1
}

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// factorial
long long fact(int n) {
    if (n == 1) return fac[n] = 1;
    if (fac[n]) return fac[n];
    return fac[n] = (fact(n - 1) * n) % MOD;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    COMinit();
    int n;
    cin >> n;
    vi a(n + 1);
    rep(i, n + 1) cin >> a[i];

    vi cp_a = a;
    sort(all(cp_a));
    int repeated_num;
    rep(i, n) if (cp_a[i] == cp_a[i + 1]) repeated_num = cp_a[i];

    vi repeated_num_idx; // zero-indexed
    rep(i, n + 1) if (a[i] == repeated_num) repeated_num_idx.push_back(i);

    rep(i, n + 1) {
        int lb = repeated_num_idx[0];
        int ub = repeated_num_idx[1];
        if (i == 0) {
            out(n);
            continue;
        }
        out((COM(n + 1, i + 1) - COM(lb + n - ub, i) + MOD) % MOD);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, a, b;
	cin >> x >> a >> b;
	int A, B;
	A = abs(x - a);
	B = abs(x - b);
	if(A < B) cout << "A" << endl;
	if(A > B) cout << "B" << endl;
	return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    string s;
    cin>>s;
    if(s[s.size()-1]=='3'){
        cout<<"bon";
    }
    else if(s[s.size()-1]=='0'||s[s.size()-1]=='1'||s[s.size()-1]=='6'||s[s.size()-1]=='8'){
        cout<<"pon";
    }
    else{
        cout<<"hon";
    }
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7820
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5 + 10; 

struct point {
    int x, y, id; 
} p[N]; 
int n, par[N];

int find(int u) { return u == par[u] ? u : par[u] = find(par[u]); }

int main(int argc, char const *argv[]) {
    scanf("%d", &n); 
    for(int i = 1; i <= n; ++i) {
        scanf("%d %d", &p[i].x, &p[i].y); 
        p[i].id = i;
    }  

    vector<pair<int, ii> > edges; 
    sort(p + 1, p + n + 1, [](point a, point b) { return a.x < b.x; });
    for(int i = 2; i <= n; ++i) 
        edges.push_back({p[i].x - p[i - 1].x, {p[i].id, p[i - 1].id}}); 
    sort(p + 1, p + n + 1, [](point a, point b) { return a.y < b.y; });
    for(int i = 2; i <= n; ++i) 
        edges.push_back({p[i].y - p[i - 1].y, {p[i].id, p[i - 1].id}}); 

    sort(edges.begin(), edges.end());
    for(int i = 1; i <= n; ++i) par[i] = i; 

    ll ans = 0; 
    for(auto e : edges) {
        int u = e.second.first, v = e.second.second; 
        u = find(u); v = find(v); 
        if(u != v) {
            par[u] = v; 
            ans += e.first; 
        }
    }
    printf("%lld\n", ans); 
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

struct Unionfind {
  vector<int> d;

  Unionfind(int n) : d(n,-1) {}

  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }

  bool unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx==ry) return false;
    if(d[rx] < d[ry]) swap(rx,ry);
    d[rx] += d[ry];
    d[ry] = rx;
    return true;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -d[root(x)];
  }
};

int main() {
  ll n, m;
  cin >> n >> m;
  vll a(m), b(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  Unionfind tree(n);
  vll ret;
  ll ans = n*(n-1LL)/2LL;
  per(i,m) {
    if(tree.same(a[i],b[i])) {
      ret.push_back(ans);
      continue;
    }
    ret.push_back(ans);
    ll as = (ll)tree.size(a[i]);
    ll bs = (ll)tree.size(b[i]);
    ans -= as*bs;
    tree.unite(a[i],b[i]);
  }
  reverse(ret.begin(),ret.end());
  rep(i,ret.size()) cout << ret[i] << endl;
  return 0;
}

Measured memory_bytes: 4212
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  int64_t a;
  double b;
  cin >> a >> b;
  const auto b2 = static_cast<int64_t>((b + 0.00001) * 100.0);
  const auto ans = a * b2 / 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b;
    cin >> a >> b;
    for(int i=1;i<=3;i++){
        int ans = a * b * i;
        if(ans % 2 == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
using System;

namespace A___ABD
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            if(n<1000)
            {
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("ABD");
            }
        }
    }
}

Measured memory_bytes: 11092
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b; cin >> a >> b;
    cout << (a%2 && b%2 ? "Odd" : "Even") << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<long long> count = {1, 0, 0, 0}; // no 0 or 9, 0, 9, 0 & 9
    long long mod = 1E9 + 7;
    for (int i = 0; i < N; ++i) {
        vector<long long> new_count(4);
        new_count[0] = (count[0] * 8) % mod;
        new_count[1] = (count[0] + count[1] * 9) % mod;
        new_count[2] = (count[0] + count[2] * 9) % mod;
        new_count[3] = (count[1] + count[2] + count[3] * 10) % mod;
        count.swap(new_count);
    }
    cout << count[3] << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N, D;

    cin >> N >> D;

    double a[N][D];
    double dist;
    int dist_i;
    int count = 0;

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

    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            dist = 0;
            for (int k = 0; k < D; k++)
            {
                dist += (a[j][k] - a[i][k]) * (a[j][k] - a[i][k]);
            }
            dist = sqrt(dist);
            if (ceil(dist) == floor(dist))
            {
                count++;
            }
        }
    }
    cout << count << endl;
}

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

int main() {
	int n, a[100], f, l, r, ans, piv;
	while(1) {
		cin >> n;
		if(!n) break;
		for(int i=0; i<n; ++i) cin >> a[i];
		cin >> f;
		l = 0; r = n-1; ans = 0;
		while(l<=r) {
			piv = (l+r)/2;
			ans++;
			if(a[piv]==f) {
				break;
			}
			if(a[piv]<f) {
				l = piv+1;
			}else {
				r = piv-1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <math.h>
using namespace std;

/* define const */

/* end up defineing const */
int ipow(int x, int n)
{
  int ans = 1;
  for (int i = 0; i < n; i++) ans *= x;
  return ans;
}

int main()
{
  int N, K;
  cin >> N >> K;

  int ans = K;
  for (int i = 1; i < N; i++) {
    ans *= K-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::cmp::*;
// use std::num;

fn main() {
    input! {
        n:i32,x:Usize1,y:Usize1

    }
    let x = x as i32;
    let y = y as i32;
    let mut e = vec![0; n as usize];
    //println!("{},{}", x, y);
    for i in 0i32..n - 1 {
        for j in i + 1..n {
            // println!("{},{}", i, j);
            let d = min(
                min((j - i).abs(), (x - i).abs() + 1 + (j - y).abs()),
                (y - i).abs() + 1 + (j - x).abs(),
            ) as usize;
            e[d] += 1;
        }
    }
    for i in e.iter().skip(1) {
        println!("{}", i);
    }
}


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

int main(){
  int n;
  cin >> n;
  n-=1;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  map<int,int> mp;
  rep(i,n)mp[a[i]]+=1;
  n+=1;
  for(int i=1;i<n+1;i++){
    cout << mp[i] << endl;;
  }
}


Measured memory_bytes: 13552
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
    i64 n;
    std::cin >> n;
    --n;
    i64 c = 26;
    int j = 1;
    while (n >= c) {
        n -= c;
        c *= 26;
        j++;
    }

    std::vector<int> a;
    while (j--) {
        a.push_back(n % 26);
        n /= 26;
    }

    std::reverse(a.begin(), a.end());
    for (const int e : a) std::cout << (char)('a' + e);
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3608
program main
    implicit none
    integer(4):: k,n,i,cnt, mini
    integer(4),allocatable:: a(:)

    read*, n,k
    allocate(a(n))
    read*, a(:)
    mini = minval(a(1:k))
    i=k+1
    cnt=1
    do while(i <= n)
        if (minval(a(i:min(i+k,n))) == mini) then
            i=i+k
        else
            i=i+k-1
        end if
        cnt=cnt+1
    end do

    print*, cnt
end program main

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
using namespace std;

template<class T> T gcd(T a,T b){ return b ? gcd(b,a % b) : a; }
template<class T> T lcm(T a,T b){ return a / gcd(a,b) * b; }

signed main(){
	int n,m,a[25];
	double p[25],ans = 0;
	cin >> n >> m;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		cin >> p[i]; p[i] /= 100;
	}
	for(int i = 1;i < (1 << n);i++){
		int l = 1;
		double q = -1;
		for(int j = 0;j < n;j++){
			if(i >> j & 1){
				if(l / gcd(l,a[j]) > m / a[j]){
					q = 0;
					break;
				}
				l = lcm(l,a[j]);
				q *= -p[j];
			}
		}
		ans += (int)(m / l) * q;
	}
	printf("%.15lf\n",ans);
}


Measured memory_bytes: 3292
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N, K) = readInts() |> pair
let p = readInts()

let sum =
  let s = Array.create N 0
  for i in 0..(N-1) do
    s.[i] <- p.[i]
  for i in 1..(N-1) do
    Array.modify s i ((+) s.[i-1])
  
  let f x1 x2 = s.[x2] - (if x1=0 then 0 else s.[x1-1])
  f

seq {
  for i in 0..(p.Length-K) do
    yield sum i (i+K-1)
}
|> Seq.max
|> (fun p -> (float (K+p))/2.)
|> printfn "%f"


Measured memory_bytes: 34388
var
  n,m,i,j,zrt:longint;
  p,y,a,b,c,o:array[0..1000000]of longint;
Procedure ch(var x,y:longint);
var
  t:longint;
begin
  t:=x;x:=y;y:=t;
end;
Procedure qs(l,r:longint);
var
  i,j,mid1,mid2:longint;
begin
  i:=l;j:=r;mid1:=p[(l+r)div 2];mid2:=y[(l+r)div 2];
  repeat
    while (p[i]<mid1)or((p[i]=mid1)and(y[i]<mid2)) do inc(i);
    while (p[j]>mid1)or((p[j]=mid1)and(y[j]>mid2)) do dec(j);
    if i<=j then
      begin
        ch(p[i],p[j]);
        ch(y[i],y[j]);
        ch(c[i],c[j]);
        inc(i);dec(j);
      end;
  until i>j;
  if l<j then qs(l,j);
  if i<r then qs(i,r);
end;


begin
  readln(n,m);
  for i:=1 to m do
    begin
      readln(p[i],y[i]);
      a[i]:=p[i];c[i]:=i;
    end;
  qs(1,m);
  for i:=1 to m do
    begin
      if (i=1)or(p[i]<>p[i-1]) then j:=1 else inc(j);
      o[c[i]]:=j;
    end;
  for i:=1 to m do
    begin
      zrt:=100000;
      for j:=1 to 6 do
        begin
          if a[i]<zrt then
            begin
              zrt:=zrt div 10;
              write(0);
            end else
          break;
       end;
      write(a[i]);
      zrt:=100000;
      for j:=1 to 6 do
        begin
          if o[i]<zrt then
            begin
              zrt:=zrt div 10;
              write(0);
            end else
          break;
        end;
      writeln(o[i]);
  end;
      end.

Measured memory_bytes: 14080
#include <stdio.h>

int main(void){
    
    int a[100000],i;
    scanf("%d",&a[0]);
    
    for(i=0; i<100000; i++){
        
        if(a[i]%2==0)
            a[i+1]=a[i]/2;
        else
            a[i+1]=3*a[i]+1;
        
        for(int j=0; j<i; j++){
            if(a[j]==a[i]){
                printf("%d",i+1);
                
                return 0;
            }
        }
    }
    return 0;
}


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

int main()
{
	int cg,cp,i,score;
	cg = 0;
	cp = 0;
	score = 0;
	string s; 
	cin>>s;
	for (i = 0;s[i]!='\0';i++){
		if (s[i]=='g')
			cg++;
		else
			cp++;
	}
	cg--;
	cp++;
	while(cg>=cp){
		score++;
		cg--;
		cp++;
	}
	cout<<score<<endl;
	return 0;
}

Measured memory_bytes: 512
import sys
from math import sqrt


def rec(state, v):
    if state == (1 << N) - 1:
        return cakes[v]
    if dp[state][v] != -1:
        return dp[state][v]

    ret = INF
    for i in range(N):
        if state == 0:
            ret = min(ret, rec(1 << i, i) + cakes[i])
        elif not (state >> i & 1):
            ret = min(ret, rec(state | 1 << i, i) + sqrt(pow(cakes[i] + cakes[v], 2) - pow(cakes[i] - cakes[v], 2)))
    dp[state][v] = ret
    return ret


testcases = [[int(x) for x in line.split()] for line in sys.stdin.readlines()]

for testcase in testcases:
    box, *cakes = testcase
    N = len(cakes)
    INF = box + 1
    dp = [[-1] * N for _ in range(1 << N)]
    print('OK' if rec(0, 0) <= box else 'NA')

Measured memory_bytes: 9860
#include<bits/stdc++.h>
#define __STDC_LIMIT_MACROS
#include <stdint.h>
using namespace std;
#define int             long long
#define endl '\n'	 
bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;
	
	}
	return true;
}
 
void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
}
bool how(pair<int,int> a, pair<int, int>b)
{
	return a.second<b.second;
}
string multiply(string x, string y)
{
	int l1 = x.length();
	int l2 = y.length();
	if(l1==0 || l2 ==0)
		return "0";
	vector<int> ans(l1+l2,0);
	int n1=0;
	int n2=0;
	for(int i=l1-1; i>=0; i--)
	{
		int c = 0;
		int a = x[i]-'0';
		n2=0;
		for(int j=l2-1; j>=0; j--)
		{
			int b = y[j]-'0';
			int sum = a*b + ans[n1+n2] + c;
			c = sum/10;
			ans[n1+n2] = sum%10;
			n2++;
		}
		if(c>0)
			ans[n1+n2]+=c;
		n1++;
	}
	int i = ans.size()-1;
	while(i>=0 && ans[i]==0)
		i--;
	if(i==-1)
		return "0";
	string s = "";
	while(i>=0)
	{
		//s += to_string(ans[i--]);
	}
	return s;
}
int power(int x,int y)
{
	int a = 0;
	while(x%y==0)
	{
		a++;
		x=x/y;
	}
	return a;
}
vector<vector<int> > graph;
vector<bool> visited;

bool dfs(int cur_node, int par_node, int &nodes_cnt)
{
	if(visited[cur_node])
		return true;

	visited[cur_node] = true;
	//for(auto child_node : graph[cur_node])
	{
		//if(child_node!=par_node)
		{
			nodes_cnt++;
			//if(dfs(child_node,cur_node,nodes_cnt))
				return true;
		}
	}
	return false;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//c_p_c();
	int a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a)<<endl;
}

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

void fnInput(string& sTarget)
{
  cin >> sTarget;
}

int fnParse(string sTarget)
{
  const vector<string> cnvsWord{"dream", "dreamer", "erase", "eraser"};
  int ixBgn, ixEnd;
  ixBgn = sTarget.size();

  while (ixBgn)
  {
    bool bRslt = false;
    ixEnd = ixBgn - 1;
    for (int i = 0; i < cnvsWord.size(); i++)
    {
      string sWord = "";
      ixBgn = ixEnd - (cnvsWord[i].size() - 1);

      for (int j = ixBgn; j <= ixEnd; j++)
        sWord += sTarget[j];

      if (sWord == cnvsWord[i])
      {
        bRslt = true;
        break;
      }
    }
    if (!bRslt)  return 0;
  }
  return 1;
}

int main()
{
  string sTarget;
  
  fnInput(sTarget);
  if (fnParse(sTarget)) cout << "YES" << endl;
  else                  cout << "NO"  << endl;

  return 0;
}
 

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

using namespace std;

int main(void) {
	long long N, M;
	cin >> N >> M;
	if(N == 1) {
		cout << M << '\n';
		return 0;
	}
	long long result = 1;
	for(long long d = 1; d <= M / N; ++d) {
		if(M % d == 0) {
			result = d;
		}
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"



  string a,b;
  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	cin >> a >> b;
	cout << b+a;
	
	
	}

	
	


	



Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#include <set>

using namespace std;



int N;
vector<int> A;




int main()
{

	bool ans = true;
	cin >> N;

	A = vector<int>(N);
	set<int> s;

	for (int i = 0; i < N; i++) {
		cin >> A[i];

		decltype(s)::iterator it = s.find(A[i]);
		if (it == s.end()) {
			s.insert(A[i]);
		}
		else {
			ans = false;
			break;
		}
	}

	

	cout << (ans?"YES":"NO") << endl;

	return 0;
}




Measured memory_bytes: 10368
#encoding:utf-8 No.0032 2014.10.6
data = []
while gets
  data.push $_.chomp.split(/,/).map{|item| item = item.to_i}
end

rectangle = 0
diamond = 0

data.length.times do |i|
  if data[i][0]**2 + data[i][1]**2 == data[i][2]**2
    rectangle += 1
  elsif data[i][0] == data[i][1]
    diamond += 1
  end
end

puts rectangle
puts diamond

Measured memory_bytes: 6100
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;
typedef vector<ll> vec;

ll a(ll i)
{
    if (i % 2 == 0)
        return i / 2;
    return 3 * i + 1;
}

int main(int argc, char const *argv[])
{
    ll s, m;
    cin >> s;
    ll i;
    ll ar[1000000];
    ar[0] = s;
    for (i = 1; i < 1000000; i++)
    {
        ar[i] = a(ar[i-1]);
    }

    for (int i = 0; i < 1000000 - 1; i++)
    {
        for (int j = i + 1; j < 1000000; j++)
        {
            if(ar[i] == ar[j]){
                cout << j + 1 << endl;
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 8064