akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n,k;
    cin>>n>>k;
    // 前処理
    COMinit();

    // 計算例
    for (int i=1;i<=k;i++){
        cout<<COM(n-k+1,i)*COM(k-1,i-1)%MOD<<endl;
    }
}



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

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t N;

    scanf("%"PRIu64, &N);

    uint64_t sum = 0;

    for (size_t i = 0; i < N; i++) {
        uint64_t a;
        scanf("%"PRIu64, &a);

        sum ^= a;
    }

    puts(sum == 0 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i,b,n) for(int i = (b) ; i < (n) ; ++i)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
  ll  money , year , n[100], Q , ans;
  int q;
  long double ss;
  cin >> q;
  while( q-- ){
    ans = 0;
    cin >> money >> year >> Q;
    rep(i,Q){
      ll n,bad;
      cin >> n >> ss >> bad;
      if(n == 0){
        ll a = money;
        ll now = 0;
        rep(j,year){
          now += ss * a;
          a -= bad;
        }
        ans = max(ans,a+now);
      } else{
        ll a = money;
        rep(j,year) a = a + ss * a - bad;
        ans = max(ans,a);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1232
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    while (n--) {
        float x1, y1, x2, y2, x3, y3, x4, y4;
        std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

        std::cout << (((x1 - x2) * (y3 - y4) == (y1 - y2) * (x3 - x4))?
                     "YES": "NO") << std::endl;
    }

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int A,B; cin>>A>>B; cout<<A*B<<"\n";
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

void sort(int x,int y,int z,int *list){

	if(x>=y && x>=z){
		list[0] = x;
		if(y>=z){
			list[1] = y; list[2] = z;
		}else{
			list[1] = z; list[2] = y;
		}
	}else if(y>=x && y>=z){
		list[0] = y;
		if(x>=z){
			list[1] = x; list[2] = z;
		}else{
			list[1] = z; list[2] = x;
		}
	}else{
		list[0] = z;
		if(x>=y){
			list[1] = x; list[2] = y;
		}else{
			list[1] = y; list[2] = x;
		}
	}
	
}


int main(void){
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	int list[3];
	
	sort(A,B,C,list);
	int c=0;
	while(list[1]<list[0]){
		list[1]+=1;
		list[2]+=1;
		c++;
	}
	while(list[2]<list[1]){
		list[2]+=2;
		c++;
	}
	if(list[2]>list[0])	c++;
	
	printf("%d",c);
	return 0;}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;

  return 0;
}

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

void myswap(int &, int &);

int mypartition(vector<int> &, int, int);

int main(int argc, char const *argv[])
{
    int n = 0;
    cin >> n;

    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int q = mypartition(a, 0, n - 1);

    for (int i = 0; i < q; i++) {
        cout << a[i] << " ";
    }
    cout << "[" << a[q] << "]";
    for (int i = q + 1; i < n; i++) {
        cout << " " << a[i];
    }
    cout << endl;

    return 0;
}

void myswap(int & a, int & b)
{
    int c = a;
    a = b;
    b = c;
}

int mypartition(vector<int> & a, int p, int r) {
    int i = p - 1;
    int j = p;

    while(j < r) {
        if (a[j] > a[r])
        {
            j++;
        }
        else
        {
            i++;
            myswap(a[i], a[j]);
            j++;
        }
    }

    myswap(a[i + 1], a[r]);

    return (i + 1);
}


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

int main()
{
  int n;
  cin >> n;
  int m;
  m = (int)(n / 1.08);
  for(int i = m-10; i<m+10; i++){
    if((int)(i * 1.08) == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include <forward_list>

#define mod 1000000007

using namespace std;

int main() {

	int N, L;
	cin >> N >> L;

	if (L<=0 && N+L-1 <= 0) {//0をまたがずに負からはじまる
		cout << (N - 1) * (L + N + L -1 -1) / 2 << endl;
	}
	else if (L < 0) {//0を跨いで負から始まる
		cout << (N) * (L + N + L-1) / 2 << endl;

	}
	else if (L >= 0) {//正からはじまる
		cout << (N - 1) * (L+1 + N + L-1) / 2 << endl;
	}
	

}




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s, ans = "Yes";
    cin >> s;
    for(int i = 0; i < (int)s.length(); i++){
        if(i % 2 == 0 && s[i] == 'L'){
            ans = "No";
            break;
        }
        if(i % 2 == 1 && s[i] == 'R'){
            ans = "No";
            break;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const N = tmp[0]|0;
  const h = tmp[1].split(' ').map(v=>v|0);
  const dp = Array(N).fill(Infinity);
  dp[0] = 0;
  for ( let i = 0; i < N-1; i++ ) {
    const j1 = Math.abs( h[i] - h[i+1] ) + dp[i];
    if ( dp[i+1] > j1 ) dp[i+1] = j1
    if ( i+1 === N ) break;
    const j2 = Math.abs( h[i] - h[i+2] ) + dp[i];
    if ( dp[i+2] > j2 ) dp[i+2] = j2;
  }
  return dp[N-1].toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 27568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005,Mo=1000000007;
int n,m,q,a[MAXN],b[MAXN];
int main(){
	n=read();
	FOR(i,1,n) a[i]=read();
	LL ans=0; a[0]=a[n+1]=0;
	FOR(i,1,n+1) ans+=abs(a[i]-a[i-1]);
	FOR(i,1,n) {
		if ((a[i]-a[i-1])*(a[i]-a[i+1])<=0) printf("%lld\n",ans);
		else printf("%lld\n",ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
	}
	return 0;
}

/*
*/


Measured memory_bytes: 1664
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}

int main(void){
    ll a,b;
    sf(a);sf(b);
    ll ans=round((a+b)/2.0);
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int x;
  cin>>x;
  cout<<(x^1)<<endl;
}



Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>

#define MAX_LEN 50

int main() {
    char S[MAX_LEN+1], T[MAX_LEN+1];
    scanf("%s\n%s",S,T);
    int i, j, sl = (int)strlen(S), tl = (int)strlen(T);
    bool restored=false;
    for (i=sl-1; i>=0; i--) {
        if (!restored && i >= tl-1) {
            for (j=0; j<tl; j++)  {
                if (S[i-j] != '?' && S[i-j] != T[tl-j-1]) break;
            }
            if (j == tl) {
                memcpy(S+(i-tl+1),T,(size_t)tl);
                restored = true;
            } else if (S[i] == '?') S[i] = 'a';
        } else if (S[i] == '?') S[i] = 'a';
    }
    printf("%s\n", restored ? S : "UNRESTORABLE");
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

int main() {
  long long A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  long long ans = 0;
  
  if (A + B <= C + C){
    if (A > C+C) {
      ans += (C+C)*X;
    } else{
      ans += A*X;
    }

    if (B > C+C) {
      ans += (C+C)*Y;
    } else{
      ans += B*Y;
    }

  } else {
    if(X > Y){
      ans = Y*(C+C);
      if(A > C+C){
        ans += (X-Y)*(C+C);
      } else{
        ans += (X-Y)*A;
      }
    } else{
      ans = X*(C+C);
      if(B > C+C){
        ans += (Y-X)*(C+C);
      } else{
        ans += (Y-X)*B;
      }
    }

  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long x = sc.nextLong();
	char c = sc.next().charAt(0);
	long y = sc.nextLong();
	if(c == '+')
	    System.out.println(x + y);
	else if(c == '-')
	    System.out.println(x - y);
    }
}


Measured memory_bytes: 10192
from collections import deque, Counter

h, w = map(int, input().split())
s = []
c = Counter()
for i in range(h):
    s_ = input().rstrip()
    s.append(s_)
    c.update(list(s_))

searched = [[False] * w for i in range(h)]

d = deque([(0, 0, 1)])
clear_step = -1

while d:
    i, j, step = d.popleft()

    if searched[i][j]:
        continue
    else:
        searched[i][j] = True

    if i == h-1 and j == w-1:
        clear_step = step
        break

    if i > 0 and s[i-1][j] == '.':
        d.append((i-1, j, step+1))
    if i < h-1 and s[i+1][j] == '.':
        d.append((i+1, j, step+1))
    if j > 0 and s[i][j-1] == '.':
        d.append((i, j-1, step+1))
    if j < w-1 and s[i][j+1] == '.':
        d.append((i, j+1, step+1))

if clear_step >= 0:
    print(c['.']-clear_step)
else:
    print(-1)


Measured memory_bytes: 40304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n, i;
    cin >> n >> i;
    i--;
    string s;
    cin >> s;
    s[i] = tolower(s[i]);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {

    val line = stdin.getLines
    val (a,b,c) = line.foldLeft(0,0,0){ (s,t) =>
      t.split(",").map(_.toInt) match { case Array(x,y) => (s._1+x*y,s._2+y,s._3+1) }
    }
    println(a)
    println(Math.round(b.toDouble/c))
}

Measured memory_bytes: 44016
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
map<string, int> dp;
int dir[4] = {-1, -4, 1, 4};
/*
 第一次从看到&#36825;个&#39064;目，从正面思考很&#38590;，&#36825;&#26102;要学会从反面思考，从&#32467;果出&#21457;得到&#27599;一个状&#24577;，&#36825;&#26102; 
 &#27599;个状&#24577;的&#32467;果就可以通&#36807;BFS一&#27493;&#27493;得到，然后用一个MAP&#32500;&#25252;起来，&#36825;&#26679;完全&#25191;行一次之后就可以得到
 所有可能的&#32467;果了，然后直接从&#36755;入的&#32467;果中&#26597;找&#23545;&#24212;的答案就行了！ 
*/
void bfs(){
	queue<string> que;
	que.push("01234567");
	
	while(que.size()){
		string now = que.front();
		que.pop();
		
		int curP = 0;
		for(int i = 0; i < now.length(); i++){
			if(now[i] == '0'){
				curP = i;
			}
		}
		
		for(int i = 0; i < 4; i++){
			int nexP = curP + dir[i];
			//&#36824;是老&#38382;&#39064;，我&#20204;在数&#32452;表示的地&#22270;移&#21160;&#26102;，一定要注意移&#21160;的合法性和正&#30830;性 
			if(nexP >= 0 && nexP < 8 && !(nexP == 4 && curP == 3) && !(nexP == 3 && curP == 4)){
				string next = now;
				swap(next[curP], next[nexP]);
				if(dp.find(next) == dp.end()){
					dp[next] = dp[now] + 1;
					que.push(next);
				}
			}
		}
	}
}

void solve(){
	bfs();
	string line;
	//无限&#36755;入字符串，一行一个
	while(getline(cin, line)){
		//去掉字符串的空格
		line.erase(remove(line.begin(), line.end(), ' '), line.end());
		cout << dp[line] << endl;
	}
	 
}

int main(){
	solve();
}

Measured memory_bytes: 5400
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>

using namespace std;

int n, m, q, l, r, dia[503][503], sum[503][503];

int main()
{
    cin>>n>>m>>q;
    memset(sum, 0, sizeof(sum));
    memset(dia, 0, sizeof(dia));
    for (int i=0; i<m; i++)
    {
        cin>>l>>r;
        dia[l][r]++;
    }
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            sum[i][j]=sum[i][j-1]+dia[i][j];
        }
    }
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            sum[j][i]=sum[j-1][i]+sum[j][i];
        }
    }
    for (int i=0; i<q; i++)
    {
        cin>>l>>r;
        cout<<sum[r][r]-sum[l-1][r]-sum[r][l-1]+sum[l-1][l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2944
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let input = buf.trim().parse::<i32>().expect("Parse error");
    println!("{}", solve(input));
}

fn solve(input: i32) -> String {
    // write solution here
    let mut output = String::new();
    for i in 3..input + 1 {
        if i % 3 == 0 {
            output.push_str(&format!(" {}", i));
        } else if let Some(_) = i.to_string().find('3') {
            output.push_str(&format!(" {}", i));
        }
    }
    // return answer
    output.to_string()
}



Measured memory_bytes: 5056
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;
int A, B;

int main()
{
    scanf("%d %d", &A, &B);
    int h = 100;
    int w = 100;
    char C[101][101];
    REP(i, h) {
        REP(j, w) {
            if(j<50)
                C[i][j] = '.';
            else
                C[i][j] = '#';
        }
    }

    A--;
    B--;
    int i = 0;
    int j = 0;
    while(B>0) {
        C[i][j] = '#';
        B--;
        if(j<48) {
            j += 2;
        } else {
            j = 0;
            i += 2;
        }
    }

    i = 0;
    j = 51;
    while(A>0) {
        C[i][j] = '.';
        A--;
        if(j<99) {
            j += 2;
        } else {
            j = 51;
            i += 2;
        }
    }

    printf("%d %d\n", h, w);
    REP(i, h) {
        REP(j, w)
            printf("%c", C[i][j]);
        printf("\n");
    }



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,h[maxn],dp[maxn],k;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	for (int i=1;i<=n;i++) read(h[i]);
	for (int i=2;i<=n;i++) {
		dp[i]=(2e9);
		for (int j=max(1,i-k);j<i;j++)
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << 

int w, h;
int x, y;

signed main()
{
    cin >> w >> h;
    cin >> x >> y;

    double res = (w*h) / 2.0;
    cout << res << " ";

    if ((double)w / 2.0 == (double)x  && (double)h / 2.0 == (double)y){
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	ll n,m; cin>>n>>m;
	ll i;
	ll sum=0;
	ll x[m];
	for(i=0; i<m; i++){cin>>x[i]; sum+=x[i];}

	ll duration = n-sum;

	if(duration<0) cout << -1 << endl; else cout<<duration<<endl;



	return 0;
}



Measured memory_bytes: 3672
def main():
    import sys
    input = sys.stdin.readline
    N, A, B, C, D = [int(x) for x in input().strip().split()]
    A, B, C, D = A-1, B-1, C-1, D-1
    S = input().strip()
    if C == D:
        print('No')
        return
    if C > D:
        C, D = D, C
        A, B = B, A
    while B != D:
        # print(S)
        # print(' ' * A + 'A')
        # print(' ' * B + 'B')
        if B + 2 < N and B + 2 != A and S[B+2] == '.':
            B += 2
        elif B + 1!= A and S[B+1] == '.':
            B += 1
        else:
            if A > B:
                if A + 1 < N and B != A + 1 and S[A+1] == '.':
                    A += 1
                elif A + 2 < N and B != A + 2 and S[A+2] == '.':
                    A += 2
                else:
                    print('No')
                    return
            else:
                print('No')
                return
    
        
    while A != C:
        # print(S)
        # print(' ' * A + 'A')
        # print(' ' * B + 'B')
        if A + 2 < N and B != A + 2 and S[A+2] == '.':
            A += 2
        elif A + 1 < N and B != A + 1 and S[A+1] == '.':
            A += 1
        else:
            print('No')
            return

    # print(S)
    # print(' ' * A + 'A')
    # print(' ' * B + 'B')
    print('Yes')



if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            a[i] = l + i;
            sum += a[i];
        }

        if (a[0] < 0 && a[n - 1] > 0) System.out.print(sum);
        else if (a[0] >= 0) System.out.print(sum - a[0]);
        else System.out.print(sum - a[n - 1]);
    }
}

Measured memory_bytes: 21460
open Scanf
open Printf

let (n,a,b,c) = sscanf (read_line ()) "%d %d %d %d" (fun n a b c -> (n,a,b,c))
let list = 
let rec input_list n l =
match n with 
  0 -> l
| x -> input_list (x-1) (sscanf (read_line ()) "%d" (fun x -> x):: l)
in input_list n [];;

let ans = ref 3000;;

let rec loop a_in b_in c_in mp l =
match l with
  [] -> 
  if (a_in * b_in * c_in = 0) then 3000
  else 
  let tmp = abs(a - a_in) + abs(b - b_in) + abs(c - c_in) + mp - 30 in
  let _ = ans := min !ans tmp in
  (*let _ = printf "%d %d %d\n" a_in b_in c_in in
  let _ = printf "tmp = %d\n" tmp in*)
  tmp
  | x::rest -> 
  let a_use = loop (a_in + x) b_in c_in (mp+10) rest in
  let b_use = loop a_in (b_in + x) c_in (mp+10) rest in
  let c_use = loop a_in b_in (c_in + x) (mp+10) rest in
  loop a_in b_in c_in mp rest;;

let _ = loop 0 0 0 0 list in printf ("%d\n") !ans;;


Measured memory_bytes: 384
#include<iostream>
#include<string>

using namespace std;

int main() {
	int n, ans = 0; bool f;
	string s, gs;
	cin >> n >> s;
	int len = (signed)s.length(), glen;
	for(int i=0; i<n; ++i) {
		cin >> gs; f = false;
		glen = (signed)gs.length();
		for(int j=0; j<=glen-len&&!f; ++j) {
			for(int k=1; k<=(glen-j-1)/(len-1)&&!f; ++k) {
				for(int l=0; l<len; ++l) {
					if(s[l]!=gs[j+l*k]) break;
					if(l==len-1) {
						ans++; f=true;
						break;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1208
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-08-02 19:55:47
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    n = int(input())
    print('Yes' if n>=30 else 'No')
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 62588
#include <stdio.h>
int main (void) {
    int sum,temp,i;
    while (scanf("%d",&sum)!=EOF&&sum!=0) {
        for (i=0; i<9; i++) {
            scanf("%d",&temp);
            sum-=temp;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 600
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N;
	cin >> N;
	vll X(N), nx;
	rep(i, N) cin >> X[i];
	nx = X;
	sort(all(nx));
	ll r = nx[N / 2], l = nx[N / 2 - 1];
	rep(i, N) {
		if (X[i] <= l) cout << r << endl;
		else cout << l << endl;
	}
}

Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
	int n;
	cin >> n;
	double k = n;
	double res = 0;
	res = (n % 2 == 0) ? (floor(k/2) / k) : ((floor(k/2)+1) / k);
	cout << fixed << setprecision(6) << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
long long black , sum , a;
string s;
vector<int>v;
int main(){
	cin >> s;
	sum = 0;
	a = 0;
	black = 0;
	for(int i = 0 ; i < s.size() ; i++){
		if(s[i] == 'B'){
			black++;
			v.pb(i);
		}
	}
	for(int i = v.size() - 1 ; i >= 0 ; i--){
		a++;
		sum += s.size() - v[i] - a;
	}
	cout << sum << endl;
}

Measured memory_bytes: 4404
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int r;
    cin >> r;
    cout << 2*r * M_PI << endl;
}

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

int main(){
	int n, m; ll k; cin>>n>>m>>k;
	ll A[n], B[m];
	rep(i, n) cin>>A[i];
	rep(i, m) cin>>B[i];
	ll sumb = 0; rep(i, m) sumb += B[i];
	int ans = 0, j = m;
	rep(i, n+1){
		while(j>0 && sumb > k) sumb -= B[--j];
		if(sumb > k) break;
		ans = max(ans, i+j);
		if(i == n) break;
		sumb += A[i];
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pi 3.1415926
int main(){
	int n,m;
	cin>>n>>m;
	int sum=0;
	while(m--){
		int a;
		cin>>a;
		sum+=a;
	}
	cout<<max(-1,n-sum);
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
def main():
    import sys
    import numpy as np

    read = sys.stdin.read

    N, W = map(int, input().split())
    products = map(int, read().split())

    dp = np.zeros(W + 1, dtype=np.int64)
    for can_w, can_v in zip(products, products):
        dp[can_w:] = np.maximum(dp[can_w:], dp[:-can_w] + can_v)

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 29068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10 , OO = 0x3f3f3f3f;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(n) for(int &x : n) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

vector<int>divisors;
int n;


void generateDivisors(int n)
{
  int i;
  for ( i = 1; i*i < n; ++i) {
    if(n%i==0){
      divisors.push_back(i);
      divisors.push_back(n/i);
    }
  }
  if(i*i==n)
    divisors.push_back(i);
}


int main()
{   

      ios_base::sync_with_stdio(0) , cin.tie(0);cout.tie(0);

      cin >> n;
      generateDivisors(n);
      sort(ALL(divisors));
      int sz = SZ(divisors);
      bool tmam = 0;
      for(int i = 0 ; i < sz ; ++i){
            for(int j = 0 ; j < sz ; ++j)
                  if((divisors[i]*divisors[j] == n))
                        if(divisors[i] >= 1 && divisors[i] <= 9 && divisors[j] >= 1 && divisors[j] <= 9)
                              tmam = 1;
      }

      if(tmam) cout << "Yes\n";
      else cout << "No\n";

    
      return 0;
}

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

using namespace std;
int main() {
  int n, t = 0, x = 0, y = 0;
  cin >> n;
  int t2, x2, y2;
  bool result = true;
  for (int i = 0; i < n; i++) {
    cin >> t2 >> x2 >> y2;
    int time = t2 - t;
    int move_x = (x2 - x);
    if (move_x < 0) move_x *= -1;
    int move_y = (y2 - y);
    if (move_y < 0) move_y *= -1;

    if (move_x + move_y > time) {
      result = false;
    } else {
      if ((move_x + move_y) % 2 == time % 2) {
        t = t2;
        x = x2;
        y = y2;
        continue;
      }
      result = false;
    }
  }
  if (result) {
    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,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
const ll inf = 1e18;
ll d[305][305],f[305][305];
int main(){
    int n,m,l; cin >> n >> m >> l;
    vector<ll> a(m),b(m),c(m);
    rep(i,m) {cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--;}
    int q; cin >> q;
    vector<ll> s(q),t(q);
    rep(i,q) {cin >> s[i] >> t[i]; s[i]--; t[i]--;}
    
    rep(i,n){
        rep(j,n){
            d[i][j] = inf;
            f[i][j] = inf;
        }
    }

    rep(i,n) {d[i][i] = 0; f[i][i] = 0;}

    rep(i,m) {d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]); d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);}

    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    rep(i,n){
        rep(j,n){
            if(i == j) continue;
            if(d[i][j] <= l) f[i][j] = min(d[i][j], 1LL);
        }
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
            }
        }
    }

    rep(i,q){
        if(f[s[i]][t[i]] < inf) cout << f[s[i]][t[i]]-1 << endl;
        else cout << "-1" << endl;
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
  vector<int> kaibunNums;
  for (int n = 1; n < 10002; ++n) {
    stringstream ss;
    ss << n;
    const string & num = ss.str();
    if (equal(num.begin(), num.end(), num.rbegin())) {
      kaibunNums.push_back(n);
    }
  }

  int input;
  while (cin >> input) {
    vector<int>::iterator lb = lower_bound(kaibunNums.begin(), kaibunNums.end(), input);

    if (*lb == input) {
      cout << input;
    } else if (abs(*lb - input) < abs(*(lb - 1) - input)) {
      cout << *lb;
    } else {
      cout << *(lb - 1);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1244
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		while (sc.hasNext()) {
			String s = sc.next();
			String t = sc.next();
			if (s.length() > t.length()) {
				String tmp = s;
				s = t;
				t = tmp;
			}
			t += "_" + t;
			int max = 0;
			for (int i = 0; i < t.length(); i++) {
				int match = 0;
				for (int j = 0; j < s.length() && j + i < t.length(); j++) {
					if (s.charAt(j) == t.charAt(j + i)) match++;
					else  match = 0;
					max = Math.max(max, match);
				}
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define repmap(mp) for(auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

ll primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

signed main(){
	ll n;
	cin >> n;
	
	
	map<ll, ll> mp;
	reppp(i, 2, n){
		ll m = i;
		repp(j, 168){
			ll p = primes[j];
			while(m % p == 0){
				mp[p]++;
				m /= p;
				if(m == 1) break;
			}
		}
	}
	
	ll ans = 1;
	repmap(mp){
		ans *= 1 + (itr->second);
		if(ans >= MOD) ans %= MOD;
	}
	cout << ans;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    String S = sc.next(); 
    if (x >= S.length()){
      System.out.println(S);
    }else{
      System.out.println(S.substring(0,x)+"...");
    }
  }
}


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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using pii = pair<int, int>; using vi = vector<int>;
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

bool f(string s) {
	rep(i, 0, s.size() - 1)
		if (s[i] != s[i + 1])return false;
	return true;
}

signed main() {
	for (string s; cin >> s&&s != "0";) {
		map<string, int> m;
		m[s] = 0;
		queue<string> q;
		q.emplace(s);
		while (!q.empty()) {
			string t = q.front(); q.pop();
			rep(i, 0, t.size() - 1) {
				if (t[i] == t[i + 1])continue;
				string tmp = t;
				if (t[i] + t[i + 1] == 'r' + 'g')tmp[i] = tmp[i + 1] = 'b';
				if (t[i] + t[i + 1] == 'g' + 'b')tmp[i] = tmp[i + 1] = 'r';
				if (t[i] + t[i + 1] == 'b' + 'r')tmp[i] = tmp[i + 1] = 'g';

				if (m.find(tmp) == m.end()) {
					q.emplace(tmp);
					m[tmp] = m[t] + 1;
				}
			}
		}

		int ans = INF;
		for (auto itr = m.begin(); itr != m.end(); itr++) {
			if (f(itr->first))ans=min(ans,itr->second);
		}
		if (ans == INF)cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}

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

using ll = uint_fast64_t;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int inf = ~(1 << 31);
constexpr ll llinf = ~(1LL << 63);
constexpr int mod = 1e9 + 7;
constexpr ld pi = 3.14159265358979323846L;

constexpr int dy[4] = {0, 1, 0, -1};
constexpr int dx[4] = {1, 0, -1, 0};
struct Pos { int x, y; };

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()
#define DEBUG cerr << "DEBUG: DONE" << endl;

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    ll a, b, c;
    cin >> a >> b >> c;
    ll x, y;
    cin >> x >> y;

    ll c_only = max(x, y) * 2 * c;
    ll abc = min(x, y)*2*c + (x-min(x, y))*a + (y-min(x, y))*b;
    ll ab = x*a + y*b;

    cout << min(ab, min(c_only, abc)) << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  vi a;
  cin >> n;
  for (int i = 0 ; i < n ; i++) {
    int tmp;
    cin >> tmp;
    a.pb(tmp);
  }
  vi l;
  l.pb(a[0]);
  for (int i = 1 ; i < n ; i++) {
    if (l[l.size()-1] < a[i]) {
      l.pb(a[i]);
    } else {
      *lower_bound(begin(l), end(l), a[i]) = a[i];
    }
  }

  printf("%lu\n", l.size());

  return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b,k;cin>>a>>b>>k;
  set<int> st;
  for(int i=0;i<k;i++){
    int t = a+i;
    if(a<=t&&t<=b)st.insert(t);
  }
  for(int i=0;i<k;i++){
    int t = b-i;
    if(a<=t&&t<=b)st.insert(t);
  }
  for(auto t : st){
    cout<<t<<endl;
  }

  return 0;
}


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

int banyak, helth[55], maks;

int main (){
	cin>>banyak;
	for (int i=1; i<=banyak; i++){
		cin>>helth[i];
	}
	for (int i=1; i<=banyak; i++){
		for (int j=1; j<=banyak; j++){
			if (i==j){
				
			}
			else{
				maks+=helth[i]*helth[j];
			}
		}
	}
	cout<<maks/2<<endl;
}

Measured memory_bytes: 3556
def judge():
    cnt = 0  
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return True
    return False

N = int(input())

if judge():  
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

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

return 0;
}



Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
    int n, pm, pe, pj;
    char c;
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for(int i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                if (pm == 100 || pe == 100 || pj == 100 || (pm + pe) / 2 >= 90 || (pm + pe + pj) / 3 >= 80) {
                    c = 'A';
                } else if (((pm + pe + pj) / 3 >= 70) || ((pm + pe + pj) / 3 >= 50 && (pm >= 80 || pe >= 80))) {
                    c = 'B';
                } else {
                    c = 'C';
                }
                printf("%c\n", c);
            }
        }
    }
        return 0;
}

Measured memory_bytes: 1028
function main()
    a,b,c,k = reads(Int,Int,Int,Int)
    println(search(a,b,c,k) ? "Yes" : "No")
end

function search(a,b,c,k,l=0)
    if a < b < c
        return true
    end
    k == l && return false
    ans = false
    ans |= search(2a,b,c,k,l+1)
    ans |= search(a,2b,c,k,l+1)
    ans |= search(a,b,2c,k,l+1)
    return ans
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

using namespace std;

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  int l = 0, r = 0;
  while(l < N && S[l] == '<') l++;
  while(r < N && S[N-1-r] == '>') r++;
  cout << N - min(l, r) << endl;
  return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    ll h,w;
    cin>>h>>w;
    if(h%3==0 || w%3==0){
        cout<<0<<endl;
        return 0;
    }
    
    ll ans=LINF;
    
    ans=min({ans,h,w});
    
    rep(i,1,w){
        ans=min(ans,max({h*i,(w-i)*(h/2),(w-i)*((h+1)/2)})-min({h*i,(w-i)*(h/2),(w-i)*((h+1)/2)}));
    }
    
    rep(i,1,h){
        ans=min(ans,max({w*i,(h-i)*(w/2),(h-i)*((w+1)/2)})-min({w*i,(h-i)*(w/2),(h-i)*((w+1)/2)}));
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

int main() {
    int N, K;
    cin >> N >> K;
    ll ans = 0;

    if(K % 2 == 1) {
        //全てKの倍数
        ll x = N / K;
        ans += x * x * x;
    }
    else {
        //全てKの倍数
        ll x = N / K;
        ans += x * x * x;
        //nをkで割ったあまりがk/2の倍数
        ll y = (N / (K/2)) - (N / K);
        ans += y * y * y;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3616