akhauriyash/Code-Regression huggingface dataset:
import sys

alpha = 'abcdefghijklmnopqrstuvwxyz'

n = int(input())

i = 0
idx = n
if n > 26:
    while n > 0:
        idx = n
        i += 1
        n = n - 26**i
        # print(i, n)

else:
    print(alpha[n-1])
    sys.exit()

# letter len : i, idx 

def getstr(i, idx):

    if i == 0:
        return ""
    elif i == 1:
        return alpha[idx-1]
    else:
        # number in the range
        t = 26**i

        # number  of bin
        b = int(26 * idx / t)

        bb = 0
        tmp = idx
        while tmp > 0:
            tmp -= int(t/26)
            bb += 1

        b = bb - 1
        idx -= b * int(t/26) 
        i -= 1
        
        return alpha[b] + getstr(i, idx)

print(getstr(i,idx))


Measured memory_bytes: 9156
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan=new Scanner(System.in);
long A= scan.nextLong();
        long B= scan.nextLong();
        long C= scan.nextLong();
        long K= scan.nextLong();

long N;
if (K<=A){N=K;}
else if(K<=A+B){N=A;}
else {N=A-K+A+B;}
System.out.println(N);




    }

       }



Measured memory_bytes: 35776
#define _USE_MATH_DEFINES
#include<iostream>
#include<math.h>
#include<cmath>
#include <iomanip>
int main(void) {
	double a, b, c;
	std::cin >> a >> b >> c;
	std::cout << std::fixed << std::setprecision(9) << 0.5*a*b*std::sin(M_PI*c / 180.) << std::endl
		<< std::fixed << std::setprecision(9) << a + b + std::sqrt(a*a + b*b - 2.*a*b*std::cos(M_PI*c / 180.)) << std::endl
		<< std::fixed << std::setprecision(9) << b* std::sin(M_PI*c / 180.) << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include<string.h>
#define M 1046527
#define L 14

char H[M][L];

int get(char *c){
    int sum=0,p=1;
    for(int i=0;i<strlen(c);i++){
        if(c[i]=='A') sum+=1*p;
        else if(c[i]=='C') sum+=2*p;
        else if(c[i]=='G') sum+=3*p;
        else               sum+=4*p;
        p*=5;
    }
    return sum;
}

int h1(int key){ return key%M;}
int h2(int key){ return 1+(key%(M-1));}

void insert(char *c){
    long long i,h,key=get(c);
    i=0;
    while(1){
        h=(h1(key)+i*h2(key))%M;
        if(!strcmp(H[h],c)) return;
        else if(H[h][0]=='\0'){
            strcpy(H[h],c);
            return;
        }
        i++;
    }
    return;
}

int find(char *c){
    long long i,h,key=get(c);
    i=0;
    while(1){
        h=(h1(key)+i*h2(key))%M;
        if(!strcmp(H[h],c)) return 1;
        else if(H[h][0]=='\0') return 0; 
        i++;
    }
    return 0;
}


int main(void){
    int n,i;
    char op[8],arr[4];
    
    for(i=0;i<M;i++){
        H[i][0]='\0';
    }
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",op,arr);
        if(op[0]=='i'){
            insert(arr);
        }
        else {
            if(find(arr)) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 8+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
vector<int> a;
vector<pii> p;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++){
		int x, y; cin >> x >> y;
		p.push_back({x, y});
		a.push_back(i);
	}
	int cnt = 0;
	double sum = 0.0;
	do {
		cnt++;
		for(int i=1; i<n; i++){
			sum += sqrt (1.0*(p[a[i]].st - p[a[i-1]].st)*(p[a[i]].st - p[a[i-1]].st) + 1.0*(p[a[i]].nd -p[a[i-1]].nd)*(p[a[i]].nd -p[a[i-1]].nd));
		}
	}while(next_permutation(a.begin(), a.end()));
	cout << fixed << setprecision(9);
	double ans = sum / cnt;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N - 1);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    --A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }
  for (int i = 0; i < N - 1; ++i) {
    cin >> C[i];
  }

  int ans = 0;

  // init
  int prev;
  int cur = A[0];
  ans += B[cur];
  swap(prev, cur);

  // iterate
  for (int i = 1; i < N; ++i) {
    int cur = A[i];
    ans += B[cur];
    if (cur == prev + 1) ans += C[prev];
    swap(prev, cur);
  }

  cout << ans << endl;
  
  return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    rep(i,0,m)cin>>a[i];
    sort(all(a));
    ll s=0;
    rep(i,0,m)s+=a[i];
    ll as=n-s;
    if(as<0)as=-1;
    cout<<as<<nl;
    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int seven = 0;
  int five = 0;
  if(a == 5)five++;
  if(a == 7)seven++;
  if(b == 5)five++;
  if(b == 7)seven++;
  if(c == 5)five++;
  if(c == 7)seven++;
  
  if(five == 2 && seven == 1)cout << "YES" <<endl;
  else cout << "NO" << endl;
  
  return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  long long int x,i=0,m=100;
  cin>>x;
 // x=1000000000000000000;
  while(m<x)
  {
    m*=1.01;
    i++;
  }
  cout<<i<<endl;
  
}

Measured memory_bytes: 3636
import numpy as np
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

dp=np.zeros((n,3),int)
for i in range(n):
  for j in range(3):
    dp[i][j]=ABC[0][j] if i==0 else max(dp[i-1][(j+1)%3]+ABC[i][j], dp[i-1][(j+2)%3]+ABC[i][j])
print(max(dp[-1]))

Measured memory_bytes: 41808
#include <stdio.h>

int main(void)
{
	int n,b,f,r,v,i,j,k,l;
	int h[4][3][10]={0};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		h[b-1][f-1][r-1]+=v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",h[i][j][k]);
			}
			printf("\n");
		}
		if(i==3) break;
		for(l=0;l<20;l++){
			printf("#");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int im=0;
	string s;
	cin>>s;
	int ss=s.size();
	for(int t=0;t<ss;t++) 
	{
		char symbol=s.at(t);
		if(symbol=='+')
		im++;
		else
		im--;
	}
	cout<<im<<endl;
}

Measured memory_bytes: 3592
a, b = [int(i) for i in input().split()]
l = [1]
if a%2==0:
  l.append(2)
while(a%2==0):
  a/=2

i = 3
while(a>i**2):
  if a%i==0:
    l.append(i)
  while(a%i==0):
    a/=i
  i+=2
if a not in l:
  l.append(a)
cnt = 0
for i in l:
  if b%i==0:
    cnt += 1
print(cnt)

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  int m; cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; i ++) cin >> b[i];

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  int j = 0;
  for (int i = 0; i < m; i ++) {
    while (j < n) {
      if (b[i] == a[j]) break;
      else j ++;
    }
    if (j == n) {
      cout << "NO" << endl;
      return 0;
    }
    j ++;
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) < sum(b):
    print(-1)
else:
    d = [a[i] - b[i] for i in range(n)]
    count = 0
    num = 0
    for i in d:
        if i < 0:
            count += 1
            num += i
    d.sort(reverse = True)
    for i in d:
        if num >= 0:
            break
        num += i
        count += 1
    print(count)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int cur = 0, res = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      res = max(res, cur);
      cur = 0;
    } else {
      ++cur;
    }
  }   
  res = max(res, cur);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;
int main() {
    while (cin >> str) {
        string res = "";
        for (int i = 0; i < str.size(); ++i) {
            if (i % 2 == 0) res += str[i];
        }
        cout << res << endl;
    }
}





Measured memory_bytes: 512
def lcm(a,b):
    x,y=a,b
    while b:
        a,b=b,a%b
    return x*y//a
X=[]
A=list(map(int, input().split()))
A.append(lcm(A[2],A[3]))
for i in range(3):
    if A[0]%A[i+2]==0:
        X.append(int(A[1]//A[i+2])-int(A[0]//A[i+2])+1)
    else:
        X.append(int(A[1]//A[i+2])-int(A[0]//A[i+2]))
print(A[1]-A[0]+1-X[0]-X[1]+X[2])

Measured memory_bytes: 3064
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int n, m, Q, L[200009], R[200009], X[509][509], C[509][509];

int main() {
	cin >> n >> m >> Q;
	for(int i = 1; i <= m; i++) {
		cin >> L[i] >> R[i]; 
        X[L[i]][R[i]]++;
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
            C[i][j] = C[i][j-1] + X[i][j];
        }
	}

	rep(roop, Q) {
		int p, q; 
        cin >> p >> q;

		int ans = 0;
		for(int i = p; i <= q; i++) { 
            ans += C[i][q] - C[i][p-1];
        }

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4480
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

s = input()
mx = 0
for i in range(0,len(s)):
    for j in range(i,len(s)):
        sp = s[i:j + 1]
        # print(sp)
        at = True
        for k in range(j-i+1):
            if sp[k] != 'A' and sp[k] != 'G' and sp[k] != 'C' and sp[k] != 'T':
                at = False

        if at:
            mx = max(mx, len(sp))
            # print(mx)

print(mx)

Measured memory_bytes: 38256
import bisect
n = int(input())
l = len(str(n))

ary = []

siti = ["3","5","7"]
def dfs (s,t):
	if len(s) == t:
		if s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
			ary.append(int(s))
		return
	for j in siti:
		dfs(s+j,t)

for i in range(3,l+1):
	dfs("",i)

ary.sort()
print (bisect.bisect_right(ary,n))

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

int main(){
  using BS = bitset<64>;
  BS b(0);

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int t,x=-1;
    cin>>t;
    if(t<4) cin>>x;
    if(t==0) cout<<b[x]<<endl;
    if(t==1) b.set(x);
    if(t==2) b.reset(x);
    if(t==3) b.flip(x);
    if(t==4) cout<<b.all()<<endl;
    if(t==5) cout<<b.any()<<endl;
    if(t==6) cout<<b.none()<<endl;
    if(t==7) cout<<b.count()<<endl;
    if(t==8) cout<<b.to_ullong()<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3124
package main

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

func main() {
	ReadLineInt()
	var (
		Input = ReadLineInt()
	)

	for i, v := range Input {
		Input[i] = v - 1
	}

	result := 0
	for i, v := range Input {
		if Input[v] == i {
			result++
		}
	}

	fmt.Println(result / 2)
}

///////////////////////////////////request //////

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}


Measured memory_bytes: 7936
N = int(input())
A = list(map(int, input().split()))
infants = []
for i,a in enumerate(A):
    infants.append((a, i))

infants.sort(reverse=True)
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]


# i番目の幼児まで見るとき
for i in range(N):
    """
    i番目の幼児を配置する方法として、
    ・左側の１～i番目として配置
    ・右側の１～i番目として配置
    の方法がある
    
    左のj人目として配置した場合、右にはi-j人配置されていることになる（右も同じ）
    例：５番目を左の二人目として配置したら、右には残りの３人がいる計算になる

    """
    for j in range(i+1):

        # 左側に配置したとき
        dp[j+1][i-j] =    max(dp[j+1][i-j], dp[j][i-j] + infants[i][0] * abs(infants[i][1] - j))
            
        # 右側に配置したとき
        dp[i-j][j+1] = max(dp[i-j][j+1], dp[i-j][j] + infants[i][0] * abs(infants[i][1] - (N-1 - j)))


ans = 0
for i in range(N+1):
    ans = max(ans, dp[i][N-i])

print(ans)


Measured memory_bytes: 107348
import java.util.Scanner;

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

    int sum=1;
    for(int i=1; i<n; i++) {
      if(s.charAt(i-1)!=s.charAt(i)) {
        sum++;
      }
    }
    System.out.println(sum);
  }
}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

#define int ll

const int mod = 1e9+7;

void solve()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i=2;(i*i)<=n;i++)
	{
		int cnt = 0;
		while(n%i == 0)
		{
			n/=i;
			cnt++;
		}
		int l = 1,r=(cnt/2)+1;
		int p = 0;
		if(cnt == 0) continue;
		while(l <= r)
		{
			int mid = (l+r)/2;
			int s = mid*1LL*(mid+1)/2;
			if(s == cnt)
			{
				p = mid;
				break;
			}
			if(s < cnt)
			{
				p = mid;
				l = mid+1;
			}
			else
			{
				r = mid-1;
			}
		}
		ans+=p;
		if(n < i)	break;
	}
	if(n != 0 && n!=1)	ans++;
	cout << ans;
}

signed main()
{
  	IOS;
  	//freopen("input.txt", "rt", stdin);
  	//freopen("output.txt", "wt", stdout);
  	int t=1;
  	//cin >> t;
  	while(t--)
  	{
   	solve();
  	}
  	return 0;
}
/*==============================================================================================================================================================*/


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(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 to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(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;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct 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, i, x;
  char com[20];
  int a=0;
  a=kansu(a);
  if(a == 0){
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}
}
void kansu(int a){
 int b=0,c=1;
 if(b == 0);
  if(c == 1);
   return a;
}


Measured memory_bytes: 20604
use proconio::input;
// ordtools {{{
#[allow(dead_code)]
mod ordtools {
    pub trait Ordtools: PartialOrd + Sized {
        fn change_min(&mut self, mut rhs: Self) {
            if self > &mut rhs {
                *self = rhs;
            }
        }

        fn change_max(&mut self, mut rhs: Self) {
            if self < &mut rhs {
                *self = rhs;
            }
        }
    }

    impl<T: PartialOrd + Sized> Ordtools for T {}
}
// }}}
use ordtools::Ordtools;

fn main() {
    input!(n: usize, a: [i64; n]);
    let sum = a.iter().sum::<i64>();
    let mut now = a[0];
    let mut ans = (sum - 2 * now).abs();
    for i in 1..n - 1 {
        now += a[i];
        ans.change_min((sum - 2 * now).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4776
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int n, m; cin>>n>>m;

   char a[n+5][m+5];
    int L[n+5][m+5], U[n+5][m+5], D[n+5][m+5], R[n+5][m+5];

   for(int i = 1; i <= n; i++){
       L[i][1] = 1;
       R[i][m] = 1;
   }
   for(int j = 1; j <= m; j++){
       U[1][j] = 1;
       D[n][j] = 1;
   }

   for(int i = 1; i <= n; i++){
       for(int j = 1; j <= m; j++){
           cin>>a[i][j];
           if(a[i][j] == '#'){
               L[i][j] = R[i][j] = U[i][j] = D[i][j] = 0;
           }
       }
   }

    
   for(int i = 1; i <= n; i++){
       for(int j = 2; j <= m; j++){
           if(a[i][j] != '#')
                L[i][j] = L[i][j-1] + 1;
       }
       for(int j = m-1; j >= 1; --j){
           if(a[i][j] != '#'){
               R[i][j] = R[i][j+1] + 1;
           }
       }
   }

   for(int j = 1; j <= m; j++){
       for(int i = 2; i <= n; i++){
           if(a[i][j] != '#'){
               U[i][j] = U[i-1][j] + 1;
           }
       }
       for(int i = n-1; i >= 1; --i){
           if(a[i][j] != '#'){
               D[i][j] = D[i+1][j] + 1;
           }
       }
   }

//    for(int i = 1; i <= n; i++){
//        for(int j = 1; j <= m; j++){
//            cout<<L[i][j]<<"$"<<R[i][j]<<"$"<<U[i][j]<<"$"<<D[i][j]<<" ";
//        }cout<<endl;
//    }

    int ans = 0;
   for(int i = 1; i <= n; i++){
       for(int j = 1; j <= m; j++){
           if(a[i][j] != '#'){
               ans = max(ans, L[i][j] + U[i][j] + D[i][j] + R[i][j] - 3);
           }
       }
   }

   cout<<ans<<"\n";


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 66944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var ans = 700 + GetStr().ToCharArray().Count(s => s == 'o') * 100;

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
ll min(ll a,ll b)
{
	if(a<b){return a;}
	return b;
}
int main()
{
	//fopen();
	fastio;
	int n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;
	ll c=0,a[n],b[n],j[n];
	fll(a);fll(b);fll(j);
	rep(i,k)
	{
		//a[i]=1;b[i]=1;j[i]=1;
		if(t[i]=='r'){c+=p;a[i]=1;}
		else if(t[i]=='p'){c+=s;b[i]=1;}
		else if(t[i]=='s')c+=r;j[i]=1;
	}
	//int a=1,b=1,j=1;
	repA(k,i,n)
	{
		if(t[i]=='r')
		{
			if(t[i-k]!='r')c+=p,a[i]=1;
			else if(t[i-k]=='r')
			{
				if(a[i-k]==0){
					c+=p;
					a[i]=1;
				}
				else{a[i]=0;}
			}
		}
		else if(t[i]=='s')
		{
			if(t[i-k]!='s')c+=r,b[i]=1;
			else if(t[i-k]=='s')
			{
				if(b[i-k]==0){
					c+=r;
					b[i]=1;
				}
				else{b[i]=0;}
			}
		}
		else 
		{
			if(t[i-k]!='p')c+=s,j[i]=1;
			else if(t[i-k]=='p')
			{
				if(j[i-k]==0){
					c+=s;
					j[i]=1;
				}
				else{j[i]=0;}
			}
		}
	}
	cout<<c;
}


Measured memory_bytes: 2768
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W := getInt(), getInt()

	// 縦
	w := W / 3
	m := W % 3
	if m == 2 {
		m--
	}
	ans := (w+m)*H - w*H
	// 横
	h := H / 3
	m = H % 3
	if m == 2 {
		m--
	}
	ans = min(ans, W*(h+m)-W*h)
	// 縦→横
	w = ((H * W) / 3) / H
	a := w * H
	b := (W - w) * (H / 2)
	c := (W - w) * (H/2 + H%2)
	s := max(a, max(b, c)) - min(a, min(b, c))
	ans = min(ans, s)
	w++
	a = w * H
	b = (W - w) * (H / 2)
	c = (W - w) * (H/2 + H%2)
	s = max(a, max(b, c)) - min(a, min(b, c))
	ans = min(ans, s)
	// 横→縦
	h = ((H * W) / 3) / W
	a = W * h
	b = (H - h) * (W / 2)
	c = (H - h) * (W/2 + W%2)
	s = max(a, max(b, c)) - min(a, min(b, c))
	ans = min(ans, s)
	h++
	a = W * h
	b = (H - h) * (W / 2)
	c = (H - h) * (W/2 + W%2)
	s = max(a, max(b, c)) - min(a, min(b, c))
	ans = min(ans, s)

	out(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l
int main() {
    int a[6];
    int cnt[4] = {0};
    rep(i, 6) {
        cin >> a[i];
        if (a[i] == 1)cnt[0]++;
        if (a[i] == 2)cnt[1]++;
        if (a[i] == 3)cnt[2]++;
        if (a[i] == 4)cnt[3]++;

    }
    int ans = 0;
    rep(i, 4) {
        if (cnt[i] >= 2)ans++;
    }
    if (ans >= 2)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long BIT[1<<20],dp[1<<20],h[1<<20],a[1<<20];
int n;
void add(long long x,int pos){
	while(pos<=n){
		BIT[pos]=max(BIT[pos],x);
		pos+=pos&-pos;
	}
}
long long query(int pos){
	long long ma=0;
	while(pos){
		ma=max(ma,BIT[pos]);
//		cout<<ma<<"gzh"<<endl;
		pos-=pos&-pos;
	}
	return ma;
}
int main(){
	scanf("%d",&n);
	
	for(int i=0;i<n;i++) scanf("%lld",&h[i]);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	long long ma=0;
//	cout<<"haha"<<endl;
	memset(BIT,0,sizeof BIT);
//	cout<<query(h[0])<<" "<<h[0]<<endl;
	for(int i=0;i<n;i++){
		long long x=query(h[i])+a[i];
		add(x,h[i]);
//		cout<<x<<endl;
		ma=max(x,ma);
	}
	cout<<ma;
	return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll inf = 1e17, N = 2000007;
ll ar[N];
int main()
{
    ll n, m, d, tot = 0, cnt = 0;
    cin>>n>>m;
    for(int i = 0; i < n; i++)
    {
        cin>>ar[i];
        tot += ar[i];
    }
    d = (tot/(4 * m)) + (tot % (4 * m) != 0);
    for(int i = 0; i < n; i++)
    {
        if(ar[i] >= d) cnt++;
    }
    //cout<<cnt<<" ";
    if(m <= cnt) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=998244353
input=lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self,n):
        fact=[1]*(n+1); invfact=[1]*(n+1)
        for i in range(1,n+1): fact[i]=i*fact[i-1]%MOD
        invfact[n]=pow(fact[n],MOD-2,MOD)
        for i in range(n-1,-1,-1): invfact[i]=invfact[i+1]*(i+1)%MOD
        self.__fact=fact; self.__invfact=invfact

    def inv(self,n):
        assert(n>0)
        return self.__fact[n-1]*self.__invfact[n]%MOD

    def fact(self,n):
        return self.__fact[n]

    def invfact(self,n):
        return self.__invfact[n]

    def comb(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[k]*self.__invfact[n-k]%MOD

    def perm(self,n,k):
        if(k<0 or n<k): return 0
        self.__fact[n]*self.__invfact[k]%MOD

def prime(n):
    if n<=1: return []
    S=[1]*(n+1)
    S[0]=0; S[1]=0
    for i in range(2,n):
        if(S[i]==0): continue
        for j in range(2*i,n+1,i): S[j]=0
    return [p for p in range(n+1) if(S[p])]

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    V=max(A)
    C=[0]*(V+1)
    for a in A: C[a]+=1

    P=prime(V)
    W=[1]*(V+1)
    for p in P:
        for i in range(p,V+1,p):
            W[i]*=(1-p)
    mf=modfact(V)
    for i in range(1,V+1):
        W[i]=(W[i]*mf.inv(i))%MOD

    ans=0
    for d in range(1,V+1):
        s=0 # 和(後に2乗する)
        t=0 # 2乗の和
        for i in range(d,V+1,d):
            s+=i*C[i]
            t+=(i**2)*C[i]
        ans+=W[d]*(s**2-t)//2
        ans%=MOD
    print(ans)
resolve()

Measured memory_bytes: 116352
#include <iostream>
#include <cstdio>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main () {
    long long int a, b, k;
    cin >> a >> b >> k;
    if(k <= a){
        a -= k;
    }
    else{
        k -= a;
        a = 0;
        if(k <= b) b -= k;
        else b = 0;
    }
    cout << a << " " << b << endl;
}

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

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

    long long ans = 1;

    while (N > 0) {
        ans *= N;
        // cout << ans << endl;
        ans = ans % 1000000007;
        N--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
s=set()
for i in range(1,n//2+1):
    if n%2==1:
        s.add((i,n-i))
    else:
        s.add((i,n+1-i))
m=len(s)
print(n*(n-1)//2-m)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if (i,j) in s:
            pass
        else:
            print(i,j)

Measured memory_bytes: 42736
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    
    int ans = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                int sum = i * 500 + j * 100 + k * 50;
                if (sum == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MOD = 1e9+7, N = 2005;
long long dp[N][N];

int main(){
    int n, k;
    cin >> n >> k;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0) dp[i][j] = 1;
            else dp[i][j] = (dp[i-1][j-1] + dp[i-1][j])%MOD;
        }
    }

    for(int i = 1; i <= k; i++){
        cout << ( dp[n-k+1][i] * dp[k-1][i-1] )%MOD << endl;
    }


}


Measured memory_bytes: 26276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N < 1200){
			System.out.println("ABC");
		}
		else if(1200 <= N){
			System.out.println("ARC");
		}
		
	}

}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
#include<time.h>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<int, int> P;

ll dp[55][2];

int main(void) {
	ll k, a, b;
	cin >> k >> a >> b;
	if (a > b) {
		cout << k + 1 << endl;
		return 0;
	}

	if (b - a <= 1) {
		cout << k + 1 << endl;;
		return 0;
	}

	if (k <= a) {
		cout << k + 1 << endl;
		return 0;
	}

	ll ans = a;
	k -= (a - 1);
	if (k % 2 == 0) {
		ans += k / 2 * (b - a);
	}
	else {
		ans += k / 2 * (b - a) + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int k;
    cin >> k;
    int even = k/2;
    int odd = (k+1)/2;
    out(even*odd);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

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

int main(void) {
  int n, m;
  cin >> n >> m;

  if(n==m){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b,c;
    cin >> a;
    int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 

    cout << k[a-1];




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	
	cout << ce(n, max(h, w)) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 500000

void max(int);
void build(void);
void printout(void);
int count,i;
int A[N];

int main() {
 int i;
 
  scanf("%d",&count);
  for(i = 0 ; i < count ; i++) scanf("%d",&A[i]);
  
  build();
  printout();

  return 0;
}

void max(int j){
  int largest,small;    
    if(2*j+1 <= count && A[2*j+1] > A[j]){
      largest = 2*j+1;
    }
    else largest = j;
  
    if(2*j+2 <= count && A[2*j+2] > A[largest]){
      largest = 2*j+2;
    }

    if(largest != j){
      small = A[largest];
      A[largest] = A[j];
      A[j] = small;
      max(largest);
    }
}

void build(){
  int j;
  for(j = count/2-1 ; j >= 0 ; j--){
    max(j);  
  }
}
void printout(){
  for(i = 0 ; i < count ; i++)
    printf(" %d",A[i]);
  printf("\n");
}

Measured memory_bytes: 2552
def sign(a)
  if a > 0
    return 1
  elsif a == 0
    return 0
  else
    return -1
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
if n!=1
  up_ary = [a[0],a[1]]
  judge = sign(a[1]-a[0])
  for i in 2..n-1
    if up_ary.size() == 1 || judge == 0
      up_ary.push(a[i])
      judge = sign(up_ary[-1]-up_ary[-2])

    elsif judge == 1
      if up_ary[-1] <= a[i]
        up_ary.push(a[i])
      else
        up_ary = [a[i]]
        count += 1
      end
    elsif judge == -1
      if up_ary[-1] >= a[i]
        up_ary.push(a[i])
      else
        up_ary = [a[i]]
        count += 1
      end
    end
  end
end
count += 1
puts count

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

const int id = 0;

int op(int l, int r) {
	return l + r;
}

struct node {
	int pos, val, all;
	node *lch, *rch;
	node(int p, int v)
		: pos(p), val(v), all(v), lch(nullptr), rch(nullptr) {}
};

void update_up(node* t) {
	t->all = op(op((t->lch ? t->lch->all : id), t->val), (t->rch ? t->rch->all : id));
}

node *update(node* t, int p, int val, int lb, int ub) {
	if (!t) return new node(p, val);
	if (t->pos == p) {
		t->val += val;
		update_up(t);
		return t;
	}
	int m = (lb + ub) >> 1;
	if (p < m) {
		t->lch = update(t->lch, p, val, lb, m);
	}
	else {
		t->rch = update(t->rch, p, val, m, ub);
	}
	update_up(t);
	return t;
}

int find(node* t, int l, int r, int lb, int ub) {
	if (!t || r <= lb || ub <= l) return id;
	if (l <= lb && ub <= r) return t->all;
	int m = (lb + ub) >> 1;
	int val = l <= t->pos && t->pos < r ? t->val : id;
	return op(op(find(t->lch, l, r, lb, m), find(t->rch, l, r, m, ub)), val);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	node *seg = nullptr;
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y; x--;
		if (com == 0) {
			seg = update(seg, x, y, 0, n);
		}
		else {
			printf("%d\n", find(seg, x, y, 0, n));
		}
	}
	return 0;
}



Measured memory_bytes: 5480
s = input()
x, y = map(int, input().split())

flg = 1
x_list = []
y_list = []
tmp = 0
for i, si in enumerate(s):
    if si == 'F':
        tmp += 1
    else:
        if flg == 1:
            x_list.append(tmp)
        else:
            y_list.append(tmp)
        flg *= -1
        tmp = 0
if flg == 1:
    x_list.append(tmp)
else:
    y_list.append(tmp)

x = sum(x_list) - x
y = sum(y_list) - y
if x % 2 != 0 or y % 2 != 0:
    print('No')
    exit()

if x < 0 or y < 0:
    print('No')
    exit()

x //= 2
y //= 2

if s[0] == 'F':
    x_list.reverse()
    x_list.pop()

dpx = [[0] * (x+1) for _ in range(len(x_list)+1)]
dpx[0][0] = 1
dpy = [[0] * (y+1) for _ in range(len(y_list)+1)]
dpy[0][0] = 1
for i in range(len(x_list)):
    for j in range(x+1):
        if dpx[i][j]:
            dpx[i+1][j] = 1
            if j + x_list[i] <= x:
                dpx[i+1][j+x_list[i]] = 1
for i in range(len(y_list)):
    for j in range(y+1):
        if dpy[i][j]:
            dpy[i+1][j] = 1
            if j + y_list[i] <= y:
                dpy[i+1][j+y_list[i]] = 1

if dpx[-1][-1] and dpy[-1][-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 105436
#include <stdio.h>

int main(void)
{
	int i, n, a;
	long int goukei = 0;
	int M = -1000000, m = 10000000;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		goukei = goukei + a;
		if (a >= M)
		{
			M = a;
		}
		if(a <= m)
		{
			m = a;
		}
	}
	printf("%d %d %ld\n", m, M, goukei);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int gcd(int a,int b){
   if(a%b==0) return b;
   return gcd(b,a%b);
}
int digit(int num){
   int cnt=0;
   while(num!=0){
      cnt+=num%10;
      num=num/10;
   }
   return cnt;
}
int main(void){
   string S;
   cin>>S;
   int N=S.size();
   long long ans=0;
   int cnt_B=0;
   for(int i=0;i<N;i++){
      if(S[i]=='B'){
         cnt_B++;
      }else{
         ans+=cnt_B;
      }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> TP;
typedef pair<string, string> PS;

ll n, m;
vector<ll> G[214514], g[214514];
ll par[214514], DEP[214414], tr[214444];

void DFS(ll pos, ll dep, ll from) {
  if (par[pos]) {
    if (DEP[pos] < dep) {
      par[pos] = from + 1;
      DEP[pos] = dep;
      return;
    } else {
      return;
    }
  }

  par[pos] = from + 1;
  DEP[pos] = dep;
  for (auto &a : g[pos]) {
    DFS(a, dep + 1, pos);
  }
}

int main() {
  cin >> n >> m;

  REP(i, n + m - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[b].pb(a);
    g[a].pb(b);
  }
  ll ne;
  REP(i, n) {
    if (G[i].size() == 0) {
      ne = i;
    }
  }
  queue<ll> pos, dep, from;
  pos.push(ne);
  dep.push(0);
  from.push(-1);

  while (!pos.empty()) {
    ll po = pos.front();
    pos.pop();
    ll de = dep.front();
    dep.pop();
    ll fr = from.front();
    from.pop();
    par[po] = fr + 1;
    for (auto &a : g[po]) {
      tr[a]++;
      if (G[a].size() == tr[a]) {
        pos.push(a);
        dep.push(de + 1);
        from.push(po);
      }
    }
  }

  REP(i, n) { cout << par[i] << endl; }
}

Measured memory_bytes: 21108
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;


int mod_power(int x, int y, int mod){
  int ans = 1;
  x %= mod;
  while(y){
    if (y & 1)
      ans *= x, ans %= mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}

int mod_inverse(int n, int mod){
  return mod_power(n, mod - 2, mod);
}

int mod_ncr(int n, int r, int mod){
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i, fact %= mod;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i, ans %= mod;
  ans *= mod_inverse(fact, mod), ans %= mod;
  return ans;
}

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}


bool m[2100][2100];
int **u;
int **d;
int **l;
int **r;


signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  u = new int*[2010];
  d = new int*[2010];
  l = new int*[2010];
  r = new int*[2010];

  for (int i = 0; i < 2010; i++)
    u[i] = new int[2010], d[i] = new int[2010], l[i] = new int[2010], r[i] = new int [2010];
  
  int h, w;
  cin >> h >> w;
  char c;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++){
      cin >> c;
      if (c == '.')
	m[i][j] = 1;
    }
  for (int i = 0; i < h; i++){
    int ll = -1;
    for (int j = 0; j < w; j++)
      if (!m[i][j])
	ll = j;
      else
	l[i][j] = ll;
    int rr = w;
    for (int j = w - 1; j >= 0; j--)
      if (!m[i][j])
	rr = j;
      else
	r[i][j] = rr;
  }

  for (int j = 0; j < w; j++){
    int uu = -1;
    for (int i = 0; i < h; i++)
      if (!m[i][j])
	uu = i;
      else
	u[i][j] = uu;
    int dd = h;
    for (int i = h - 1; i >= 0; i--)
      if (!m[i][j])
	dd = i;
      else
	d[i][j] = dd;
  }
  int ans = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (m[i][j])
	ans = max(ans, r[i][j] - l[i][j] - 1 + d[i][j] - u[i][j] - 1 - 1);
  cout << ans << endl;
      
}


Measured memory_bytes: 133620