akhauriyash/Code-Regression huggingface dataset:
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int n;
int dp[100100];
int arr[100100];



int mydp(int i)
{
    if(i>=n)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int ret1=INF,ret2=INF;
    if(i+2<=n)
    {
        ret1=abs(arr[i+2]-arr[i])+mydp(i+2);
    }
    if(i+1<=n)
    {
        ret2=abs(arr[i+1]-arr[i])+mydp(i+1);
    }
    dp[i]=min(ret1,ret2);
    return dp[i];
}
int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif
  cin>>n;
  for(int i=1;i<=n;i++)
  {
      cin>>arr[i];
  }
  memset(dp,-1,sizeof dp);
  int ans=mydp(1);
  cout<<ans<<endl;


}



Measured memory_bytes: 7452
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> beauty(n);
    for (int i = 0; i < n; i++)cin >> beauty[i];
    vector<int> limit(n, 1145141919);
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        limit[r] = min(limit[r], l);
    }

    for (int i = n - 1; i >= 0; i--) {
        limit[i] = min(limit[i], i);
        if (i < n - 1)limit[i] = min(limit[i], limit[i + 1]);
    }

    vector<ll> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        dp[i] = max(dp[i - 1], dp[limit[i - 1]] + beauty[i - 1]);
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 6732
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n;
    cin >> n;
    if(n < 1200){
        cout << "ABC" << endl;
    }else if(n >= 1200 && n < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
l=list(map(int,input().split()))
N=l[0]
K=l[1]
L=list(map(int,input().split()))
a=L[0]
v=0
X=[]
Y=[]
for i in range(N):
    X.append(0)
    Y.append(0)
X[0]=1
Y[0]=0
for i in range(K):
    b=a
    if X[b-1]==1:
        k1=Y[b-1]
        k2=i+1-k1
        v=1
        a=L[a-1]
        break
    X[a-1]+=1
    Y[a-1]=i+1
    a=L[a-1]
    
if v==1:
    K=(K-k1)%k2
    for i in range(K):
        b=a
        a=L[a-1]


print(b)



    



Measured memory_bytes: 107344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    string s; cin >> s;
    ll n = s.size();
    ll cnt[26];
    rep(i,26) cnt[i] = 0;
    rep(i,n) cnt[s[i]-'a']++;
    ll ans = 1 + (n * (n-1)) / 2;
    rep(i,26){
        ll m = cnt[i];
        ans -= (m * (m-1))/2;
    }
    cout << ans << endl;
}

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

int main(){
	int n[10], m[10];
	string in;
	while( getline(cin, in), in.length() ){
		for( int i=0; i<10; i++ )
			n[i] = in[i]-'0';
		for( int i=8; i>=0; i-- ){
			for( int j=0; j<=i; j++ ){
				m[j] = (n[j] + n[j+1]) % 10;
			}
			for( int j=0; j<10; j++ ){
				n[j] = m[j];
			}
		}
		cout << n[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << OF64 << sqrt(pow(c - a, 2) + pow(d - b, 2)) << endl;
	return 0;
}


Measured memory_bytes: 3296
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    int n;
    cin >> n;
    unsigned long long a[n];
    bool zero=false;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0) zero=true;
    }
    unsigned long long mul=1;
    if(zero){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/mul){
            mul *= a[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << mul << endl;
    return 0;
}

Measured memory_bytes: 3916
s = input()
head = int(s[:2])
tail = int(s[2:])

head_M = 1 <= head <= 12
tail_M = 1 <= tail <= 12

if head_M and tail_M:
  ret = 'AMBIGUOUS'
elif head_M:
  ret = 'MMYY'
elif tail_M:
  ret = 'YYMM'
else:
  ret = 'NA'
print(ret)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

vector<int> g[100010];
map<pair<int,int>,int> mp;
int ans[100010];

void dfs(int now,int par,int pre){
  int num=1;
  for(auto nex:g[now]){
    if(nex==par) continue;
    if(num==pre) num++;
    int a=now,b=nex;
    if(a>b) swap(a,b);
    ans[mp[mkp(a,b)]]=num;
    dfs(nex,now,num);
    num++;
  }
}

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  rep(i,N-1) cin>>A[i]>>B[i];

  for(int i=0;i<N-1;i++){
    A[i]--;B[i]--;
    g[A[i]].push_back(B[i]);
    g[B[i]].push_back(A[i]);
    mp[mkp(A[i],B[i])]=i;
  }

  int K=0;
  rep(i,N) K=max(K,(int)g[i].size());

  int st=0;
  for(int i=0;i<N;i++) if(g[i].size()==1) st=i;
  dfs(st,-1,-1);

  cout<<K<<endl;
  for(int i=0;i<N-1;i++){
    cout<<ans[i]<<endl;
  }



  return 0;
}


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

#define pb push_back
using ll = long long;
using i7 = __int128;
vector <i7> v;

int cnt[30][2];

i7 p10[30];

ll dfs(int x, int n, i7 d) {
	i7 s = 0;
	for(int i = x; i < n; i ++)
		s += v[i];
	s = 9 * s;
	if(d > s || d < -s) return 0;
	if(x == n) return 1;

	ll r = 0;
	for(int i = -9; i <= 9; i ++) {
		if(x == 0)
			r += dfs(x + 1, n, d - i * v[x]) * cnt[i + 10][1];
		else
			r += dfs(x + 1, n, d - i * v[x]) * cnt[i + 10][0];
	}
	return r;
}

int main() {
	p10[0] = 1;
	for(int i = 1; i < 30; i ++)
		p10[i] = p10[i - 1] * 10;

	for(int i = 0; i < 10; i ++)
		for(int j = 0; j < 10; j ++)
			cnt[j - i + 10][0] ++;
	for(int i = 1; i < 10; i ++)
		for(int j = 0; j < 10; j ++)
			cnt[j - i + 10][1] ++;

	int _d; cin >> _d;
	i7 d = _d;

	ll ans = 0;
	for(int n = 2; n <= 20; n ++) {
		v.clear();
		for(int i = 1; i * 2 <= n; i ++)
			v.pb(p10[n - i] - p10[i - 1]);
		//for(i7 x : v) cout << int(x) << '\n';
		if(n & 1)
			ans += dfs(0, v.size(), d) * 10;
		else
			ans += dfs(0, v.size(), d);
	}
	cout << ans << '\n';
}

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


#define ll long long int
#define pb push_back
#define F first
#define S second 
#define f(i,n) for(int i = 0; i < n; i++)
using namespace std;
    // n   sum


bool solve(int n,int k, int a[])
{
  bool dp[k+1];
 // memset(dp,false,sizeof(dp));
  
  for(int j = 0; j <= k ; j++)
  { dp[j] = false;
    for(int i = 0; i < n; i++)
    {
      if(j >= a[i] && !dp[j - a[i]])
        dp[j] = true;
    }
  }
  return dp[k];
}







int main()
{
 
     #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
     //soe();
     int n,k; cin>>n>>k;
     int a[n];
     
     f(i,n)
       cin>>a[i];
     
      
     
     solve(n,k,a)?cout<<"First"<<endl:cout<<"Second"<<endl;

     return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#include <algorithm>

int c[100001];

int main() {
  long long int n;
  long long int count = 0;
  std::cin >> n;
  for (int i = 0; i < 100001; ++i)
    c[i] = 0;
  for (long long int i = 0; i < n; ++i) {
    int x = 0;
    std::cin >> x;
    if (x >= 100001) {
      count++;
      continue;
    }   
    c[x]++;
  }
  for (int i = 1; i < 100001; ++i) {
    count += (c[i] < i) ? c[i]: c[i] - i;
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	if (a + b == 15)
		printf("+\n");
	else if (a*b == 15)
		printf("*\n");
	else
		printf("x\n");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 1000000

int main()
{
  int i,j,key,n,q,cnt=0,left=0,right=0,mid=0,S[N],T[N]/*,swap,flag=1*/;

  scanf("%d",&n);
  for(i=0;i<n;i++)
      scanf("%d",&S[i]);

  /*
  while(flag)
    {
      flag = 0;
      for(j=n-1;j>=1;j--)
	{
	  if(S[j] < S[j-1])
	    {
	      swap = S[j];
	      S[j] = S[j-1];
	      S[j-1] = swap;
	      flag = 1;
	    }
	}
    }
  */
  
  scanf("%d",&q);
  i = 0;
  while(i<q)
    {
      scanf("%d",&T[i]);
      for(j=0;j<i;j++)
	if(T[i] == T[j]) break;
      if(i == j) i++;
    }

 
  for(i=0;i<q;i++)
    {
      left = 0;
      right = n;
      key = T[i];
      while(left < right)
	{
	  mid = (left+right)/2;
	  if(S[mid] > key) right = mid;
	  else if(S[mid] < key) left = mid + 1;
	  else
	    {
	      cnt++;
	      break;
	    }
	}
    }
	
	printf("%d\n",cnt);
    return 0;
}






Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> 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 = j + (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;
  return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  LL a,b;
  cin >> a >> b;
  if(a==b){
    cout << 1 << endl;
    return 0;
  }
  int i=60;
  for(;(a&(1ll<<i))==(b&(1ll<<i));i--);
  if(i==0){
    cout << 2 << endl;
    return 0;
  }
  i--;
  LL ans=(1ll<<(i+1))-(((1ll<<(i+1))-1)&a);
  while(1){
    if(b&(1ll<<i)){
      cout << ans+(1ll<<(i+1)) << endl;
      return 0;
    }else{
      if(a&(1ll<<i)){
        ans+=(1ll<<(i+1))-(((1ll<<(i+1))-1)&a);
        for(;i>=0;i--){
          if(b&(1ll<<i)){
            cout << ans+(1ll<<(i+1)) << endl;
            return 0;
          }
        }
        cout << ans+1 << endl;
        return 0;
      }else{
        if(i==0){
          cout << ans+2 << endl;
          return 0;
        }else{
          ans+=1ll<<i;
          i--;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import copy
a = [int(c) for c in input().split()]
K = a[0]
N = a[1]
A = [int(c) for c in input().split()]
B = list(map(lambda x: x+K,copy.deepcopy(A)))
A = A+B
l = 0
tmp = 0
cnt = 0
for i in range(N):
    tmp = A[i+1]-A[i]
    if tmp > l :
        cnt = i
        l = tmp

print(K-l)


Measured memory_bytes: 33168
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 1e9
for i in range(n - k + 1):
    if x[i + k - 1] < 0:
        t = -x[i]
    elif 0 < x[i]:
        t = x[i + k - 1]
    else:
        t = -x[i] + x[i + k - 1] +  min(-x[i], x[i + k - 1])
    ans = min(ans, t)
print(ans)

Measured memory_bytes: 62576
use std::collections::HashMap;

fn colorize_edges(vertices: &mut Vec<HashMap<usize, usize>>) {
    let mut q = std::collections::VecDeque::new();
    q.push_front((0, 0));

    loop {
        if let Some((v0, used_color)) = q.pop_back() {
            let mut usable_color_min = 1;
            let v1s = vertices[v0].keys().map(|x| *x).collect::<Vec<_>>();

            for &v1 in v1s.iter() {
                let &color = vertices[v0].get(&v1).unwrap();
                if color == 0 {
                    if usable_color_min == used_color {
                        usable_color_min += 1;
                    }

                    vertices[v0].insert(v1, usable_color_min);
                    vertices[v1].insert(v0, usable_color_min);

                    q.push_front((v1, usable_color_min));
                    usable_color_min += 1;
                }
            }
        } else {
            break;
        }
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut edges = Vec::new();
    for _ in 0..(n-1) {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let edge = buf.split_whitespace()
            .map(|x| x.parse::<usize>().unwrap())
            .collect::<Vec<_>>();

        edges.push((edge[0], edge[1]));
    }

    let mut k = 0usize;
    let mut vertices = vec![HashMap::new(); n];
    for edge in edges.iter() {
        let (v0, v1) = (edge.0-1, edge.1-1);

        vertices[v0].insert(v1, 0);
        vertices[v1].insert(v0, 0);

        k = std::cmp::max(k, vertices[v0].len());
        k = std::cmp::max(k, vertices[v1].len());
    }

    colorize_edges(&mut vertices);

    println!("{}", k);
    for edge in edges.iter() {
        let (v0, v1) = (edge.0-1, edge.1-1);
        println!("{}", vertices[v0].get(&v1).unwrap());
    }
}


Measured memory_bytes: 86396
<?php
$a = '1:';
$b = '2:';
$c = '3:';
$d = '4:';
$e = '5:';
$f = '6:';

$count = trim(fgets(STDIN));
for ($i = 0; $i < $count; $i++) {
    $t = trim(fgets(STDIN));
     switch($t) {
         case $t < 165.0:
             $a .= '*';
             break;
        case 165.0 <= $t && $t < 170.0:
             $b .= '*';
             break;
        case 170.0 <= $t && $t < 175.0:
             $c .= '*';
             break;
        case 175.0 <= $t && $t < 180.0:
             $d .= '*'; 
             break;
        case 180.0 <= $t && $t < 185.0:
             $e .= '*';
             break;
        case 185.0 <= $t:
             $f .= '*';
             break;
     }
}
echo $a . PHP_EOL;
echo $b . PHP_EOL;
echo $c . PHP_EOL;
echo $d . PHP_EOL;
echo $e . PHP_EOL;
echo $f . PHP_EOL;



Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 3500;

map <ll,ll> mp;

int main()
{
    for(ll i=0; i<sz; i++) {
        ll n = 1;
        for(int j=0; j<5; j++) n *= i;
        mp[n] = i;
    }

    ll x;
    cin >> x;
    for(ll i=0; ; i++) {
        ll n = 1;
        for(int j=0; j<5; j++) n *= i;
        n -= x;
        bool neg = 0;
        if(n < 0) neg = 1, n = 0-n;

        if(mp.find(n) != mp.end()) {
            ll y = mp[n];
            if(neg) y *= -1;
            printf("%lld %lld\n", i, y);
            break;
        }
    }
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll N,K;cin>>N>>K;
  string S;cin>>S;

  // ひっくり返す範囲はどこかの連続した0
  // 単純にひっくり返せる数が多ければいいわけではなく、結果としての長さ
  // 連続した1の数の島をカウントしていって、Kの数だけ繋げられるとする
  deque<int> row;
  char prevch;
  REP(i,N) {
    if (S[i]==prevch) {
      row[row.size()-1]++;
    } else {
      prevch = S[i];
      row.push_back(1);
    }
  }

  // 条件を統一するために、1から始まって1で終わると設定する
  if (S[0]=='0') row.push_front(0);
  if (S.back()=='0') row.push_back(0);
  int row_size = row.size();

  // もしK回で十分繋げられるなら全部
  if ((row_size-1)/2<=K) {
    OUT(N);
    return 0;
  }

  int tmp = 0;
  REP(i,K*2+1) tmp += row[i];
  int ans = tmp;
  for (int i=2;i<row_size-K*2;i+=2) {
    tmp -= row[i-2];
    tmp -= row[i-1];
    tmp += row[i+K*2];
    tmp += row[i+K*2-1];
    ans = max(ans,tmp);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 768
from sys import exit
n, m = map(int, input().split())
a = list(map(int, input().split()))

odd = []
even = []
for x in a:
	if x%2 == 0:
		even.append(x)
	else:
		odd.append(x)

if n%2 == 0:
	if len(odd) > 2:
		print("Impossible")
		exit()
	if len(odd) == 2:
		a = [odd[0]] + even + [odd[1]]
		b = [odd[0]+1] + even + [odd[1]-1]
		if b[-1] == 0:
			b.pop()
	else:
		a = even
		b = [1] + even
		b[-1] -= 1
		if b[-1] == 0:
			b.pop()

else:
	if len(odd) > 1:
		print("Impossible")
		exit()
	if m == 1:
		b = [1, n-1]
	else:
		a = odd + even
		b = [odd[0]+1] + even
		b[-1] -= 1
	if b[-1] == 0:
		b.pop()

print(*a)
print(len(b))
print(*b)

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

const int N=100005;
int n,k;
ll ans;
int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>k;
	for(int b=1;b<=n;b++) {
		for(int x=0;1ll*x*b+k<=n;x++) {
			int tk=max(k,1-x*b);
//			cerr<<x<<"*"<<b<<"="<<x*b<<" delta="<<max(0,min(n-x*b-tk+1,b-tk))<<" delta2=";
			ans+=max(0,min(n-x*b-tk+1,b-tk));
//			int cnty=0;
//			for(int y=k;y+x*b<=n&&y<b;y++) {
//				int a=x*b+y;
//				if (a%b==k&&a<=n) cnty++;
//			}
//			cerr<<cnty<<"\n";
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n,k=map(int, input().split())
    h=list(map(int, input().split()))
    cnt=0
    for hk in h:
        if hk>=k:cnt+=1
    print(cnt)

main()

Measured memory_bytes: 11896
# Binary Indexed Tree (Fenwick Tree)
class BIT():
    """一点加算、区間取得クエリをそれぞれO(logN)で答える
    add: i番目にvalを加える
    get_sum: 区間[l, r)の和を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目にvalを加える"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)


from operator import itemgetter
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**18


for bit_state in range(1 << n):
    pattern = [[] for i in range(2)]
    for i in range(n):
        if bit_state & (1 << i) and i % 2 == 0:
            pattern[0].append(a[i]*100 + i)
        elif bit_state & (1 << i) and i % 2 == 1:
            pattern[1].append(a[i]*100 + i)
        elif i % 2 == 0:
            pattern[1].append(b[i]*100 + i)
        else:
            pattern[0].append(b[i]*100 + i)

    if len(pattern[0]) == len(pattern[1]) or len(pattern[0]) - 1 == len(pattern[1]):
        for i in range(2):
            pattern[i] = sorted(pattern[i])
        bit = BIT(n)
        ans_tmp = 0
        prev_num = 10**8
        for i in range(n)[::-1]:
            pal = i % 2
            num = pattern[pal].pop()
            ind = num % 100
            num = num // 100
            if prev_num < num:
                break
            prev_num = num
            bit.add(ind, 1)
            ans_tmp += bit.get_sum(0, ind)
        else:
            ans = min(ans, ans_tmp)

if ans == 10**18:
    print(-1)
else:
    print(ans)


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

int main()
{
  int n;
  cin >> n;
  int a[n],b[n],c[n],dp[n][3];
  for (int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];
  dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
  for (int i=1; i<n; i++)
  {
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i];
  }
  cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int maxn=105,INF=0x3FFFFFFF;
int n,m,f[maxn][maxn][maxn][maxn],g[maxn][maxn];
char mat[maxn][maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",mat[i]+1);
	for (int i=0;i<=n;i++)
		for (int j=0;j<=m;j++)
		{
			g[i][j]=INF;
			for (int k=0;k<=i;k++)
				for (int l=0;l<=j;l++)
					f[i][j][k][l]=INF;
		}
	if (mat[1][1]=='.')
		f[1][1][0][0]=f[1][1][0][1]=f[1][1][1][0]=g[1][1]=0; else
		f[1][1][1][1]=g[1][1]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		{
			if (i==1 && j==1) continue;
			if (mat[i][j]=='.')
			{
				f[i][j][0][0]=g[i][j]=min(g[i][j-1],g[i-1][j]);
				for (int k=1;k<=i;k++) f[i][j][k][0]=g[i][j];
				for (int l=1;l<=j;l++) f[i][j][0][l]=g[i][j];
			} else
			{
				f[i][j][1][1]=g[i][j]=min(g[i-1][j],g[i][j-1])+1;
				for (int k=2;k<=i;k++)
				{
					f[i][j][k][1]=min(f[i-1][j][k-1][1],g[i][j-1]+1);
					g[i][j]=min(g[i][j],f[i][j][k][1]);
				}
				for (int l=2;l<=j;l++)
				{
					f[i][j][1][l]=min(f[i][j-1][1][l-1],g[i-1][j]+1);
					g[i][j]=min(g[i][j],f[i][j][1][l]);
				}
				for (int k=2;k<=i;k++)
					for (int l=2;l<=j;l++)
					{
						f[i][j][k][l]=min(f[i-1][j][k-1][l],f[i][j-1][k][l-1]);
						g[i][j]=min(g[i][j],f[i][j][k][l]);
					}
			}
		}
	printf("%d\n",g[n][m]);
	return 0;
}


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

vector<int> vi;

int main(){
   int n,k;
   scanf("%d%d",&n,&k);
   for(int i=0;i<n;i++){
    int s;
    scanf("%d",&s);
    vi.push_back(s);
   }
   for(int i=0;i+k<n;i++){
    printf("%s\n",vi[i]<vi[i+k]?"Yes":"No");
   }
   return 0;
}


Measured memory_bytes: 4348
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int selectionSort(vector<int> &A, int N){
    int count = 0;
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]) minj = j;
        }
        if(minj != i){
            swap(A[i], A[minj]);
            count++;
        }
    }
    return count;
}

int main(){
    int N;
    scanf("%d", &N);
    vector<int> A(N);
    rep(i, N) scanf("%d", &A[i]);
    int count = selectionSort(A, N);
    rep(i, N){
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", count);
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	map<string, int> cnt;
	REP(i,N) {
		string s; cin >> s;
		cnt[s] += 1;
	}
	cout << "AC x " << cnt["AC"] << endl;
	cout << "WA x " << cnt["WA"] << endl;
	cout << "TLE x " << cnt["TLE"] << endl;
	cout << "RE x " << cnt["RE"] << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3660
#include <iostream>

#define swap(type, x, y) do { type t = x; x = y; y = t; } while (0)
using namespace std;

void quick(long long a[], int b[], int left, int right);

int main(void){
  int n, m;
  int b[100000];
  long long a[100000];
  long long sum = 0;
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  quick(a, b, 0, n-1);
  for(int i = 0; i < n; i++){
    if(b[i] < m){
      m -= b[i];
      sum += a[i]*(long long)b[i];
    }
    else if(m == 0)
      break;
    else{
      sum += a[i]*(long long)m;
      m = 0;
      break;
    }
  }
  cout << sum << endl;
}

void quick(long long a[], int b[], int left, int right)
{
    int pl = left;                /* 左カーソル */
    int pr = right;                /* 右カーソル */
    long long x = a[(pl + pr) / 2];    /* 枢軸は中央の要素 */

    do {
        while (a[pl] < x) pl++;
        while (a[pr] > x) pr--;
        if (pl <= pr) {
            swap(long long, a[pl], a[pr]);
            swap(int, b[pl], b[pr]);
            pl++;
            pr--;
        }
    } while (pl <= pr);

    if (left < pr)  quick(a, b, left, pr);
    if (pl < right) quick(a, b, pl, right);
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;

int N;
int a[100010];
int b[100010];
int K = 0;
vector<vector<int> > V;
map<pair<int, int>, int> mt;
queue<pair<int, int> > Q;

void bfs(int x, int y){
    int v, w;
    mt[make_pair(x, y)] = 1;
    mt[make_pair(y, x)] = 1;
    Q.push(make_pair(x, y));
    
    while(!Q.empty()){
        v = Q.front().first;
        w = Q.front().second;
        Q.pop();
        
        bool used[K+1];
        for(int i = 0; i <= K; i++) used[i] = false;
        used[mt[make_pair(v, w)]] = true;
        for(int j = 0; j < V[w].size(); j++){
            if(V[w][j] == v) continue;
            int nv = w;
            int nw = V[w][j];
            Q.push(make_pair(nv, nw));
            
            for(int k = 1; k <= K; k++){
                if(!used[k]) {
                    mt[make_pair(nv, nw)] = k;
                    mt[make_pair(nw, nv)] = k;
                    used[k] = true;
                    break;
                }
            }
        }
    }
}

int main(void){
    // Your code here!
    cin >> N;
    V.resize(N);
    for(int i = 0; i < N-1; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        V[a[i]].push_back(b[i]);
        V[b[i]].push_back(a[i]);
    }
    
    for(int i = 0; i < N; i++) {
        int hoge = V[i].size();
        K = max(K, hoge);
    }

    int root = -1;
    for(int i = 0; i < N; i++) {
        if(V[i].size() == 1){
            root = i;
            break;
        }
    }
    bfs(root, V[root][0]);
    
    cout << K << endl;
    
    for(int i = 0; i < N-1; i++){
        cout << mt[make_pair(a[i], b[i])] << endl;
    }
}


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

const long long oo = 1e15;
long long a[3005];
bool c[3005][3005];
long long f[3005][3005];
int n;

void inp()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
}

///t == 1 -> maximizing (X - Y) and vice versa
long long tryyy(int t,int l,int r)
{
    if (l > r) return 0;
    if (c[l][r]) return f[l][r];
    long long tmp;
    if (t == 1)
    {
        tmp = tryyy(1-t, l , r - 1) + a[r];
        tmp = max(tmp, tryyy(1-t, l + 1, r) + a[l]);
    }
    else
    {
        tmp = tryyy(1 - t, l, r - 1) - a[r];
        tmp = min(tmp , tryyy(1-t, l + 1, r) - a[l]);
    }
    c[l][r] = true;
    f[l][r] = tmp;
    return tmp;
}


int main()
{
    //freopen("file.inp","r",stdin);
    inp();
    cout << tryyy(1,1,n);
    return 0;
}


Measured memory_bytes: 79744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  cout << (a + b >= c ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b;
	for (int i = 0; i < 4; ++i) {
		cin >> a >> b;
		switch (a) {
		case 1:
			cout << b * 6000 << endl;
			break;
		case 2:
			cout << b * 4000 << endl;
			break;
		case 3:
			cout << b * 3000 << endl;
			break;
		case 4:
			cout << b * 2000 << endl;
		}
	}
}


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

int main(void){
    string s;
    string t;
    cin >> s >> t;
    vector<bool> ls(26), lt(26);
    for(char c : s) ls[c - 'a'] = true;
    for(char c : t) lt[c - 'a'] = true;
    for(int i = 0; i < 26; i++) if(!ls[i] && lt[i]){
        cout << -1 << endl;
        return 0;
    }
    vector<vector<ll>> pos(26, vector<ll>(s.length() + 1, -1));
    for(int i = 0; i < s.length(); i++){
        pos[s[i] - 'a'][i] = i;
    }
    for(int i = s.length() - 1; i >= 0; i--){
        for(int j = 0; j < 26; j++){
            if(pos[j][i] == -1) pos[j][i] = pos[j][i + 1];
        }
    }
    ll q = 0;
    ll c = 0;
    for(int i = 0; i < t.length(); i++){
        int m = t[i] - 'a';
        if(pos[m][c] == -1){
            q++;
            c = 0;
        }
        c = pos[m][c] + 1;
    }
    cout << q * s.length() + c << endl;
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  int n; cin >> n;
  vector<int> sum(10000+1);
  for(int i = 0; i <= 10000; ++i) sum[i] = i*(i+1)/2;
  auto it = lower_bound(ALL(sum), n);
  auto lim = distance(sum.begin(), it);

  for(int i = 1; i <= lim; ++i) {
    if(i == *it-n) continue;

    cout << i << endl;
  }
}


Measured memory_bytes: 3652
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    int N;
    LL H;
    GI(N);GLL(H);
    vector<LL> A(N);
    vector<LL> B(N);
    REP(i,N){
        GLL(A[i]);GLL(B[i]);
    }
    sort(ALL(A));
    sort(ALL(B));
    LL ans = 0;
    for(int i=N-1;0<=i;i--){
        if(B[i] <= A[N-1]||H<=0)
            break;
        ans++;
        H-=B[i];
    }
    if(0<H){
        ans += (H+A[N-1]-1)/A[N-1];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
string s;
int main()
{
//	freopen("1580.in","r",stdin);
//	freopen("1580.out","w",stdout);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int x[3];

    for(int i = 0; i < 3; i++) {
        scanf("%d", &x[i]);
    }
    
    int cnt = 0;
    if(x[0] == x[1] && x[1] == x[2] && x[0] == x[2]) {
        printf("1");
    } else if(x[0] != x[1] && x[1] != x[2] && x[0] != x[2]) {
        printf("3");
    } else {
        printf("2");
    }

    return 0;
}

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

int main(){
	int n, d;
	cin >> n >> d;
	
	//use 2d array
	//vector<vector<int>> x(n, vector<int>(d));
	int x[n][d];
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> x[i][j];
		}
	}
	
	int ans=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int norm=0;
			for(int k=0; k<d; k++){
				int diff = abs(x[i][k]-x[j][k]);
				norm += diff*diff;
			}
			
			bool flag=false;
			for(int k=0; k<=norm; k++){
				if(k*k==norm) flag = true;
			}
			
			if(flag) ans++;
		}
	}
	cout << ans << endl;
}

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

A, B, M = map(int, input().split())

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
m = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)
for x in m:
    ans = min(ans, a[x[0] - 1] + b[x[1] - 1] - x[2])

print(ans)


Measured memory_bytes: 38436
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
int count_bit(int a)
{
    n=0;
    while(a!=0)
    {
        if(a%2!=0)
        {
            n++;
        }
        a=a/2;
    }
}
int32_t main()
{
      int b;
      cin>>b;
      int a[b][b];
      int i,j,mo=1000000007;
      for(i=0;i<b;i++)
      {
          for(j=0;j<b;j++)
          {
              cin>>a[i][j];
          }
      }
      int x=1<<b;
      int dp[x];//
      for(i=0;i<x;i++)
      {
          dp[i]=0;
      }
      int co[x];
      for(i=0;i<x;i++)
      {
          count_bit(i);
          co[i]=n;
      }
      for(j=0;j<b;j++)
      {
          for(i=0;i<x;i++)
          {
              if(co[i]==j)
              {
                  if(dp[i]!=0||i==0)
                  {
                      for(int k=0;k<b;k++)
                      {
                          if(a[j][k]==1)
                          {
                              if(j==0)
                              {
                                  dp[i|1<<k]=1;
                              }
                              else
                              {
                                  if((i&1<<k)==0)
                                  dp[i|1<<k]=(dp[i|1<<k]+dp[i])%mo;
                              }
                          }
                      }
                  }
              }
          }
      }
      cout<<dp[x-1];
}



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

using namespace std;

int main() {
int n,c=1;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i];
}
int flag;
for(int i=1;i<n;i++)
{
    flag=0;
    for(int j=0;j<=i;j++)
    {
        if(arr[j]>arr[i])
        {
            flag=1;
            break;
        }
    }
        if(flag==0)
            c++;
}
cout<<c;

}


Measured memory_bytes: 256
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, k]: number[] = tmp[0].split(" ").map(Number);
    const sList: string[] = tmp[1].split("");
    let prev: string = "";
    const countList: number[] = sList[0] == "0" ? [0] : [];
    let count: number = 0;
    let max: number = 0;
    for (let i = 0; i < n; ++i) {
      const s: string = sList[i];
      if (s == prev) {
        ++countList[countList.length - 1];
        ++count;
      } else if (s == "1") {
        countList.push(1);
        ++count;
      } else {
        countList.push(1);
        if (countList.length / 2 > k) {
          if (count > max) {
            max = count;
          }
          count -= countList.shift();
          count -= countList.shift();
        }
        ++count;
      }
      prev = s;
    }
    if (count > max) {
      max = count;
    }
    return `${max}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 14924
#include <bits/stdc++.h>
using namespace std;
int f[11] = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1};
int dp[2][2] = {};

int main() {
    string N; cin >> N;
    dp[0][0] = f[(int)(N[0] - '0')];
    dp[0][1] = f[(int)(N[0] - '0') + 1];
    for(int i=1; i<N.size(); ++i) {
        int k = (int)(N[i] - '0');
        dp[i&1][0] = min(dp[(i-1)&1][0] + k, dp[(i-1)&1][1] + 10 - k);
        dp[i&1][1] = min(dp[(i-1)&1][0] + k + 1, dp[(i-1)&1][1] + 9 - k);
    }
    cout << min(dp[(N.size()-1)&1][0], dp[(N.size()-1)&1][0]) << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

const ll M = 1e9+7;

void add(ll& x, ll y)
{
    x += y;
    x %= M;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string K;
    ll n, d;
    cin >> K >> d;
    n = K.size();
    V<int> k(n);
    rep(i,0,n) k[i] = K[i] - '0';
    // dp[x][y] - number of numbers with sum of i digits equal to x mod d (base 10)
    //               (y = 1 already small) (y = 0 not small by the moment)
    V<V<ll>> dp(d, V<ll>(2));
    rep(digit,0,k[0]+1) {
        ll a = digit % d;
        if (digit < k[0]) 
            ++dp[a][1];
        else // digit == k[0]
            ++dp[a][0];
    }
    rep(i,1,n) {
        V<V<ll>> ndp(d, V<ll>(2));
        rep(value,0,d) {
            rep(digit,0,10) {
                rep(already_small,0,2) {
                    if (not already_small and digit > k[i]) continue;
                    add(ndp[(value+digit)%d][already_small|(digit<k[i])], dp[value][already_small]);
                }
            }
        }
        dp = ndp;
    }
    cout << ((dp[0][0] + dp[0][1] - 1) % M + M) % M << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int n;
	long  int a;
	long int max, min, sum = 0;
	int i;

	scanf("%ld", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%ld", &a);

		//?????????
		if (i == 0)
		{
			max = a;
			min = a;
		}

		if (max < a)
			max = a;

		if (min > a)
			min = a;

		sum += a;
	}

	printf("%ld %ld %ld\n", min, max, sum);

	return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = 51;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C-min(A-B, C));
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    ans = 0
    for i in range(1,N+1):
        ans += i * (N+1-i)

    for _ in range(N-1):
        u,v = map(int,input().split())
        if u > v:
            u,v = v,u
        ans -= u * (N+1-v)

    print(ans)

main()

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

int n, m, a, b, ans = -1;
vector< int > dp( 1e5 + 5, -1 );
vector< vector< int > > adj( 1e5 + 5 );

int solve( int u )
{
	if( dp[ u ] != -1 )
	{
		return dp[ u ];
	}
	dp[ u ] = 0;
	for( int v : adj[ u ] )
	{
		dp[ u ] = max( dp[ u ], 1 + solve( v ) );
	}
	return dp[ u ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> m;
	for( int i = 1; i <= m; ++i )
	{
		cin >> a >> b;
		adj[ a ].emplace_back( b );
	}
	for( int i = 1; i <= n; ++i )
	{
		ans = max( ans, solve( i ) );		
	}
	cout << ans << "\n";
	return 0;
}

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

int main()
{
  int S, W;
  cin >> S >> W;
  
  if (S <= W)
  {
    printf("unsafe");
  }
  else
  {
    printf("safe");
  }

  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int N;
    cin >> N;
    int ans[N+1];
    for(int i=0;i<=N;i++)ans[i]=0;
    for(int i=1;i<101;i++){
        for(int j=1;j<101;j++){
            for(int k=1;k<101;k++){
                int v=i*i+j*j+k*k+i*j+j*k+k*i;
                if(v<=N){
                    ans[v]++;
                }
            }
        }
    }
    for(int i=1;i<=N;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   int a, b, k;
   cin >> a >> b >> k;
   vector<int> d;
   if(a>b) {
       a = a ^ b;
       b = a ^ b;
       a = a ^ b;
   }
   for(int i = 1; i <=a; i ++){
       if(a%i==0&&b%i==0){
           d.push_back(i);
       }
   }
    cout <<d[d.size()-k]<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List

main :: IO ()
main = do  
  input <- getContents 
  let strList = lines input
  let listSize = length strList - 1
  let num = [1..listSize]
  let listWithoutZero = take listSize strList 
  let answerTuple = zip num listWithoutZero
  mapM_ putStrLn $ map toCaseStr answerTuple


toCaseStr :: ((Int, String) -> String)
toCaseStr (x, y) = "Case " ++ show x ++ ": " ++ y

getInts = do 
  x <- getLine 
  let y = (map$toInt)$words x
  return y
  
toInt :: (String -> Int)
toInt x = read x :: Int


Measured memory_bytes: 6828