akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
struct Node
{
	int key;
	Node *next,*prev;
};

Node* nil;

void init()
{
	nil = (Node* )malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;

}

Node* listSearch(int key)
{
	Node* cur = nil->next;
	while(cur != nil && cur->key != key)
	{
		cur = cur->next;
	}
	return cur;
}

void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while(1)
	{
		if(cur == nil) break;
		if(isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node* t)
{
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void insert(int key)
{
	Node* x =(Node* )malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}



int main(int argc, char const *argv[])
{
	int key, n;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d",&n);
	init();
	for (int i = 0; i < n; ++i)
	{
		scanf("%s%d",com,&key);
		if (com[0]=='i')
		{
			insert(key);
			np++;
			size++;
		}
		else if (com[0]=='d')
		{
			if(strlen(com)>6){
				if(com[6]=='F') deleteFirst();
				else if(com[6]=='L') deleteLast();
			}
			else 
			{
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}
	printList();

	return 0;
}


Measured memory_bytes: 37140
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.nextLine();
		for(int i=0;i<a.length();i++) {
			int m =a.charAt(i)-'a';
			if(m==25)
				System.out.print('z');
			else {
				System.out.print((char)(m+1+'a'));
			}
		}
	}
	
}

Measured memory_bytes: 21844
n = int(input())
*A, = map(int, input().split())

result,right,asum=0,0,0
for left in range(n):
    while n>right and not asum&A[right]:
        asum|=A[right]
        right += 1
    asum -= A[left]
    result += right-left
print(result)

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string S;

    cin >> S;

    for(int i = 0 ; i < S.size(); i++ ){
        if( S[i] == '?' ){
            S[i] = 'D';
        }
    }

    cout << S << endl;
}


Measured memory_bytes: 3748
def codei
  return gets.split.map &:to_i
end
a,b = codei; obj = a * b; count = 0
3.times do |i|
  ans = obj * i
  if ans%2 == 1
    count += 1
  end
end
if count > 0
  puts "Yes"
else
  puts "No"
end


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

int main(void){
    ll N; cin>>N;
    ll ans=0;
    for(ll i=1;i<=N;i+=2){
        ll t=0;
        for(ll j=1;j<=i;j++){
            if(i%j==0) t++;
        }
        if(t==8) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
H,W,K = map(int,input().split(sep=" "))
S = [list(map(int,list(input()))) for i in range(0,H,1)]
minimum = H+W
for sepH in range(0,2**(H-1),1):
    bitcounter = 0
    tmp_sepH = sepH
    while tmp_sepH > 0:
        if tmp_sepH & 1 == 1:
            bitcounter+=1
        tmp_sepH = tmp_sepH//2
    A = [[0 for i in range(0,W,1)] for j in range(0,bitcounter+1,1)]
    index=[[]for i in range(0,bitcounter+1,1)]
    countInd = 0
    for i in range(0,H,1):
        index[countInd].append(i)
        if (sepH >> i) & 1:
            countInd +=1
   
    for j in range(0,bitcounter+1,1):
        for i in range(0,W,1):
            for k in range(0,len(index[j]),1):
                if S[index[j][k]][i] == 1:
                    A[j][i]+=1
    countA=[0 for i in range(0,bitcounter+1,1)]
    sepCounter = 0
    dame = False
    for i in range(0,W,1):
        for j in range(0,bitcounter+1,1):
            if A[j][i] > K:
                dame = True
        for j in range(0,bitcounter+1,1):
            countA[j]+=A[j][i]
            if countA[j] > K:
                sepCounter+=1
                for j in range(0,bitcounter+1,1):
                    countA[j] = A[j][i]
                break

    if bitcounter+sepCounter < minimum and (not dame):
        minimum = bitcounter +sepCounter

print(minimum)

Measured memory_bytes: 55004
#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;

ll n,A,B,C;
ll l[8];

ll dfs(ll cur, ll a, ll b, ll c){
    if(cur==n){
        return min({a,b,c})>0 ? abs(a-A)+abs(b-B)+abs(c-C)-30 : inf;
    }
    ll ret0 = dfs(cur+1, a,b,c);
    ll ret1 = dfs(cur+1, a+l[cur],b,c) + 10;
    ll ret2 = dfs(cur+1, a,b+l[cur],c) + 10;
    ll ret3 = dfs(cur+1, a,b,c+l[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}

int main(){FIN

    cin>>n>>A>>B>>C;
    REP(i,n) cin>>l[i];
    ll ans = dfs(0,0,0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <fstream>
#include <iostream>

#include <iostream>

class TaskA {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int N, A;
    in >> N >> A;
    out << N * N - A;
  }
};

int main() {
  TaskA solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

vec_x = lst[2] - lst[0]
vec_y = lst[3] - lst[1]

x3 = lst[2] - vec_y
y3 = lst[3] + vec_x

x4 = x3 - vec_x
y4 = y3 - vec_y

print (x3, end =' ')
print (y3, end =' ')
print (x4, end =' ')
print (y4)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const int N = 1e6 + 5;
const ll inf = -1e18;
const int MOD = 1e9 + 7;


ll a[3];
int main(){
   fast;
   ll ans, out = 1e18;
   for(int i = 0; i < 3; i++)
      cin >> a[i];
   sort(a, a + 3);
   do{
      ans = abs(a[1] - a[0]) + abs(a[2] - a[1]);
      out = min(out, ans);
   }while(next_permutation(a, a + 3));
   cout << out;



   return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;



map<string, vector<ll>> mv;

string ch[4] = {"A", "T", "G", "C"};

bool check(string s){
    bool flag = true;
    if (s.substr(1) == "AGC") flag = false;
    if (s.substr(1) == "ACG") flag = false;
    if (s.substr(1) == "GAC") flag = false;
    if (s.substr(0,3) == "AGC") flag = false;
    if (s.substr(0,3) == "ACG") flag = false;
    if (s.substr(0,3) == "GAC") flag = false;
    if (s[0] == 'A' && s.substr(2) == "GC") flag = false;
    if (s[0] == 'A' && s[1] == 'G' && s[3] == 'C') flag = false;
    return flag;
}


int main(){
    int n;
    cin >> n;
    if (n == 3){
        cout << 61 << endl;
        return 0;
    }

    rep(i, 4) rep(j, 4) rep(k, 4) rep(l, 4){
        string tmp = ch[i] + ch[j] + ch[k] + ch[l];
        if (check(tmp)) mv[tmp].push_back(1);
        else mv[tmp].push_back(0);
        rep(m, 100) mv[tmp].push_back(0);
    }

    
    for(int i = 0; i < n; i++){
        for(auto v : mv){
            string s = v.first;
            rep(j, 4){
                string t = s.substr(1) + ch[j];
                if (check(t)) mv[t][i+1] += mv[s][i];
            }
        }
        for(auto v : mv){
            string s = v.first;
            mv[s][i+1] %= MOD;
        }
    }
    ll ans = 0;
    for(auto v : mv){
        string s = v.first;
        ans += mv[s][n-4];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 087 B "Coins"
 *   https://abc087.contest.atcoder.jp/tasks/abc087_b/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int X = in.nextInt();

		int ans = 0;
		for (int a = 0; a <= A; a++) {
			for (int b = 0; b <= B; b++) {
				for (int c = 0; c <= C; c++) {

					int sum = 500 * a + 100 * b + 50 * c;
					if (sum == X) {
						ans++;
					}
				}
			}
		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 21460
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
    cin>>H>>W;
    if(H == 0&&W == 0)break;
        for(int j = 1;j <= H;j++){
            for(int a = 1;a <= W;a++){
            if(j == 1){cout<<"#";}else if(j == H){cout<<"#";}else if(a == 1){cout<<"#";}else if(a == W){cout<<"#";}else{cout<<".";}
            }
        cout<<endl;
        }
    cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;


/** 10進 -> base進変換

    http://snowytom.hatenablog.com/entry/2018/08/13/230545
    負進数にも対応
    12345, 10 -> [1, 2, 3, 4, 5]
*/
template<typename T>
std::vector<T> conv_base(T n, T base) {
    std::vector<T> ret;
    if (n == 0) {
        ret.push_back(0);
        return ret;
    }

    while (n != 0) {
        auto r = std::abs(n) % std::abs(base);
        ret.push_back(r);
        n -= r;
        n = n / base;;
    }

    std::reverse(std::begin(ret), std::end(ret));

    return ret;
}


int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int> D;
    for (decltype(K) i = 0; i < K; ++i) {
        int t;
        std::cin >> t;
        D.push_back(t);
    }

    for (;;++N) {
        auto b = conv_base(N, (int64_t)10);

        for (auto d: D) {
            auto pos = std::find(std::begin(b), std::end(b), d);
            if (pos != std::end(b)) {
                goto next;
            }
        }
        std::cout << N << std::endl;
        return 0;
    next:
        int a;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll sum=0;
  
  if(A==0){
    cout << 0 << endl;
    return 0;
  }
  
  ll div = N/(A+B);
  
  if((N-div*(A+B))>=A){
	cout << A*(div+1) << endl;
  }else{
    cout << A*div + (N-div*(A+B)) << endl;
  }
}

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

int main(){
  int res,n; cin>>n;
  string s,t; cin>>s>>t;     
  for(int i=1;i<=n;i++){
   if(s.substr(n-i,i)==t.substr(0,i)){
     res=i;
   }
  }
  cout<<2*n-res<<endl;
  return 0;
}

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

int main()
{
	string t,s;
  	cin>>s>>t;
  	vector<int> a(s.size()+1),b(s.size()+1);
	
	for(int i=0;i<t.size();i++)
    {
      for(int j=i+1;j<=s.size();j++)
      {
        if(s[j-1]==t[i])
          b[j]=a[j-1];
        else
          b[j]=a[j-1]+1;
      }
      a=b;
    }
  
  int min=s.size();
  for(int i=t.size();i<a.size();i++)
    if(min>a[i]) min=a[i];
  cout<<min;
  return 0;
}
  

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1e9
//S.size()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;

int main(void){
  int  N;cin>>N;
  VI a(N);
  for(int i = 0;i < N;i++)cin>>a[i];

  int num = 0;
  int man = 0;

  for(int j = 0;j < N;j++){
    for(int q = 0;q < N;q++){
      if(a[j] - a[q] >= 0)num = a[j] - a[q];
      else num = a[q] - a[j];

      if(num >= man)man = num;
    }
  }

  cout<<man;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int x,y,a;
	
	while(1)
	{
		scanf( "%d %d",&x, &y);
		
		if( x == 0 && y == 0)
		{
			break;
		}
		
		if( x > y )
		{
			a = x;
			x = y;
			y = a;
		}
		
		printf( "%d %d\n",x, y);
	}
	
	return 0;
}


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

int main(){
    int X;
    cin >> X;
    if(X <= 599){
        cout << '8' << endl;
    }
    else if(600 <= X && X <= 799){
        cout << '7' << endl;
    }
    else if(800 <= X && X <= 999){
        cout << '6' << endl;
    }
    else if(1000 <= X && X <= 1199){
        cout << '5' << endl;
    }
    else if(1200 <= X && X <= 1399){
        cout << '4' << endl;
    }
    else if(1400 <= X && X <= 1599){
        cout << '3' << endl;
    }
    else if(1600 <= X && X <= 1799){
        cout << '2' << endl;
    }
    else if(1800 <= X && X <= 1999){
        cout << '1' << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int binary(vector<ll>& b, int left, int right, ll target){
	while(left+1 < right){
		int mid = (right+left)/2;
		if(target > b.at(mid)){
			left = mid;
		}else if(target == b.at(mid)){
			return mid;
		}else{
			right = mid;
		}
	}
	return left;
}

int main(){
	int n, m;
	ll k;
	cin >> n >> m >> k;
	vector<ll> a(n+1);
	vector<ll> b(m+1);
	a.at(0) = 0;
	rep(i,n){
		cin >> a.at(i+1);
	}
	b.at(0) = 0;
	rep(i, m){
		cin >> b.at(i+1);
		if(i >=1) b.at(i) += b.at(i-1);
	}
	int bookmax = 0;
	rep(i, n+1){
		k -= a.at(i);
		if(k < 0) break;
		int bc = binary(b, 0, m+1, k);
		int n_book = i+bc;
		if(bookmax < n_book) bookmax = n_book;
	}
	cout << bookmax << endl;
}


Measured memory_bytes: 6352
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        t: usize,
        x: usize,
    };

    println!("{:.5}", t as f64 / x as f64);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		char[] marks = {'S', 'H', 'C', 'D'};

		for(char mark : marks) {
			for (int i = 1; i <= 13; i++) {
				Card.allCards.add(new Card(mark, i));
			}
		}

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String str = br.readLine();
			String[] arr = str.split(" ");
			for (Card card : Card.allCards) {
				if (card.mark != arr[0].charAt(0)) {
					continue;
				}
				if (card.rank == Integer.parseInt(arr[1])) {
					card.have = true;
				}
			}
		}

		for (Card card : Card.allCards) {
			if (!card.have) {
				System.out.println(card.mark + " " + card.rank);
			}
		}
	}
}

class Card {
	char mark;
	int rank;
	boolean have = false;
	static List<Card> allCards = new ArrayList<Card>();

	Card(char mark, int rank) {
		this.mark = mark;
		this.rank = rank;
	}
}

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

int main(){
  ll N; cin>>N;
  ll n=N%10;
  if(n==3) cout<<"bon"<<endl;
  else if(n==0 || n==1 || n==6 || n==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}


Measured memory_bytes: 3636
import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    n = int(input())
    d_list = sorted([int(i) for i in input().split()])
    print(d_list[n // 2] - d_list[n // 2 - 1])
    # print(list(accumulate(d_list, max)))
    # K 選び方でARC と ABCが同じ数になる選び当た


if __name__ == "__main__":
    main()

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int N, t[MAXN], x[MAXN], y[MAXN];

int main(){
	scanf("%d", &N);
	up (i, 1, N) scanf("%d%d%d", &t[i], &x[i], &y[i]);
	int cx = 0, cy = 0;
	up (i, 1, N) {
		int d = t[i] - t[i - 1];
		int dis = abs(x[i] - cx) + abs(y[i] - cy);
		if (d >= dis && (d - dis) % 2 == 0) {
			cx = x[i];
			cy = y[i];
		}else {
			puts("No");
			return 0;
		}
	} 
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>

using namespace std;
long long mod = 1000000007;
long long dp[52];

int main() {
	long long n; cin >> n;
	string s1, s2; cin >> s1 >> s2;
	long long i = 0;
	if (s1[0] == s2[0]) {
		dp[0] = 3;
		i++;
	}
	else {
		dp[0] = dp[1] = 6;
		i += 2;
	}

	while (i < n) {
		if (s1[i] == s2[i]) {
			if (s1[i - 1] == s2[i - 1]) {
				dp[i] = dp[i - 1] * 2;
				dp[i] %= mod;
				i++;
			}
			else {
				dp[i] = dp[i - 1];
				dp[i] %= mod;
				i++;
			}
		}
		else {
			if (s1[i - 1] == s2[i - 1]) {
				dp[i] = dp[i - 1] * 2;
				dp[i] %= mod;
				dp[i + 1] = dp[i];
				i += 2;
			}
			else {
				dp[i] = dp[i - 1] * 3;
				dp[i] %= mod;
				dp[i + 1] = dp[i];
				i += 2;
			}
		}
	}
	cout << dp[n - 1] << endl;
	int x; cin >> x;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	ll N, K; cin >> N >> K;
	cout << N - K + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(LL i=(m);i>=(n);i--)
	//i=m -> n(降順)

VB seen;

void dfs(const VVLL &g, LL v,VVLL &group, LL group_num){
  seen[v] = true;
  
  for(LL next_v : g[v]){
    if(seen[next_v]){continue;}
    dfs(g, next_v, group, group_num);
  }
  group[group_num].push_back(v);
}

int main(){
  LL n,m,ans=0;
  cin >> n >> m;
  VLL a(m),b(m);
  VVLL g(n+10);
  REP(i,0,m){
    cin >> a[i] >> b[i];
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  seen.assign(n+10,false);
  VVLL group(n+10,VLL());
  LL group_num = 0;
  
  REP(i,1,n+1){
    if(seen[i]){continue;}
    dfs(g,i,group,group_num);
    group_num++;
  }
  
  for(VLL x : group){
    LL compare = x.size();
    ans = max(ans,compare);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 87640
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll a[55];

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

	ll K;
	cin >> K;
	for (int i = 0; i < 50; i++)a[i] = 49;
	for (int i = 0; i < 50; i++)a[i] +=(K / 50LL);

	ll temp = a[0];
	ll r = K % 50LL;
	for (int i = 0; i < 50; i++) {
		if (i < K % 50LL)a[i] = temp + 51 - r;
		else a[i] = temp - r;
	}


	puts(50);
	for (int i = 0; i < 50; i++)cout << a[i] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int n = s.length();
		boolean[] ax = new boolean[20000];
		boolean[] ay = new boolean[20000];
		int offset = 10000;
		
		ay[offset] = true;
		int rot = 0;
		int fw = 0;
		for(int i = 0; i <= n; i++)
		{
			if(i < n && s.charAt(i) == 'F')
			{
				fw++;
			}
//			if(s.charAt(i) == 'T')
			else
			{
				rot++;
				
				if(rot%2 == 0)
				{ //any vertical
					boolean[] nay = new boolean[20000];
					for(int k = 0; k < 20000; k++)
					{
						if(ay[k])
						{
							if(k+fw<20000)nay[k+fw]=true;
							if(k-fw>=0)nay[k-fw]=true;
						}
					}
					ay = nay;
				}
				else
				{ //horizontal
					if(rot == 1)
					{ //only right
						ax[fw+offset] = true;
					}
					else
					{ //any horizontal
						boolean[] nax = new boolean[20000];
						for(int k = 0; k < 20000; k++)
						{
							if(ax[k])
							{
								if(k+fw<20000)nax[k+fw]=true;
								if(k-fw>=0)nax[k-fw]=true;
							}
						}
						ax = nax;
					}
				}
				
				fw = 0;
			}
			
		}
		
		if(ax[x+offset] && ay[y+offset])
		{
			System.out.println("Yes");
		}
		else System.out.println("No");
	}

}


Measured memory_bytes: 61892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    unsigned int n;
    int answer = 0;
    scanf("%d", &n);
    while(n > 1){
        n = n>>1;
        answer++;
    }
    printf("%d\n", (int)pow(2, answer));



    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define PF push_front
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n) 
 
#define ll 	 long long 
 
#define mod  1000000007



int main()
{
	FAST;
	int n;
	cin >> n;
	set<int> s;
	for(int i = 0; i < n; i ++){
		int x;
		cin >> x;
		s.insert(x);
	}
	cout << s.size();
	return 0;
}

Measured memory_bytes: 3640
# coding: utf-8
# Your code here!

N = int(input())
S = list(input())
a1 = []
a2 = []
duplicate = []
max_num = 0

for i in range(1, N):
    a1 = S[0:i]
    a2 = S[i::]
    duplicate = [x for x in set(a1) if a2.count(x) >= 1]
    if len(duplicate) > max_num: 
        max_num = len(duplicate)
print(max_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=200005;
const int NN=2005;
const ll md=998244353;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll a[N]={0};
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    ll ans=a[1];
    multiset<ll> p;
    p.insert(-1*a[2]);
    p.insert(-1*a[2]);

    for (int i=3;i<=n;i++){
        //cout << *p.begin() << E;
        ans-=*p.begin();
        p.erase(p.find(*p.begin()));
        p.insert(-1*a[i]);
        p.insert(-1*a[i]);

    }
    cout << ans << E;
    return 0;
}


/*







*/


Measured memory_bytes: 14480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 0 ; i < n ; i++) {
			sum += sc.nextInt();
		}
		System.out.println(h <= sum ? "Yes" : "No");
	}


}



Measured memory_bytes: 58608
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x2 x123456789
#define y2 y123456789

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=1e5+5;
const int maxl=25;

int n,l,q;
int x[maxn];
int st[maxl][maxn];

int main(){
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",x+i);
	int k=0;
	scanf("%d",&l);
	FOR(i,0,n){
		while(k<n&&x[k]-x[i]<=l) k++;
		st[0][i]=k-1;
	}
	FOR(i,1,20){
		FOR(j,0,n){
			st[i][j]=st[i-1][st[i-1][j]];
		}
	}
	scanf("%d",&q);
	FOR(i,0,q){
		int a,b,ans=0;
		scanf("%d%d",&a,&b);
		--a;--b;
		if(a>b) swap(a,b);
		for(int j=19;j>=0;--j){
			if(st[j][a]<b){
				ans+=1<<j;
				a=st[j][a];
			}
		}
		while(a<b) a=st[0][a],++ans;
		printf("%d\n",ans);
	}
	return 0;
}

/*
6
1 4 9 12 16 17
5
1
2 5
*/

Measured memory_bytes: 9472
#include<stdio.h>
int main()
{
	char c;
	int ans = 0;
	for (int i = 0; i < 4; i++)
	{
		scanf("%c", &c);
		if (c == '+')
		{
			ans++;
		}
		if (c == '-')
		{
			ans--;
		}
	}
	printf("%d", ans);
	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


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

long long lcm(long long a, long long b) {
   long long tmp = max(a,b)/gcd(a,b);
   return min(a,b)*tmp;}

int main() {
    int N;
    cin >> N;
    int ac,wa,tle,re;
    ac = wa = tle = re = 0;
    rep(i,N) {
        string s;
        cin >> s;
        if (s=="AC") ac++;
        if (s=="WA") wa++;
        if (s=="TLE") tle++;
        if (s=="RE") re++;
    }
    cout << "AC" << " x " << ac << endl;
    cout << "WA" << " x " << wa << endl; 
    cout << "TLE" << " x " << tle << endl;
    cout << "RE" << " x " << re << endl;   
}

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

using namespace std;

int main(int argc, char *argv[])
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << ((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[0] != a[1]) ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
X,K,D=map(int,input().split())
P = X-D*K
Q = 2*D
if X-D*K<=0<=X+D*K:
    U=(X-D*K)%(Q)
    print(min(U,Q-U))
    
elif 0<X-D*K:
    print(X-D*K)
    
    
elif X+D*K<0:
    print(-X-D*K)
    

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

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

  int n, x, t;
  cin >> n >> x >> t;

  if(n%x!=0)cout << (n/x+1)*t << endl;
  else cout << n/x*t << endl;

  return 0;
}

Measured memory_bytes: 3644
a,b = gets.chomp.split().map(&:to_i)
s = gets.chomp.split(//)

a.times do |i|
  c = s.shift
  unless c == c.to_i.to_s
    puts 'No'
    exit
  end
end

c=s.shift
unless c == '-'
  puts 'No'
  exit
end

b.times do |i|
  c = s.shift
  unless c == c.to_i.to_s
    puts 'No'
    exit
  end
end

puts 'Yes'


Measured memory_bytes: 1788
import copy
from sys import exit
n, k = map(int, input().split())
A = list(map(int, input().split()))

mod = 10**9 + 7

plus = []
minus = []
for a in A:
    if a >= 0:
        plus.append(a)
    else:
        minus.append(a)
plus.sort()
minus.sort(reverse=True)

def is_ans_plus():
    if len(plus) > 0:
        if n == k:
            if len(minus) % 2 == 0:
                return True
            else:
                return  False
        else:
            return True
    else:
        if k % 2 == 0:
            return True
        else:
            return False

ans = 1
if is_ans_plus():
    if k % 2 == 1:
        ans *= plus.pop()
        k -= 1
    for i in range(k // 2):
        plus_pair, minus_pair = -1, -1
        if len(plus) >= 2:
            plus_pair = plus[-1] * plus[-2]
        if len(minus) >= 2:
            minus_pair = minus[-1] * minus[-2]
        if plus_pair >= minus_pair:
            ans *= plus_pair
            plus.pop()
            plus.pop()
        else:
            ans *= minus_pair
            minus.pop()
            minus.pop()
        ans %= mod
else:
    ans = -1
    A = sorted([abs(a) for a in A])
    for i in range(k):
        ans *= A[i]
        ans %= mod
print(ans)


Measured memory_bytes: 130628
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>
#include<queue>

using namespace std;

#define maxn 215
#define ll long long

char s[maxn][maxn];
bool vis[maxn][maxn];

struct node{
int x,y;
int k;
};

vector<node> sol;
node pr;
node sa;
queue<node> Q;

int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    getchar();
    for(int i=0;i<h;i++)
        scanf("%s",s+i);
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
        if(s[i][j]=='@') {
            pr.x=i;pr.y=j;pr.k=0;
        }
        if(s[i][j]=='$'){
            node so;
            so.x=i;so.y=j;
            so.k=1;
            sol.push_back(so);
        }
        if(s[i][j]=='%'){
            sa.x=i;
            sa.y=j;
            sa.k=0;
        }
    }
    memset(vis,false,sizeof(vis));
    for(int i=0;i<sol.size();i++){
        Q.push(sol[i]);
        vis[sol[i].x][sol[i].y]=true;
    }
    Q.push(pr);
    vis[pr.x][pr.y]=true;
    bool flag=false;
    while(!Q.empty()){
            node now=Q.front();
            Q.pop();
            int x=now.x;
            int y=now.y;
            if(x==sa.x&&y==sa.y){
                if(now.k==0) flag=true;
                else flag=false;
                break;
            }
            if(x+1<h&&!vis[x+1][y]&&s[x+1][y]!='#'){
                node ny=now;
                ny.x++;
                vis[x+1][y]=true;
                Q.push(ny);
            }
            if(x-1>=0&&!vis[x-1][y]&&s[x-1][y]!='#'){
                node ny=now;
                ny.x--;
                vis[x-1][y]=true;
                Q.push(ny);
            }
            if(y-1>=0&&!vis[x][y-1]&&s[x][y-1]!='#'){
                node ny=now;
                ny.y--;
                vis[x][y-1]=true;
                Q.push(ny);
            }
            if(y+1<w&&!vis[x][y+1]&&s[x][y+1]!='#'){
                node ny=now;
                ny.y++;
                vis[x][y+1]=true;
                Q.push(ny);
            }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 0; i < (int)(n); i+=2)
using vi=vector<int>;  using vs=vector<string>;
using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end())
#define sodo(c) sort((c).begin(),(c).end(),gi())

int main() {
    int n; cin>>n;
    vi v(n+1);
    rep(i,n) cin>>v.at(i);

    int a=0,b=0;
    sodo(v);
    
    rep2(i,n){
        a+=v.at(i);
        b+=v.at(i+1);
    } 

    cout<<a-b<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

const int N = 2e5 + 5;
int l = ( int )ceil( log2( N ) );
vector< long long > segtree( ( 1 << ( l + 1 ) ) + 10, 0 );
int n;
vector< int > height( N ), beauty( N );
long long res;

long long query( int v, int tl, int tr, int l, int r )
{
	if( tl == l && tr == r )
	{
		return segtree[ v ];
	}
	int tm = ( tl + tr ) >> 1;
	if( r <= tm )
	{
		return query( 2 * v, tl, tm, l, r );
	}
	else if( l > tm )
	{
		return query( 2 * v + 1, tm + 1, tr, l, r );
	}
	else
	{
		return max( query( 2 * v, tl, tm, l, tm ), query( 2 * v + 1, tm + 1, tr, tm + 1, r ) );
	}
}

void update( int v, int tl, int tr, int pos, long long val )
{
	if( tl == tr )
	{
		segtree[ v ] = val;
		return;
	}
	int tm = ( tl + tr ) >> 1;
	if( pos <= tm )
	{
		update( 2 * v, tl, tm, pos, val );
	}
	else
	{
		update( 2 * v + 1, tm + 1, tr, pos, val );
	}
	segtree[ v ] = max( segtree[ 2 * v ], segtree[ 2 * v + 1 ] );
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> height[ i ];
	}
	for( int i = 1; i <= n; ++i )
	{
		cin >> beauty[ i ];		
	}
	for( int i = 1; i <= n; ++i )
	{
		res = 0;
		if( height[ i ] != 1 )
		{
			res = query( 1, 1, n, 1, height[ i ] - 1 );
		}
		res += beauty[ i ];
		update( 1, 1, n, height[ i ], res );
	}
	cout << query( 1, 1, n, 1, n ) << "\n";
	return 0;
}

Measured memory_bytes: 5888
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  cin >> N;
  int a[] = {1, 2, 4, 8, 16, 32, 64};

  rep(i, 7){
    if(a[i] > N){
      print(a[i-1]);
      return 0;
    }
  }
  print(64);
}


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

int		main(void)
{
	int		n;
	int		r;

	if ((scanf("%d %d", &n, &r)) < 2)
		return (-1);
	if (n < 10)
		printf("%d", r - 100 * n + 1000);
	else
		printf("%d", r);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, k;
	cin >> n >> k;
	if (k == 1) cout << 0 << endl;
	else cout << n-k << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n ;
	double x, ans=0;
	char u[4];

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%lf %s", &x, u);
		if (u[0] == 'J') {
			ans += x;
		}
		else
		{
			ans += x * 380000;
		}
	}
	printf("%lf", ans);

	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e16;
long long int MOD = 1000000007;

int main(){
	
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0){
			break;
		}
		long long int CL[300][300], CS[300][300];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				CL[i][j] = INF;
				CS[i][j] = INF;
			}
			CL[i][i] = 0;
			CS[i][i] = 0;
		}
		for(int i = 0; i < m; i++){
			long long int u, v, cost;
			cin >> u >> v >> cost;
			u--;
			v--;
			string str;
			cin >> str;
			if(str == "L"){
				cost = min(cost, CL[u][v]);
				CL[u][v] = cost;
				CL[v][u] = cost;
			}else{
				cost = min(cost, CS[u][v]);
				CS[u][v] = cost;
				CS[v][u] = cost;
			}
		}
		for(int k = 0; k < n; k++)
		for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++){
			CL[i][j] = min(CL[i][j], CL[i][k] + CL[k][j]);
			CS[i][j] = min(CS[i][j], CS[i][k] + CS[k][j]);
		}
		
		int R, pre, num;
		cin >> R;
		cin >> pre;
		pre--;
		
		long long int ans = INF, DP1[300], DP2[300];
		for(int i = 0; i < n; i++){
			DP1[i] = INF;
		}
		DP1[pre] = 0;
		for(int i = 1; i < R; i++){
			cin >> num;
			num--;
			for(int j = 0; j < n; j++){
				DP2[j] = DP1[j] + CL[pre][num];
				for(int k = 0; k < n; k++){
					DP2[j] = min(DP2[j], CL[pre][k] + DP1[k] + CS[k][j] + CL[j][num]);
				}
			}
			swap(DP1, DP2);
			pre = num;
		}
		
		for(int i = 0; i < n; i++){
			ans = min(ans, DP1[i]);
		}
		cout << ans << endl;
	}
	
	return 0;
}


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

void Main() {
	int N, M;
	cin >> N;
	vector<int> vec(N);
	cin >> M;
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
	int cnt = 0;
	double sum = (double)accumulate(vec.begin(), vec.end(), 0)/ ((double)4 * M);
	bool isYes = false;
	for (int i = 0; i < vec.size(); i++) {
		if (vec[i] < sum) {
			continue;
		}
		cnt++;
		if (cnt == M) {
			isYes = true;
			break;
		}
	}
	if (isYes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int inf = 1e8;
const ll INF = 1e18;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-9;
const long double pi = acos(-1.0);
using namespace std;

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

ll const MOD = 1e9 + 7;
int n, c;
ll dp[555][555];
int a[555], b[555];
ll poww[555][555], sum_pow[555][555];
void solve() {
    cin >> n >> c;
    for (int i = 0; i <= 400; i++){
        poww[i][0] = 1;
        for (int j = 1; j <= c; j++){
            poww[i][j] =  poww[i][j - 1] * i;
            poww[i][j] %= MOD;
        }
    }
    for (int i = 0; i <= c; i++){
        for (int j = 1; j <= 400; j++){
            sum_pow[j][i] = (sum_pow[j - 1][i] + poww[j][i]) % MOD;
        }
    }
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= c; j++){
            for (int q = 0; q <= c; q++){
                if (j + q > c) break;
                ll sum = (sum_pow[b[i] ] [j] - sum_pow[a[i] - 1][j] + MOD) % MOD;
                //cout << sum << " " << sum_pow[b[i]][j] << " " << sum_pow[a[i] - 1][j] << " " << i << " " << j << endl;
                dp[i][j + q] = (dp[i][j + q] + dp[i - 1][q]  * sum) % MOD;
            }
        }
    }
    cout << dp[n][c] << endl;
}



int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(40);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();


}

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

typedef long long ll;


#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
const ll MAX = 1e6;
/* end defineing */

signed main()
{
    int n;
    string s[101];
    set<string> ss;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];

    for (int i = 0; i < n; i++)
        ss.insert(s[i]);
    bool f = true;
    for (int i = 0; i < n - 1; i++)
    {
        if ((s[i])[s[i].length() - 1] != (s[i + 1])[0])
            f = false;
    }

    if (f && n == ss.size())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256