akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  cout << fixed << setprecision(10);
  ll n;
  cin >> n;
  lf ans = 0.0;
  REP (i,n) {
    lf x;
    string s;
    cin >> x >> s;
    if (s[0] == 'J') ans += x;
    else ans += 380000.0*x;
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    map<int, int> m;
    int res = 0;
    int n, t;
    cin >> n;
    while (n--)
    {
        cin >> t;
        m[t]++;
    }
    for (auto i : m)
    {
        if (i.first == i.second)
            continue;
        else if (i.first < i.second)
            res += i.second - i.first;
        else
            res += i.second;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7+5;
ll a[100005];
int main(){
	ll n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		if(k-(q-a[i])<=0) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

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

const ll MOD = 1000000007;

int main(){
  ll n;cin >> n;
  vector<ll> a(n);
  ll total;
  rep(i,n){
    cin >> a.at(i);
    if( i == 0 ) total = a.at(i);
    else total ^= a.at(i);
  }
  vector<ll> ans(n);
  rep(i,n) ans.at(i) = total ^ a.at(i);
  rep(i,n){
    cout << ans.at(i);
    if( i != n-1 ) cout << " ";
    else cout << endl;
  }

  return 0;
}


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

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(a + b > c)
    {
        cout << "No" << endl;
    }
    else if(4 * a * b < (c - a - b) * (c - a - b))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
Scanf.sscanf (read_line ()) "%d %d %d" (fun h w k ->
    let s = Array.init h (fun _ -> read_line ()) in
    let sm = Array.init w (fun i ->
        let rec loop j acc =
            if j = h then acc else loop (j + 1) (acc * 2 + if s.(j).[i] = '1' then 1 else 0)
        in
        loop 0 0
    )
    in
    let bits = Array.init 1024 (fun i ->
        let rec loop k acc =
            if k = 0 then acc else loop (k lsr 1) (acc + (k land 1))
        in
        loop i 0
    )
    in
    let calc b div =
        let curline = Array.make h 0 in
        let rec loop b_ div_ sum x i =
            if i = h then (curline.(x) <- sum; curline) else
                let sum = sum + (b_ land 1) in
                if div_ land 1 = 1 then (
                    curline.(x) <- sum;
                    loop (b_ lsr 1) (div_ lsr 1) 0 (x + 1) (i + 1)
                ) else (
                    loop (b_ lsr 1) (div_ lsr 1) sum x (i + 1)
                )
        in
        loop b div 0 0 0
    in
    let exists a =
        let rec loop i =
            if i = h then false else if a.(i) > k then true else loop (i + 1)
        in
        loop 0
    in
    let calc i =
        let rec loop y sum count =
            if y = w then count else
                let curline = calc sm.(y) i in
                if exists curline then max_int else
                    let rec loop2 x flag =
                        if x = h then flag else
                            let () = sum.(x) <- sum.(x) + curline.(x) in
                            let flag = flag || sum.(x) > k in
                            loop2 (x + 1) flag
                    in
                    if loop2 0 false then loop (y + 1) curline (count + 1)
                                     else loop (y + 1) sum count
        in
        loop 0 (Array.make h 0) (bits.(i))
    in
    let rec loop i mi =
        if i < 0 then mi else
            loop (i - 1) (min mi (calc i))
    in
    loop ((1 lsl (h - 1)) - 1) max_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 2688
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn main() {
    let n: usize = read().parse().unwrap();
    let mut cnt: Vec<usize> = vec![50_usize; 26];
    for _ in 0..n {
        let s = read();
        for i in 0..26 {
            let tmp = s.as_bytes().iter().filter(|&&x| x == i + b'a').count();
            cnt[i as usize] = std::cmp::min(cnt[i as usize], tmp);
        }
    }
    let ans: String = (0..26)
        .map(|x| {
            (0..cnt[x as usize])
                .map(|_| (x + b'a') as char)
                .collect::<String>()
        })
        .collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    n = int(input())
    p_list = list(map(int, input().split()))
    cnt = 0
    for i in range(1, n-1):
        if min(p_list[i-1],p_list[i+1])<p_list[i] and p_list[i]<=max(p_list[i-1],p_list[i+1]):
            cnt += 1
        else:
            pass
    print(cnt)



if __name__=='__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int numInt = sc.nextInt();
		int c = sc.nextInt();
		long get[] = new long[numInt];
		for(int i = 0; i < numInt; i ++) {
			get[i] = sc.nextLong();
		}
		long code[][] = new long[num][numInt];
		for(int i = 0; i < num; i ++) {
			for(int j = 0; j < numInt; j ++) {
				code[i][j] = sc.nextLong();
			}
		}
		int count = 0;
		for(int i = 0; i < num; i ++) {
			int tmp = c;
			for(int j = 0; j < numInt; j ++) {
				tmp += code[i][j] * get[j];
			}
			if(tmp > 0) { count ++; }
		}
		System.out.println(count);
	}
}

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

#define mod 1000000007
#define pb push_back
#define bs binary_search
#define bp __builtin_popcountll

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,t;
    cin>>s>>t;
    int i,c,n;
    c=0;
    n=s.length();
    for(i=0;i<n;i++)
    {
        if(s[i]==t[i])
        c++;
    }
    
    if(c==n)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 3676
#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>;
const int INF = 1000000000;
const int MOD = 1000000007;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  long double r;
  cin >> r;
  long double ans = 2 * r * M_PI;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

#define N_MAX 3000

typedef struct
{
    int x;
    int y;
}Point;

int N;
int K;

Point P[N_MAX];
Point T[N_MAX];

int compX(const void *a, const void *b)
{
    if(((Point *)a)->x == ((Point *)b)->x)
    {
        return ((Point *)a)->y - ((Point *)b)->y;
    }
    return ((Point *)a)->x - ((Point *)b)->x;
}

int compA(const void *a, const void *b)
{
    return ((Point *)b)->x * ((Point *)a)->y - ((Point *)a)->x * ((Point *)b)->y;
}

bool eq(const Point a, const Point b)
{
  return b.x * a.y == a.x * b.y;
}

int check(int p, int M)
{
    int maxl = 1;
    int l = 1;
    Point pre;
    int i;
    
    qsort(T, M, sizeof(Point), compA);
    pre = T[0];
    
    for(i = 1; i < M; i++)
    {
        if(eq(pre, T[i]))
        {
            l++;
            if(maxl > l)
            {
                maxl = maxl;
            }
            else
            {
                maxl = l;
            }
        }
        else
        {
            l = 1;
        }
        pre = T[i];
    }
    return maxl;
}


int solve()
{
    int k = 0;
    int v = 0;
    int i;
    int j;
    
    for (i = 0; i < N; i++)
    {
        k = 0;
        v = 0;
        for (j = i + 1; j < N; j++)
        {
            if ( P[i].x == P[j].x )
            {
                v++;
            }
            else
            {
                T[k] = P[j];
                T[k].x -= P[i].x;
                T[k].y -= P[i].y;
                k++;
            }
        }
        if ( 1 + v >= K ) return 1;
        if ( 1 + check(i, k) >= K ) return 1;
    }
    return 0;
}

int main()
{
    int i;

    scanf("%d%d", &N, &K);

    for(i = 0; i < N; i++)
    {
        scanf("%d%d", &P[i].x, &P[i].y);
    }
    qsort(P, N, sizeof(Point), compX);
    
    printf("%d\n", solve());
    
    return 0;
}


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

int main(){
    int A,B,res=0;
    cin >> A >> B;
    if(A > B){
        res += A;
        A --;
    }
    else{
        res += B;
        B--;
    }
    if(A > B){
        res += A;
        A--;
    }
    else{
        res += B;
        B--;
    }
    cout << res << endl;
}


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

const long long N=200000;
long long a[N],b[N];


int main(){
	
ios_base::sync_with_stdio(false);

long long n,i,j,ans=0;
string s;
char c;

cin>>n;
cin>>s;

for(i=0;i<n;i++){
	
	c=s[i];
	j=i;
	
	while((j<n)&&(s[j]==c)){
	j++;}
	
	ans++;
i=j-1;}

cout<<ans<<endl;

return 0;}

Measured memory_bytes: 512
def binarySearch(t):
    left=0
    right=n
    while left<right:
        mid=(left+right)//2
        if S[mid]==t:
            return 1
        elif t<S[mid]:
            right=mid
        else:
            left=mid+1
    return 0

n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

C=0

for t in T:
    C+=binarySearch(t)
    
print(C)

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

int main()
{

	string n;

	cin >> n;

	if (n[0] == '1') {
		cout << 9;
	}

	else if(n[0]=='9') {
		cout << 1;
	}

	if (n[1] == '1') {
		cout << 9;
	}

	else if(n[1]=='9'){
		cout << 1;
}

	if(n[2]=='1') {
		cout << 9 << endl;
	}

	else if(n[2]=='9') {
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
mod = 10 ** 9 + 7
MAX = n * m


class ModInt:
    def __init__(self, num):
        self.num = num

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= mod
        return ModInt(ret)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= mod
        return ModInt(ret)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= mod
        return ModInt(ret)

    def pow(self, times):
        pw = pow(self.num, times, mod)
        return ModInt(pw)

    def inverse(self):
        return ModInt(inv[self.num])

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num)


def comb(n, k):
    return fact[n] * inv[n-k] * inv[k]


fact = [None] * (MAX + 1)
fact[0] = ModInt(1)
for i in range(1, MAX + 1):
    fact[i] = fact[i-1] * ModInt(i)

inv = [None] * (MAX + 1)
inv[MAX] = fact[MAX].pow(mod - 2)
for i in range(MAX, 0, -1):
    inv[i-1] = inv[i] * ModInt(i)

ans = ModInt(0)
for i in range(n):
    for j in range(m):
        add = ModInt(n - i) * ModInt(m - j) * ModInt(i + j)
        if i != 0 and j != 0:
            add *= ModInt(2)

        ans += add

ans *= comb(n * m - 2, k - 2)
print(ans)


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  
  vector<ll> dp(n,2000000000);
  dp[0]=0; 
  rep(i,n){
    for(int j = 1; j <= k; j++){
      if(i-j>=0){
        dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
      }
    }
  }
  cout << dp[n-1] << endl;
}


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

bool solve();

int main()
{
	if (solve())
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

bool solve()
{
	char keyence[16]{"keyence"}, s[128];
	scanf("%s", s);
	int length;
	length = strlen(s);
	if (strcmp(keyence, s + length - 7) == 0)
		return true;
	for (int pre{}; pre < 7; pre++)
	{
		if (s[pre] != keyence[pre]) return false;
		if (strcmp(keyence + pre + 1, s + length - 6 + pre) == 0) return true;
	}
	return false;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
q=0
i=0
while i<=a and (i*500)<=x:
    j=0
    while j<=b and (i*500+j*100)<=x:
        k=0
        while k<=c:
            if (i*500+j*100+k*50)==x:
                q+=1
                break
            k+=1
        j+=1
    i+=1
print(q)

Measured memory_bytes: 3060
def get_next_str():
    return input().rstrip("\n")
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])
def solve(maze, start_r, start_c):
    
    distances = {}
    offsets = [(-1,0),(1,0),(0,-1),(0,1)]
    
    distances[start_r, start_c] = 0
    candidates = [(start_r, start_c)]
    
    while candidates:
        r, c= candidates.pop(0)
        
        for offset_r, offset_c in offsets:
            move_r, move_c = r + offset_r, c + offset_c
            if not (move_r, move_c) in distances and maze[move_r, move_c] == ".":
                distances[move_r, move_c] = distances[r, c] + 1
                candidates.append((move_r, move_c))
    
    return max(distances.values())
    

def main():
    h, w = get_next_ints()
    from collections import defaultdict
    maze = defaultdict(str)
    for r in range(h):
        line = get_next_str()
        for c in range(w):
            maze[r,c] = line[c]
    
    results = []
    for r in range(h):
        for c in range(w):
            if maze[r,c] != "#":
                result = solve(maze, r, c)
                results.append(result)
    
    print(max(results))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3436
#include <cstdio>
#include <cstdlib>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node {int key;Node *right,*left,*parent;};
Node *root,*NIL;
Node *minimum(Node *x){
  while(x->left!=NIL) x=x->left;
  return x;
}
Node *find(Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}
Node *successor(Node *x){
  if(x->right!=NIL) return minimum(x->right);
  Node *y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
void treedelete(Node *z){
  Node *y;
  Node *x;
  if(z->left==NIL||z->right==NIL) y=z;
  else y=successor(z);
  if(y->left!=NIL) x=y->left;
  else x=y->right;
  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else {
    if(y==y->parent->left) y->parent->left=x;
    else y->parent->right=x;
  }
  if(y!=z) z->key=y->key;
  free(y);
}
void insert(int k){
  Node *y=NIL,*x=root,*z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}
void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,x;
  char com[6];
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(com[0]=='f'){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    } else if(com[0]=='d'){
      scanf("%d",&x);
      treedelete(find(root,x));
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    int n, k, t;
    cin >> n >> k;

    vector<int> input(n, 0);
    vector<int> score(n, 0);

    for (int i = 0; i < n; i++) {
        cin >> t;
        input[i] = t;
    }

    for (int i = 1; i < k && i < n; i++) {
        t = INT_MAX;
        for (int j = 1; j <= i; j++) {
            t = min (t, abs(input[i] - input[i-j]) + score[i-j]);
        }
        score[i] = t;
    }

    for (int i = k; i < n; i++) {
        t = INT_MAX;
        for (int j = 1; j <= k; j++) {
            t = min (t, abs(input[i] - input[i-j]) + score[i-j]);
        }
        score[i] = t;
    }
    
    cout << score[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main()
{
	int n, W;
	cin >> n >> W;
	vector<int> v(n), w(n);
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
	}
	vector<long long> dp(W + 1, 0);
	long long ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = W; j >= 0; j--) {
			if (j - w[i] >= 0 && j - w[i] <= W)
				dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}
	for (int i = 0; i <= W; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N,K = MAP()
    A = LI()
    isVisited = set()
    loop = []
    cur = 0

    while True:
        if cur in isVisited:
            break
        isVisited.add(cur)
        loop.append(cur)
        cur = A[cur]-1
    
    before_loop = loop.index(cur)
    loop_length = len(loop)- before_loop

    if K < len(loop):
        print(loop[K]+1)
    else:
        print(loop[before_loop+(K-before_loop)%loop_length]+1)


    return

if __name__ == '__main__':
    main()


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


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

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll n;
    cin>>n;
    vector<ll>x(n),y(n),h(n);
    rep(i,0,n){
        cin>>x.at(i)>>y.at(i)>>h.at(i);
    }
    ll tcx,tcy,th;
        rep(cx,0,101){
            rep(cy,0,101){
                bool c=true;
                vector<ll> H;
                ll hre=INF;
                rep(i,0,n){
                    if(h.at(i)==0) continue;
                    else{
                        ll tmph=h.at(i)+abs(x.at(i)-cx)+abs(y.at(i)-cy);
                        H.push_back(tmph);
                    }
                }
                rep(i,0,H.size()-1){
                    if(H.at(i)!=H.at(i+1))c=false;
                }
                if(c){
                    tcx=cx,tcy=cy,th=H.at(0);
                }
                bool d=true;
                rep(i,0,n){
                    if(h.at(i)!=max((ll)0,th-abs(x.at(i)-tcx)-abs(y.at(i)-tcy)))d=false;
                }
                if(d){
                    cout<<tcx<<' '<<tcy<<' '<<th<<endl;
                    return 0;
                }
            }
        }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    ll ans = 0;
    bool flag = false;
    for(int i = 0; i < n; i++){
        if(flag){
            ans += t[i];
        }
        if(s[i] == x) flag = true;
    }
    cout << ans << endl;

    return 0;
}

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

int main (){
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    int mon=std::min(a,b);
    int count=0;
    while(count<k){
        if(a%mon==0&&b%mon==0){
            count++;
        }
        mon--;
    }
    printf("%d",mon+1);
}

Measured memory_bytes: 128
o = list(input())
e = list(input())
ans = ""

olen = len(o)
num = olen - len(e)
if num==0:
    for n in range(olen):
        ans += o[n] + e[n]
else:
    for n in range(len(e)):
        ans += o[n] + e[n]
    ans += o[olen-1]
print(ans)

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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  string dest;
  for(int i=0;i<S.length();i++){
    char c = S[i];
    c += N;
    if(c>90){
      c -= 26;
    }
    dest +=(char) c;
  }
  cout << dest;
  return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        // A xor B <= A + B
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        ll cnt = N;
        int l = 0, r = 0;
        ll sum = 0, xsum = 0;
        while(l < N or r < N) {
            assert(sum == xsum);
            int prev_r = r;
            while(sum == xsum and r < N) {
                sum += A[r];
                xsum ^= A[r];
                r++;
            }
            if(sum != xsum) {
                sum -= A[r - 1];
                xsum ^= A[r - 1];
                r--;
            }
            //debug("inc");
            //cerr << l << " " << r << endl;
            // cerr << "\t" << sum << " ! " << xsum << endl;
            if(prev_r != r) {
                ll n = r - l;
                ll pn = prev_r - l;
                cnt += n * (n - 1) / 2;
                if(pn > 1) cnt -= pn * (pn - 1) / 2;
            }
            do {
                sum -= A[l];
                xsum ^= A[l];
                l++;
            } while(sum != xsum);
            //debug("dec");
            //cerr << l << " " << r << endl;
            //cerr << "\t" << sum << " ! " << xsum << endl;
        }
        cout << cnt << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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


int main() {

	long long N;
	std::vector<long long> v(5);

	std::cin >> N;
	for (int i = 0; i < 5; i++) std::cin >> v[i];

	std::sort(v.begin(), v.end());

	if (v[0] > N) std::cout << 5 << std::endl;
	else {
		N = (N + (v[0] - 1)) / v[0];
		N += 4;
		std::cout << N << std::endl;
	}

	return 0;
}

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

int main(){
  int n,x; cin>>n>>x;
  int y=0, ans=1;
  for(int i=0; i<n; ++i){
    int l; cin>>l;
    y+=l;
    if(y<=x)++ans;
  }

  cout<<ans<<endl;
}


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

int main()
{
  string s;
  cin>>s;
  int ans=0,x=0,i;
  for(i=0;s[i]!='\0';i++)
  {
    if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C')
      x++;
    else
      x=0;
    ans=max(ans,x);
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

bool check(ll n, ll k) {
  while(n%k==0) {
    n=n/k;
  }
  return n%k==1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll n;
  cin>>n;
if(n==2) {
cout << 1 << endl;
return 0;
}
  vector<ll> cand;
  for(ll x=2; x*x<=n; x++) {
    if(n%x==0) {
      cand.push_back(x);
if(n/x!=x)
cand.push_back(n/x);
    }
  }
  
  for(ll x=2; x*x<=n-1; x++) {
    if((n-1)%x==0) {
      cand.push_back(x);
if((n-1)/x!=x)
cand.push_back((n-1)/x);
    }
  }
  ll y =0;
  for(auto x : cand) {
    //    cout << "check("<<n<<","<<x<<")="<<check(n,x)<<endl;
    if(check(n,x))y++;
  }
  cout << y+2 << endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            if (a == b) {
                out.println(c);
            } else if (b == c) {
                out.println(a);
            } else if (c == a) {
                out.println(b);
            } else {
                throw new RuntimeException();
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<pair<int, int64_t>> xh(n);
  for (int i = 0; i < n; i++) {
    int x, h;
    cin >> x >> h;
    xh.at(i) = make_pair(x, (h + a - 1) / a);
  }
  sort(xh.begin(), xh.end());
  queue<pair<int, int64_t>> q;
  int64_t s = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    while (!q.empty() && q.front().first < xh.at(i).first - d) {
      s -= q.front().second;
      q.pop();
    }
    if (!q.empty()) xh.at(i).second -= s;
    if (xh.at(i).second <= 0) continue;
    ans += xh.at(i).second;
    q.emplace(xh.at(i).first + d, xh.at(i).second);
    s += xh.at(i).second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
k = int(input())
c = 0
ans = [[]]
ans[0] = [1,2,3,4,5,6,7,8,9]
for i in range(1,10):
  s = []
  for j in range(10):
    for a in ans[i-1]:
      if j == a%10 or j-1 == a%10 or j+1 == a%10:
        s.append(int(str(a)+str(j)))
  ans.append(s)
        
ans = list(sum(ans,[]))
ans.sort()
print(ans[k-1])
      

Measured memory_bytes: 14216
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n,i = 0,j;
  cin >> n;

  vector<int> a(n);
  for(;i<n;i++){
    cin >> a[i];
  }
  for(j=n-1;j>0;j--){
    cout << a[j] << " ";
  }
  cout << a[0] << endl;
  return 0;
}



Measured memory_bytes: 3088
N = int(input())

C = []
S = []
F = []
for i in range(N-1):
    c, s, f = list(map(int, input().split()))
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t < S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        else:
             t +=  F[j] - t % F[j]
        t += C[j]
    print(t)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) std::cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second

template <typename T>
struct countmap {
    std::map<T, long long> dict;

    countmap() {
        dict = map<T, long long>();
    }

    bool contains(T key) {
        return (dict.find(key) != dict.end());
    }

    long long operator[](T key) {
        if (dict.find(key) != dict.end()) {
            return dict[key];
        } else {
            return 0;
        }
    }

    // key に対応する値があれば inc 増加させる，なければキーを新設して inc をセット
    void incrementFor(T key, long long inc = 1) {
        if (dict.find(key) != dict.end()) {
            dict[key] += inc;
        } else {
            dict.emplace(key, inc);
        }
    }

    // 登場回数の多い順に (値, 登場回数) のリストを取得
    vector<pair<T, long long>> most_common() {
        auto result = vector<pair<T, long long>>();

        for (const auto &[key, value] : dict) {
            result.push_back(make_pair(key, value));
        }

        sort(result.begin(), result.end(), [](const auto &p1, const auto &p2) {
            return p1.second > p2.second;
        });

        return result;
    }

    // for (auto &p: dict) でループできるように
    auto begin() const {
        return dict.begin();
    }

    auto end() const {
        return dict.end();
    }
};

using P = pair<Int, Int>;

int main() {
    Int H, W, M;
    cin >> H >> W >> M;
    countmap<Int> hc, wc;
    auto s = set<P>();
    rep(i, M) {
        Int h, w;
        cin >> h >> w;
        hc.incrementFor(h);
        wc.incrementFor(w);
        s.insert(MP(h, w));
    }

    auto hs = hc.most_common();
    auto ws = wc.most_common();

    auto ans = 0LL;
    auto prev_hv = -1LL;
    auto found = false;
    for (auto &hp : hs) {
        auto x = hp.F;
        auto hv = hp.S;
        if (prev_hv > hv) {
            break;
        }
        auto prev_wv = -1LL;
        for (auto &wp : ws) {
            auto y = wp.F;
            auto wv = wp.S;
            if (prev_wv > wv) {
                break;
            }
            auto a = hv + wv;
            if (s.find(MP(x, y)) != s.end()) {
                a--;
            } else {
                found = true;
            }
            ans = max(ans, a);
            prev_wv = wv;
            if (found) {
                break;
            }
        }
        prev_hv = hv;
        if (found) {
            break;
        }
    }
    PUTS(ans)
}

Measured memory_bytes: 76560
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		var list = new List<int[]>[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(Console.ReadLine());
			list[i] = new List<int[]>();
			for(var j=0;j<A[i];j++){
				string[] str = Console.ReadLine().Split();
				list[i].Add(new int[2]{int.Parse(str[0]),int.Parse(str[1])});
			}
		}
		int ans = 0;
		int M = (int)Math.Pow(2,N);
		int[]B = new int[N];
		for(var i=0;i<M;i++){
			int a = 1;
			for(var j=0;j<N;j++){
				if(i/a%2==1){
					B[j] = 1;
				} else {
					B[j] = 0;
				}
				a *= 2;
			}
			bool flag = true;
			for(var j=0;j<N;j++){
				if(B[j]==1){
					for(var k=0;k<A[j];k++){
						int a1 = list[j][k][0];
						int a2 = list[j][k][1];
						if(B[a1-1] != a2){
							flag = false;
						}
					}
				}
			}
			if(flag){
			int ct = 0;
			for(var j=0;j<N;j++){
				if(B[j]==1){
					ct++;
				}
			}
			ans = Math.Max(ans,ct);
            }
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

map<ll, ll> prime_factorization(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while(n >= a*a){
    if(n % a == 0){
      ans[a]++;
      n /= a;
    }else{
      a++;
    }
  }
  ans[n]++;

  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int> va(n);
  map<ll, ll> pr;
  rep(i, n){
    int a;
    cin >> a;
    va.at(i) = a;
    auto npr = prime_factorization(a);
    for(auto p : npr){
      if(pr[p.first] < p.second) pr[p.first] = p.second;
    }
  }
  mint l = 1;
  for(auto p : pr){
    mint adl = p.first;
    l *= adl.pow(p.second);
  }
  mint ans = 0;
  rep(i, n){
    mint add = l / va.at(i);
    // cerr << (l / va.at(i)) . x << endl;
    ans += add;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;

static const int MAX_SIZE = 1 << 20; 

LL segMax[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];

//区間[a, b)に値xを加算する.
void add(int a, int b, LL x, int k = 0, int l = 0, int r = MAX_SIZE)
{
    if (r <= a || b <= l) return;

    if (a <= l && r <= b){
        segAdd[k] += x;
        return;
    }

    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);

    segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
}

LL getMax(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE)
{
    if (r <= a || b <= l) return 0;

    if (a <= l && r <= b) return (segMax[k] + segAdd[k]);

    LL left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
    LL right = getMax(a, b, k * 2 + 2, (l + r) / 2, r);

    return (max(left, right) + segAdd[k]);
}


int main(){
    int n,m;cin >> n >> m;
    vector<pair<int,pair<int,int>>> v(n);
    for (int i = 0; i < n; i++) {
        int l,r;cin >> l >> r;
        v[i] = make_pair(r - l + 1, make_pair(l, r));
    }
    sort(ALL(v));
    int k = 0;
    for (int i = 1; i <= m; i++) {
        while(k < n && v[k].first < i){
            add(v[k].second.first, v[k].second.second + 1, 1);
            k++;
        }
        int ans = n - k;
        for (int j = 1; i * j <= m; j++) {
            ans += getMax(i * j, i * j + 1);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 16896
#include <stdio.h>

int main(){
	int i,a,num=0;
	int train[10];
	for(i=0;i<10;i++){
		train[i]=0;
	}
	while(scanf("%d",&a)!=EOF){
		if(a==0){
			printf("%d\n",train[num]);
			num--;
		}else{
			num++;
			train[num]=a;
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> K;

  if (K <= 9)
    return (ll)K;

  K -= 10;
  ll now = 10;
  while (K--) {
 //   now++;
    string s = to_string(now);
    bool switched = false;
    s.back()++;
    for (int i = s.length()-2; (i >= 0) && (i < s.length()-1); switched ? i++ : i--) {
      if (switched)
        s[i+1] = max((int)'0', s[i]-1);
      else {
        if (s[i+1] == '9'+1 || abs(s[i] - s[i+1]) > 1) {
          switched = true;
          s[i]++;
          while ( i >= 1){
            if (s[i] == '9'+1 || abs(s[i-1] - s[i]) > 1) {
              s[i-1]++;
              i--;
            }
            else break;
          }
          if (s[0] == '9' + 1) {
            s[0] = '0';
            s = '1' + s;
            i++;
          }
          s[i+1] = max((int)'0', s[i]-1);
        }
      }
    }
    now = stoll(s);
  }

  return now;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
	
int main(){
	int n, x;
	cin >> n >> x;
	int sum = 0, cnt = 0;
	if(sum <= x)cnt++;
	for(int i = 1; i <= n; i++){		
		int t; cin >> t; sum += t;
		if(sum <= x)cnt++;
	}
	cout << cnt << endl;
	return 0;
}                  
















Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  vector<string> d = {"Sunny", "Cloudy", "Rainy"}; 
  string s;
  cin >> s;
  
  int n;
  for(int i=0; i<3; i++) {
    string x = d.at(i);
    if( s == x ) {
      if(i == 2) n = 0;
      else n = i+1;
    }
  }

  cout << d.at(n) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
string S;
int main(){
  wmem = memarr;
  rd(N);
  rd(S);
  if(N%2==0 && S.substr(0,N/2)==S.substr(N/2)){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191111-2

// --- original code ---
// int N; string S;
// {
//   rd(N,S);
//   wt( if[N%2==0 && S.substr(0,N/2)==S.substr(N/2), "Yes", "No"] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
const ll MOD=1e9+7;
int ruil[200001];
int ruir[200001];
int a[200000];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	ruil[0]=0;
	for(int i=0;i<n;i++)
		ruil[i+1]=max(a[i],ruil[i]);
	ruir[n]=0;
	for(int i=n-1;i>-1;i--)
		ruir[i]=max(a[i],ruir[i+1]);
	for(int i=0;i<n;i++)
	{
		cout<<max(ruil[i],ruir[i+1])<<endl;
	}
	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

struct dijkstra{
  struct Node{
    vector<ll> edges_to;
    vector<ll> edges_cost;
    bool done;
    ll cost;
  };
  vector<Node> graph;
  void init(ll N){
    graph.resize(N);
  }
  void add(ll from, ll to, ll cost){
    graph[from].edges_to.push_back(to);
    graph[from].edges_cost.push_back(cost);
  }
  void shortest(ll start){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> d;
    d.push(make_pair(0,start));
    while(!d.empty()){
      pair<ll,ll> p = d.top();
      d.pop();
      Node &point = graph[p.second];
      if(point.done) continue;
      point.done = true;
      point.cost = p.first;
      for(ll i = 0; i < (ll)point.edges_to.size(); i++){
        if(graph[point.edges_to[i]].done)continue;
        d.push(make_pair(point.cost+point.edges_cost[i],point.edges_to[i]));
      }
    }
  }
};

int main() {
  ll N,M,R;
  cin>>N>>M>>R;
  vector<ll> v(R);
  for(ll i = 0; i<R; i++){
    ll x;
    cin>>x;
    v[i]=x-1;
  }
  dijkstra tree;
  tree.init(N);
  for(ll i = 0; i < M; i++){
    ll a,b,c;
    cin>>a>>b>>c;
    tree.add(a-1,b-1,c);
    tree.add(b-1,a-1,c);
  }
  map<pair<ll,ll>,ll> m;
  for(ll i = 0; i < R; i++){
    dijkstra T = tree;
    T.shortest(v[i]);
    for(ll j = 0; j < R; j++){
      pair<ll,ll> p = make_pair(i,j);
      m[p]=T.graph[v[j]].cost;
    }
  }
  vector<ll> P(R);
  for(ll i = 0; i < R; i++) P[i]=i;
  vector<vector<ll>> all;
  do{
    all.push_back(P);
  }while(next_permutation(P.begin(),P.end()));
  /*for(auto x:all){
    for(auto y:x)cout<<y<<" ";
    cout<<endl;
  }*/
  ll ans = INF;
  for(auto x:all){
    ll d=0LL;
    for(ll i = 0; i < (ll)x.size()-1;i++){
      d+=m[make_pair(x[i],x[i+1])];
    }
    chmin(ans,d);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5216
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=1234567;
int a[MAXN],pr[MAXN],ne[MAXN],pos[MAXN];
int main() {
  int n;
  scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
		pos[a[i]]=i;
    }
    for(int i=0;i<=n+1;i++)
	{
		pr[i]=i-1;
		ne[i]=i+1;
    }
    long long ans=0;
    for(int i=n;i>=1;i--)
	{
		int j=pos[i];
		ans+=i*1LL*(j-pr[j])*(ne[j]-j);
		pr[ne[j]]=pr[j];
		ne[pr[j]]=ne[j];
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9216