akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i,n,a[100],b[100],s=0;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>b[i];
    }
    a[0]=b[0];
    s=a[0];
    for(i=0;i<n-1;i++){
        //if(i==0){a[i]=b[i];}
        if(i==n-2){
            a[i+1]=b[i];
            s=s+a[i+1];
            break;
        }

        a[i+1]=min(b[i],b[i+1]);
        s=s+a[i+1];
    }
    cout<<s;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#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 inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(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 UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL a, b;
LL d[2], c;

LL deg(LL v, int d) { return (v / (1LL << d)) % 2; }
void one(LL & v, int d) { if(deg(v, d) == 0) { v += (1LL << d); } }

int main() {
	cin >> a >> b;
	
	LL mm = b, ap = a, bp = b;
	bool flag = false;
	dec(i, 61) {
		if(! flag) {
			if(deg(a ^ b, i) == 1) {
				flag = true;
				one(ap, i);
			}
		}
		if(flag) {
			if(deg(b, i) == 1) { c++; }
			one(mm, i);
			if(c >= 2) { one(bp, i); }
		}
	}
	bp++;
	
	LL ans = (mm - a + 1) - max(0LL, ap - bp);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),l=s.nextInt();
		int[]a=IntStream.range(l,l+n).toArray();
		//System.err.println(Arrays.toString(a));

		int sum=Arrays.stream(a).sum();
		int min=Arrays.stream(a).boxed().min(Comparator.comparingInt(Math::abs)).get();
		System.err.println(sum);
		System.err.println(min);
		System.out.println(sum-min);
	}
}


Measured memory_bytes: 26816
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi 3.14159265359
//#define INF 0x7fffffff
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef long long LL;
int main(){
	char c[100005];
	scanf("%s",c);
	int s=0,e=strlen(c)-1;
	int ans=0;
	for(;s<e;){
		if(c[s]==c[e])
		s++,e--;
		else{
			if(c[s]=='x')
			ans++,s++;
			else if(c[e]=='x')
			ans++,e--;
			else{
				printf("-1\n");
				return 0;
			}	
		}
		//printf("%c %c\n",c[s],c[e]);
	}
	printf("%d\n",ans);
} 





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

int main() {
  string s, t;
  cin >> s >> t;
  
  int a, b;
  cin >> a >> b;
  
  string u;
  cin >> u;
  
  if (u == s) {
    a--;
  }
  
  if (u == t) {
    b--;
  }
  
  cout << a << " " << b;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * n

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
    # 一番目の足場では一つ前しか存在しない
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i -2]))

print(dp[n-1])


Measured memory_bytes: 52208
import java.util.Scanner;

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

		int n = sc.nextInt();
		
	if(n==7||n==5||n==3){
		System.out.println("YES");
	}else{
		System.out.println("NO");
	}
	
	}}

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

int main() {
	long long n;
	while ( cin >> n ) {
		int h[ n+5 ], mh[ n+5 ]; mh[0] = 0;
		
		for (int i = 1; i <= n; ++i) { cin >> h[i]; mh[i] = max( mh[ i-1 ], h[i] ); }
		
		int ans = 0;
		
		for (int i = 1; i <= n; ++i) if ( h[i] == mh[i] ) ans++ ;
		
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(6-(a+b));

    }
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , k;
int a[ 55 ];
int dp[ 55 ][ 55 ][ 105 ];

int solve( int l , int r , int kk ) {
        if( kk < 0 ) return -inf;
        if( kk == 0 || l > r ) return 0;
        if( dp[l][r][kk] != -1 ) return dp[l][r][kk];
        int ret = -inf;
        ret = max( ret , solve( l + 1 , r , kk - 1 ) + a[l] );
        ret = max( ret , solve( l , r - 1 , kk - 1 ) + a[r] );
        ret = max( ret , solve( l + 1 , r , kk - 2 ) );
        ret = max( ret , solve( l , r - 1 , kk - 2 ) );
        ret = max( ret , 0 );
        return dp[l][r][kk] = ret;
}
int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n >> k;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        memset( dp , -1 , sizeof( dp ) );
        cout << solve( 1 , n , k )<< endl;
        return 0;
}










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

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val)
{
    std::fill((T*)array, (T*)(array + N), val);
}
void dfs(int v, Graph& G, vector<bool>& seen)
{
    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv])
            continue;
        dfs(nv, G, seen);
    }
}
int main()
{
    int N, M;
    cin >> N >> M;
    Graph G(N);
    vector<bool> seen(N, false);
    for (int i = 0; i < M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int ans = 0;
    for (int v = 0; v < N; v++) {
        if (seen[v])
            continue;
        dfs(v, G, seen);
        ans++;
    }

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

Measured memory_bytes: 13388
import Control.Monad.State
import Data.List.Split

type Dist = Double
type Angle = Int

main = do
    moveList <- getList []
    let (x,y) = evalState (moves moveList) ((0,0),90)
    print $ truncate x
    print $ truncate y

getList lst = do
    line <- getLine
    let [d,a] = splitOn "," line
        d' = read d :: Dist
        a' = read a :: Angle
    if d == "0" && a == "0" then return lst
                            else getList (lst ++ [(d',a')])


moves :: [(Dist,Angle)] -> State ((Double,Double),Angle) (Double,Double)
moves []         = move 0 0
moves ((d,a):ms) = move d a >>= \x -> moves ms
move :: Dist -> Angle -> State ((Double,Double),Angle) (Double,Double)
move d nextA = do
    (point,ang) <- get
    let newpoint = pursue d ang point
    put (newpoint,(ang - nextA) `rem` 360)
    return newpoint

pursue :: Dist -> Angle -> (Double,Double) -> (Double,Double)
pursue d ang (x,y) = (x',y')
    where
        x' = x + d * cos (fromIntegral ang*pi/180)
        y' = y + d * sin (fromIntegral ang*pi/180)

Measured memory_bytes: 4164
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key))sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2132
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
typedef struct pp{
  char name[100];
  int t;
}P;

P Q1[MAX+1],Q2[MAX+1];

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P x);
P dequeue(void);
int tail,head,n;
int main(){
  int x,time=0,i,t;
  char elaps[100];
  P q;
  scanf("%d %d",&n,&t);

  initialize();
  for(i=0;i<n;i++){
    for ( i = 1; i <= n; i++){
      scanf("%s", Q1[i].name);
      scanf("%d", &Q1[i].t);
      enqueue(Q1[i]);
    }
  }
  
  while(head!=tail){        
    
    q=dequeue();
    x=q.t-t;
    if(x>0){
      q.t=x;
      enqueue(q);
      time+=t;
    }
    
    else{    
      time+=q.t;    
      printf("%s %d\n",q.name,time);	
    }    
  }  
  return 0;
}

void initialize(void){
  head = tail = 0;
}

int isEmpty(void){
  if( head == tail)return 0;//kara
  else return 1;
}
int isFull(void){
  if (head == (tail+1) % MAX) return 0; //manpai
  else return 1;
}
void enqueue(P x){

  if(isFull()== 0){
    fprintf(stderr,"??¨?????????????????????????????????\n");
    exit(8);
  }
  Q2[tail] = x;
  if(tail ==n+1)tail=0;
  else tail++;
}
P  dequeue(void){
  P x;
  if(isEmpty()== 0){
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(8);
  }
  x = Q2[head];
  if (head ==n+1)head = 0;
  else head++;
  return x;
  
}

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

int main() {

  int64_t X,A,B,AA,BB;
  cin >> X; // 本野和
  for(int64_t i=0;i<X;i++){
    A=i;
    AA = pow(A,5);
    BB = AA - X;
    if ( BB < 0 ){
      BB *= -1;
      B = pow(BB,0.2);
      B *= -1;
    } else {
      B = pow(BB,0.2);
    }
    if( X == A * A * A * A * A - B * B * B * B * B ) { break;}
  }
  cout << A << " " << B << endl;
}


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

long long int max1, max2;
long long int N, C;
vector<long long int> x, v, toRight, toRightMax, toRight2, toLeft, toLeftMax, toLeft2;
int main() {
	cin >> N >> C;
	long long int temp_x, temp_v;
	for(int i=0; i<N; i++) {
		cin >> temp_x >> temp_v;
		x.push_back(temp_x);
		v.push_back(temp_v);
		toRight.push_back(0);
		toRightMax.push_back(0);
		toRight2.push_back(0);
		toLeft.push_back(0);
		toLeftMax.push_back(0);
		toLeft2.push_back(0);
	}

	// 時計回りオンリー
	toRight[0] = v[0] - x[0];
	toRightMax[0] = toRight[0];
	toRight2[0] = toRight[0] - x[0];
	for(int i=1; i<N; i++) {
		toRight[i] = toRight[i-1] + v[i] - (x[i] - x[i-1]);
		if(toRightMax[i-1] < toRight[i])
			toRightMax[i] = toRight[i];
		else
			toRightMax[i] = toRightMax[i-1];
		toRight2[i] = toRight2[i-1] - 2 * (x[i] - x[i-1]) + v[i];
	}
	// 半時計回りオンリー
	toLeft[N-1] = v[N-1] - (C - x[N-1]);
	toLeftMax[N-1] = toLeft[N-1];
	toLeft2[N-1] = toLeft[N-1] - (C - x[N-1]);
	for(int i=1; i<N; i++) {
		toLeft[N-1-i] = toLeft[N-i] + v[N-1-i] - (x[N-i] - x[N-1-i]);
		if(toLeftMax[N-i] < toLeft[N-1-i])
			toLeftMax[N-1-i] = toLeft[N-1-i];
		else
			toLeftMax[N-1-i] = toLeftMax[N-i];
		toLeft2[N-1-i] = toLeft2[N-i] - 2 * (x[N-i] - x[N-1-i]) + v[N-1-i];
	}

	// 右に行ってから左へ
	long long int temp_max1;
	for(int i=0; i<N-1; i++) {
		temp_max1 = toRight2[i] + toLeftMax[i+1];
		if(max1 < temp_max1)
			max1 = temp_max1;
	}
	// 左に行ってから右へ
	long long int temp_max2;
	for(int i=N-1; i>=1; i--) {
		temp_max2 = toLeft2[i] + toRightMax[i-1];
		if(max2 < temp_max2)
			max2 = temp_max2;
	}

	if(max1 < max2)
		max1 = max2;
	if(max1 < toLeftMax[0])
		max1 = toLeftMax[0];
	if(max1 < toRightMax[N-1])
		max1 = toRightMax[N-1];
	if(0 > max1)
		max1 = 0;
	cout << max1 << endl;

	return 0;
}

Measured memory_bytes: 6704
#include <iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 1e9
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a<b&&b<c?"Yes":"No")<<endl;
}


Measured memory_bytes: 3116
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')

for l in range(n - k + 1):
    r = l + k - 1
    ans = min(ans, min(abs(x[l]), abs(x[r])) + x[r] - x[l])
print(ans)


Measured memory_bytes: 14168
#include <iostream>
#include <math.h>
using namespace std;
//ABCD?????????????????°??????
int main(){
	int n;
	cin >> n;
	while(n--){
		double x[4], y[4], o;
		for(int i = 0; i < 4; i++) cin >> x[i] >> y[i];
		o = (x[1]-x[0])*(y[3]-y[2]) - (y[1]-y[0])*(x[3]-x[2]);
		if(fabs(o) < 1e-10) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

int s[101];

void solve()
{
    int N, K;
    cin >> N >> K;
    REP1 (i, K)
    {
        int d;
        cin >> d;
        REP1 (i, d)
        {
            int A;
            cin >> A;
            s[A]++;
        }
    }
    int ans = 0;
    REP1 (i, N)
    {
        ans += (s[i] == 0);
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)
#define MAP_traverse_ulta(it,x) for(auto it=ED(x); it!=BN(x); it-- )
#define PI 3.14159265358979323846264338327950L

map<int,int> mp;
map<int,int>::iterator it;

int main()
{
    IOS;
    
    st str,st1;
    cin>>str;

    if (str=="ABC")
    {
        cout<<"ARC";
    }else
    {
        cout<<"ABC";
    }
    
    
   
    

  return 0;
     
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int N =1e5+3;
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #else
  #endif
  int n;
  cin>>n;cout<<1000*(n%1000!=0)-n%1000 <<endl;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int N=sc.nextInt();
		int X=sc.nextInt();
		int T=sc.nextInt();
		int t=ceil(N,X);
		System.out.println(t*T);
 	}
	static int ceil(int a,int b){
        return a%b==0?a/b:a/b+1;
    }
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32468
console.log((args=>{
  const S = args.trim().split('');
  const stack = [[S.slice(0,3),S[3]]];
  while ( stack.length ) {
    const [a,s] = stack.pop();
    if ( a.length === 0 ) {
      if ( eval(s) === 7 ) return s+'=7';
      else continue;
    }
    const v = a.pop();
    stack.push([[...a],v+'+'+s]);
    stack.push([[...a],v+'-'+s]);
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29468
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t X;
    intmax_t ans = 0;

    scanf("%jd", &X);

    while (X >= 500) {
        X -= 500;
        ans += 1000;
    }
    while (X >= 5) {
        X -= 5;
        ans += 5;
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

template<class Type,class Type_k>
Type nCk(Type n,Type_k k){//nCk.
	if(n<k) return 0;
	if(n<0 or k<0) return 0;
	Type res=1;
	for(Type i=0;i<k;++i) res*=n-i, res/=i+1;
	return res;
}

llong solve1(string s){
	if(s.size()<1) return 0;
	
	llong res=9*(s.size()-1);
	res+=s[0]-'0';
	
	return res;
}

llong solve2(string s){
	if(s.size()<2) return 0;
	
	llong res=nCk(s.size()-1,2)*pow(9,2);
	res+=(s[0]-'0'-1)*((s.size()-1)*9);
	
	int i;
	for(i=1;i<s.size();++i){
		if(s[i]!='0') break;
	}
	string t=s.substr(i,s.size()-i);
	res+=solve1(t);
	
	return res;
}

llong solve3(string s){
	if(s.size()<3) return 0;
	
	llong res=nCk(s.size()-1,3)*pow(9,3);
	res+=(s[0]-'0'-1)*nCk(s.size()-1,2)*pow(9,2);
	
	int i;
	for(i=1;i<s.size();++i){
		if(s[i]!='0') break;
	}
	string t=s.substr(i,s.size()-i);
	res+=solve2(t);
	
	return res;
}

int main(){
	string s;
	int k;
	cin>>s>>k;
	
	llong ans;
	if(k==1) ans=solve1(s);
	else if(k==2) ans=solve2(s);
	else if(k==3) ans=solve3(s);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
donuts = []
for _ in range(N):
    donuts.append(int(input()))

cnt = len(donuts)
for d in donuts:
    X -= d
min_d = min(donuts)
while X >= min_d:
    X -= min_d
    cnt += 1
print(cnt)


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

using namespace std;

using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

int H, W;
char field[50][50];
bool can = true;

int main(void){
	cin>>H>>W;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++) cin>>field[i][j];

	for(int i=1;i<H;i++) {
		for(int j=1;j<W;j++) {
			if(field[i][j]=='#' && field[i][j-1]!='#' && field[i][j+1]!='#' && field[i-1][j]!='#' && field[i+1][j]!='#') {
				can = false;
			}
		}
	}

	if(can) cout<< "Yes" <<endl;
	else cout<< "No" <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
const int mod = 1000000007;
 
int main() {
    int n;
    string s;
    cin >> n >> s;
    VI a(n);
    rep(i,n) {
        if(s[i] == 'R') a[i] = 0;
        if(s[i] == 'G') a[i] = 1;
        if(s[i] == 'B') a[i] = 2;
    }
    vector<LL> cnt(3);
    rep(i,n) cnt[a[i]]++;
    LL ans = 1;
    rep(i,3) ans *= cnt[i];
    rep(j,n)rep(i,j) {
        int k = 2*j - i;
        if(k < n) {
            if(a[i] == a[j]) continue;
            if(a[i] == a[k]) continue;
            if(a[k] == a[j]) continue;
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
object Main extends App {
  val x = io.StdIn.readLine()
  val targets = Seq('7', '5', '3')
  val res = x.toCharArray.foldLeft(0)((acc, a) => if (targets.contains(a)) 1 + acc else acc)
  println(if (res > 0) "YES" else "NO")
}

Measured memory_bytes: 25552
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a>0) {
    cout << "Positive" << endl;
  }
  else {
    if (b>=0) {
      cout << "Zero" << endl;
    }
    else {
      if ((b-a+1)%2==0) {
        cout << "Positive" << endl;
      }
      else {
        cout << "Negative" << endl;
      }
    }
  }
}

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

int main(){
	int n;
	int i;
	cin >> n;
	vector<int> a(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int counter = 0;
	int temp = a[0];
	while(temp%2 == 0){
		temp = temp >> 1;
		counter++;
	}
	if(counter == 0){
		cout << 0 << endl;
		return 0;
	}
	int division = 1 << counter;
	while(1){
		for(i=0; i<a.size(); i++){
			if(a[i]%division != 0){
				break;
			}
			if(i == a.size()-1){
				cout << counter << endl;
				return 0;
			}
		}
		division = division >> 1;
		counter--;
	}
}


Measured memory_bytes: 256
from itertools import permutations

N = int(input())

A = tuple([int(x) for x in input().split()])
B = tuple([int(x) for x in input().split()])

all_list = []
for i in permutations(range(1, N+1)):
    all_list.append(i)

print(abs(all_list.index(A)-all_list.index(B)))


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

typedef long long ll;

ll n,t;
ll a[100002];
ll cnt=0;
ll nmin,nminid;
ll ans[100002]={0};
ll ansmax=0;

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

	for(int i=n-1;i>=0;i--){
		nminid=i;nmin=a[i];
		for(int j=nminid;j>=0;j--){
			if(a[j]<nmin){nmin=a[j];nminid=j;}

		}


		while(i>=nminid){
			
			ans[i]=a[i]-nmin;
			if(ans[i]>ansmax)ansmax=ans[i];
			i--;
		}
		i++;

	}

	for(int i=0;i<n;i++)if(ans[i]==ansmax)cnt++;
	cout<<cnt<<endl;
}

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

int main() {
	int i, j;

	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>l>>n>>m;
    if(m>n)
    {
        r=max(0,(m-n-l));
    }
    else
    {
        r=max(0,(n-m-l));
    }
    cout<<r<<"\n";
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		InputStreamReader insISR = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(insISR);
		int intA = 1;
	//	System.out.println("????????\????????????????????????");
		try {
			String strLine = reader.readLine();
			int intNum = Integer.parseInt(strLine);
			int intYakusuu = 0;
			int intThreetimes = 3;
			String strCheckNum = "3";
			intYakusuu = intNum % intThreetimes;
			while(intA <= intNum) {
				String strA = String.valueOf(intA);
				boolean isOk1 = false;
				boolean isOk2 = false;
				intYakusuu = intA % intThreetimes;
				int intYakusuu1 = intA % 10;
				if(intYakusuu == 0) {
					System.out.print(" "+intA);
					intThreetimes = intThreetimes + 3;
					isOk1 = true;
				}
				else if(intYakusuu1 == 3) {
					System.out.print(" "+intA);
					isOk2 = true;
				}
				else if(strA.indexOf(strCheckNum) != -1) {
					System.out.print(" "+strA);
				}
				intA = intA + 1;
			}
			System.out.println("");
		}catch(IOException e) {
			System.out.println(e);
		}catch(NumberFormatException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 28328
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans="";
		if (a<=b) {
			for(int i=1;i<=b;i++){
				ans=ans+a;
			}
		}
		else{
			for(int i=1;i<=a;i++){
				ans=ans+b;
			}
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 21204
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var T = Console.ReadLine().ToArray();
            for (var i = 0; i < T.Length; i++) {
                if(T[i] == '?') {
                    T[i] = 'D';
                }
            }
            Console.Write(string.Join(null,T));
        }
    }
}

Measured memory_bytes: 33464
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n,k;
	cin >> n >> k;
	vector<int>h(n);
	rep(i, n) {
		cin >> h[i];
	}
	int ans = 0;
	rep(i, n) {
		if (h[i] >= k)++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    ll n, m, x, y;
    while(cin>>n>>m>>x>>y){
        ld ans=0;
        ans=n*m;
        ans/=2.0;
        cout<<fixed<<setprecision(12)<<ans<<" " ;
        if(x==n/2&&y==m/2&&n%2==0&&m%2==0){
            cout<<1<<endl;
        }
        else{
            cout<<0<<endl;
        }

    }
  return 0;
}




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

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;

  long double x =
      sqrt(a * a + b * b - 2 * a * b * cosl((60 * h - 11 * m) * M_PI / 360.0));

  cout << fixed << setprecision(15);
  cout << x << endl;
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int ans = N;
	REP(i, 1, N - 1) {
		int A = i;
		int B = N - i;
		int tmp = 0;
		while (A > 0) {
			tmp += A % 10;
			A /= 10;
		}
		while (B > 0) {
			tmp += B % 10;
			B /= 10;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    A.at(i) = i + 1;
  }
  long long ans = 0;
  for(int i = 0; i < N; i++) {
    if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
      ans += A.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7152
#include <iostream>
using namespace std;
int main()
{
    int n, k, q; cin >> n >> k >> q;
    int score[n];
    int freq[100001] = {0};
    for (int i = 0; i < q; i++) {int a; cin >> a; freq[a-1]++;}
    for (int i = 0; i < n; i++) {score[i] = k - q + freq[i];}
    for (int i = 0; i < n; i++) 
    {
        if(score[i] <= 0){cout << "No" << "\n";}
        else{cout << "Yes" << "\n";}
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define pll pair<ll, ll>
#define N 200123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vpll vector<pll>
#define pb emplace_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007LL
#define M 10000123

using namespace std;


int main(){
    ios_base::sync_with_stdio(0);
    ll a, b;
    ll d;
    scanf("%lld %lld.%lld", &a, &b, &d);
    b *= 100LL;
    a = a * (b + d) / 100LL;
    printf("%lld\n", a);
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0);
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];


signed main(){
	IOS
	ll n;
	string s;
	cin >> n >> s;
	string s1 = s.substr(0, n), s2 = s.substr(n, n);
	reverse(s2.begin(), s2.end());
	map<pair<string, string>, ll> mp;
	for (ll i = 0;i < (1 << n);++i){
		string t1 = "", t2 = "";
		for (int j = 0;j < n;++j) {
			if((i >> j) & 1)t1 = t1 + s1[j];
			else t2 = t2 + s1[j];
		}
		reverse(t2.begin(), t2.end());
		mp[make_pair(t1, t2)]++;
	}
	ll ans = 0;
	for (ll i = 0;i < (1 << n);++i){
		string t1 = "", t2 = "";
		for (int j = 0;j < n;++j) {
			if((i >> j) & 1)t1 = t1 + s2[j];
			else t2 = t2 + s2[j];
		}
		reverse(t2.begin(), t2.end());
		ans += mp[make_pair(t1, t2)];
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 84992
#include<iostream>
using namespace std;
int N_MAX = 10;
int main()
{
  int n,nn,m,i,j,kk,t,res=0;
  int k[N_MAX],s[N_MAX][N_MAX],p[N_MAX],ss[N_MAX];
  cin >> n >> m;
  for(i=0;i<m;i++){
    cin >> k[i];
    for(j=0;j<k[i];j++)
      cin >> s[i][j];
  }
  for(i=0;i<m;i++)
    cin >> p[i];
  nn=1<<n;
  for(i=0;i<nn;i++){
    for(j=0;j<n;j++)
      ss[j]=(i>>j)%2;
    for(j=0;j<m;j++){
      t=0;
      for(kk=0;kk<k[j];kk++)
        if(ss[s[j][kk]-1]==1) t++;
      if(t%2!=p[j]) break;
    }
    if(j==m) res++;
  }
  cout << res << endl;
  return 0;
}

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

const int maxn = 100010, P = 1000000007;
int n, m;
long long x[maxn], y[maxn];

int main() {
    scanf("%d %d", &n, &m);
    long long ans1 = 0, ans2 = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &x[i]);
        ans1 += x[i] * (i - 1) - x[i] * (n - i), ans1 %= P;
    }
    for (int i = 1; i <= m; i++) {
        scanf("%lld", &y[i]);
        ans2 += y[i] * (i - 1) - y[i] * (m - i), ans2 %= P;
    }
    ans1 = ans1 * ans2 % P;
    printf("%lld\n", (ans1 + P) % P);
    return 0;
}

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

int main(){
  map<int,int> m;
  int a;
  for(int i=0;i<3;++i){
    cin >> a;
    ++m[a];
  }
  if(m[5] == 2 && m[7] == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

const int MAXN = 1000 * 100 * 2 + 100;
vector <int> gr[MAXN];
int holder[MAXN];
int check[MAXN];
int sum[MAXN];

void dfs(int, int);

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x;
		holder[p] += x;
	}
	dfs(1, holder[1]);
	for (int i = 1; i <= n; i++) {
		cout << sum[i] << ' ';
	}
	cout << endl;
	return 0;
}

void dfs(int v, int sumTilNow) {
	check[v] = 1;
	sum[v] = sumTilNow;
	for (int u: gr[v]) {
		if(check[u] == 0) {
			dfs(u, sumTilNow + holder[u]);
		}
	}

}

Measured memory_bytes: 21760
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
 
const int INF = 1e9 + 5;
 
int main() {
    int n;
    scanf("%d", &n);
int k;
cin>>k;
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
  vector<int> dp(n,INF);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    
  for(int i=2;i<n;i++){
      int p=k;
    while(p!=0){
      if(i-p<0){
        p--;
        continue;
      }
      else{
        dp[i]=min(dp[i],  dp[i-p]+abs(h[i]-h[i-p]));
      p--;
      }
    }
  }
 cout<<dp[n-1]<<endl;
return 0;
}
      
      
      
      
      
      

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

#include <iostream>
#include <fstream>

#include <iostream>

class ABlackjack {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int a,b,c;
	    cin>>a>>b>>c;
	    cout<<(a+b+c>=22?"bust":"win");
	}
};


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


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int a[N],b[N],n;
int t[N],l[N];
int g(int k){
	int ans=0;
	for(;k;k-=k&-k)ans=max(ans,t[k]);
	return ans;
}
void up(int k,int p){
	for(;k<N;k+=k&-k)t[k]=max(t[k],p);
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i];
	sort(b+1,b+1+n);
	int len=unique(b+1,b+1+n)-b-1;
	for(int i=1;i<=n;i++)a[i]=lower_bound(b+1,b+1+len,a[i])-b,a[i]=n-a[i]+1;
	int ans=0;
	for(int i=1;i<=n;i++){
		l[i]=g(a[i])+1;
		up(a[i],l[i]);
		ans=max(ans,l[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ld long double
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
#define pr_vec(v) for(ll _=0;_<v.size();_++) cout << v[_] << " " ;
const int N = 1e6 + 7;
ll m = 998244353;


void solve()
{
    ll n, w, x, y;
    cin >> n >> w;
    std::vector<ll> dp(w + 1);
    rep(_, n)
    {
        std::vector<ll> t=dp;
        cin >> x >> y;
        for(ll i = 0; i + x <= w; i++)
            t[i + x] = max(dp[i + x], dp[i] + y);


        swap(dp, t);

    }
    cout << dp[w];


}



int main()
{



    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;


    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        cout << endl;
    }


}

Measured memory_bytes: 1816
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x;

  if(x >= 30) cout <<"Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3648
N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0 
for i in range(1,N):
    if P[i-1]>P[i] and flag == 0:
        flag = 1
    elif P[i-1]<P[i] and flag == 0:
        flag = 2
    elif flag == 1 and (P[i-1] < P[i]) :
        cnt += 1
        flag = 0
    elif flag == 2 and (P[i-1] > P[i]) :
        cnt += 1
        flag = 0
print(cnt)

Measured memory_bytes: 14252
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void printlong(int64_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int main(void){
	int k=nextint();
	for(int i=0; i<k; i++){
		printf("ACL");
	}
}


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

using namespace std;
typedef unsigned long long ull;

int main()
{
	ull n, t, ai;
	cin >> t;
	n = t * 3;
	ull counter = n-2;
	ull msum = 0;

	vector<ull> mems;
	mems.reserve(n);
	while (n > 0)
	{
		cin >> ai;
		mems.push_back(ai);
		--n;
	}

	sort(mems.begin(), mems.end());
	
	while (t > 0)
	{
		msum += mems[counter];
		counter -= 2;
		--t;
	}
	cout << msum << endl;

	return 0;
	
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    // if ((n - 1) * d - (n + 1) * c >= 0) {
    //     if (-d * n <= b - a && b - a <= d * n) cout << "YES\n";
    //     else cout << "NO\n";
    // } else {
        n--;
        ll x = (b - a) + (n * d), y = c + d;
        ll M = (y + x % y) % y;
        if (M <= n * (d - c) && -d * n <= b - a && b - a <= d * n) cout << "YES\n";
        else cout << "NO\n";
    // }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int ROW_INDEX = 1;
//[min_range, max_range]からn_ints個の整数の組をすべてとりだしcomb[組][整数]に格納する
void AllCombs_ints(int min_range, int max_range, int depth, int n_ints, int **comb){
	if(depth > 0){
		for(int x = min_range; x <= max_range; x++){
			//comb[0]を一時的な格納場所として使っている。気持ち悪い。
			comb[0][depth-1] = x;
			if(depth == 1){
				for(int num_i = 1; num_i <= n_ints; num_i++)
					comb[ROW_INDEX][num_i-1] = comb[0][n_ints-num_i];
				ROW_INDEX++;
			}
			AllCombs_ints(x, max_range, depth - 1, n_ints, comb);
		}
	}
	if(depth == n_ints)
		ROW_INDEX = 1;
}
long int Factorial(int upto){
	if(upto == 0)
		return 1;
	return upto * Factorial(upto - 1);
}
int main(){
	int N, M, Q;
	scanf("%d %d %d", &N, &M, &Q);
	int mat[Q][4], **pt_srs;
	long int n_combs = Factorial(N+M-1) / Factorial(N) / Factorial(M-1);
	pt_srs = (int **) malloc(sizeof(int *) * (n_combs + 1));
	for(int pt_i = 0; pt_i <= n_combs; pt_i++)
		pt_srs[pt_i] = (int *) malloc(sizeof(int) * N);
	AllCombs_ints(1, M, N, N, pt_srs);
	for(int i = 0; i < Q; i++)
		for(int j = 0; j < 4; j++)
			scanf("%d", &mat[i][j]);

	long int ans = 0;
	for(int pt_i = 1; pt_i <= n_combs; pt_i++){
		int ans_temp = 0;
		for(int abcd_i = 0; abcd_i < Q; abcd_i++)
			if(pt_srs[pt_i][mat[abcd_i][1]-1]-pt_srs[pt_i][mat[abcd_i][0]-1] == mat[abcd_i][2])
				ans_temp += mat[abcd_i][3];
		if(ans_temp > ans)
			ans = ans_temp;
	}
	printf("%ld", ans);

	for(int pt_i = 0; pt_i <= n_combs; pt_i++)
		free(pt_srs[pt_i]);
	free(pt_srs);
	return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a[5];
  int ans=15;
  rep(i,5){cin>>a[i];ans-=a[i];}
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3560