akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(int argc, char** argv) {
  int a, b;
  std::cin >> a >> b;
  int up = (a<b)?a:b;
  int down = (a>b)?a:b;
  if (up == 1 && down == 2) std::cout << "3\n";
  else if (up == 1 && down == 3) std::cout << "2\n";
  else std::cout << "1\n";
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string a,b;
    cin>>a>>b;
    int n=a.size();
    int m=b.size();
    vector< vector<int > > v(n+1,vector<int>(m+1));
    for(int i=0;i<=n;i++)
    {
      for(int j=0;j<=m;j++)
      {
          if(i==0||j==0)
          {
              v[i][j]=0;
          }
          else if(a[i-1]==b[j-1])
          {
              v[i][j]=v[i-1][j-1]+1;
          }
          else
          {
              if(v[i][j-1]>v[i-1][j])
              {
                  v[i][j]=v[i][j-1];
              }
              else
              {
                  v[i][j]=v[i-1][j];
              }
          }
      }
    }
    int i=n,j=m;
    string s="";
    while(i>0&&j>0)
    {
        if(a[i-1]==b[j-1])
        {
            s+=a[i-1];
            i--;
            j--;
        }
        else{
            if(v[i][j-1]>v[i-1][j])
            {
                j--;
            }
            else
            {
                i--;
            }
        }
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}


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

double dp[605][605], e[605];
vector<int> g[605], nx[605];

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int u, v;
		cin >> u >> v;
		g[v].push_back(u);
		nx[u].push_back(v);
	}
	e[n] = 0;
	for (int i = n - 1; i >= 1; i--) {
		e[i] = 1;
		for (auto v : nx[i]) {
			e[i] += e[v] / nx[i].size();
		}
	}
	for (int i = n - 1; i >= 1; i--) {	
		for (auto v : nx[i]) {
			for (int j = i + 1; j <= n; j++) {
				dp[i][j] += dp[v][j] / nx[i].size();
			}
		}
		dp[i][i] = 1;
	}
	double mn = 0;
	for (int i = 1; i <= n; i++) {
		if (nx[i].size() < 2) continue;
		for (auto v : nx[i]) {
			double minus = (e[i] - 1) * nx[i].size();
			minus -= e[v];
			//if (i == 1 && v == 2) cout << minus << endl;
			minus = minus / (nx[i].size() - 1) + 1 - e[i];
			//if (i == 1 && v == 2) cout << minus << endl;
			minus = minus * dp[1][i];
			//if (i == 1 && v == 2) cout << minus << endl;
			mn = min(mn, minus);
			
		}
	}
	cout << setprecision(10) << fixed << e[1] + mn;
	return 0;
}


Measured memory_bytes: 5376
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin >> n >> k;
	ll h[n];
	for(ll i=0; i<n; i++) cin >> h[i];

	vector<ll> dp(n,inf);
	dp[0]=0;
	for(ll i=0; i<n; i++){
		for(ll j=i+1; j<=i+k; j++){
			if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
		}
	}
	cout << dp[n-1];
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 1792
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200005;
const int MOD =1e9+7;
using mint = modint998244353;
//using mint = modint;
using S=int;
using F=int;
S op(S a,S b){
  return a+b;
}
S e(){
  return 0;
}
S mapping(F  f,S x){
  return f*x;
}
F composition(F f,F g){
  return f*g;
}
F id(){
  return 1;
}
signed main(){
int k;
string a="ACL";
cin>>k;
for(int i=0;i<k;i++)cout<<a;
cout<<endl;

}


Measured memory_bytes: 3608
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 3e5 + 100, T = 1e4 + 100, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 50, lg = 21;
typedef pair <int, int> pii;
pii p[N];

int32_t main() {
	use_fast;
	int n, d, a;
	cin >> n >> d >> a;
	for(int i = 0; i < n; i++) 
		cin >> p[i].ff >> p[i].ss;
	sort(p, p + n);
	set <pii> s;
	int sum = 0, ans = 0;
	for(int i = 0; i < n; i++) {
		while((int)s.size()) {
			pii t = *s.begin();
			if(t.ff < p[i].ff) {
				s.erase(t);
				sum -= t.ss;
				continue;
			}
			else 
				break;
		} 
		p[i].ss -= (a * sum);
		if(p[i].ss < 0)
			continue;
		p[i].ss = (p[i].ss + a - 1) / a;
		sum += p[i].ss;
		ans += p[i].ss;
		s.insert({p[i].ff + 2 * d, p[i].ss});
	}
	cout << ans << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

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

int h, w;
int m[16][16];

int n;
int sy, sx;

const int size = (1 << 23);
int dp[size];

int dfs(int y, int x, int b = (1 << n) - 1, int d = 0)
{
  if (b == 0){
    return (y == sy || x == sx);
  }

  int &ret = dp[b];
  ret = 0;
  for (int i = y - 1; i >= 0; i--){
    if (m[i][x] == -1) continue;
    if (b & (1 << m[i][x])){
      ret += dfs(i, x, b - (1 << m[i][x]), d * 10 + m[i][x]);
      break;
    }
  }
  for (int i = y + 1; i < h; i++){
    if (m[i][x] == -1) continue;
    if (b & (1 << m[i][x])){
      ret += dfs(i, x, b - (1 << m[i][x]), d * 10 + m[i][x]);
      break;
    }
  }
  for (int i = x - 1; i >= 0; i--){
    if (m[y][i] == -1) continue;
    if (b & (1 << m[y][i])){
      ret += dfs(y, i, b - (1 << m[y][i]), d * 10 + m[y][i]);
      break;
    }
  }
  for (int i = x + 1; i < w; i++){
    if (m[y][i] == -1) continue;
    if (b & (1 << m[y][i])){
      ret += dfs(y, i, b - (1 << m[y][i]), d * 10 + m[y][i]);
      break;
    }
  }

  return ret;
}

int main()
{
  while (cin >> w >> h, w){
    n = 0;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cin >> m[i][j];
        if (m[i][j] == 0) m[i][j] = -1;
        if (m[i][j] == 2) {
          sy = i; sx = j;
          m[i][j] = -1;
        }
        if (m[i][j] == 1) m[i][j] = n++;
      }
    }

    cout << dfs(sy, sx) << endl;
  }
}

Measured memory_bytes: 35868
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
	int key;
	struct node	*left, *right, *parent;
}node;

node *root_node, *NIL;

//copy from the notes
void insert(int k) {
	node* y = NIL, * x = root_node, * z;
	z = (node*)malloc(sizeof(node));
	z->key = k;	z->left = NIL;	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (k < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;

	if (y == NIL) root_node = z;
	else {
		if (k < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inOrder(node* input_node) {
	if (input_node == NIL)return;
	inOrder(input_node->left);
	printf(" %d", input_node->key); //from note put space before number
	inOrder(input_node->right);
}
void preOrder(node* input_node) {
	if (input_node == NIL)return;
	printf(" %d", input_node->key);
	preOrder(input_node->left);
	preOrder(input_node->right);
}

int main() {
	int i, size, number;
	scanf("%d", &size);
	char input[7];

	for (i = 0; i != size; i++) {
		scanf("%s", input);
		if (strcmp(input, "insert") == 0) {
			scanf("%d", &number);
			insert(number);
		}
		else {
			inOrder(root_node);
			printf("\n");
			preOrder(root_node);
			printf("\n");
		}
	}

	return 0;
}



Measured memory_bytes: 25136
fun main(args: Array<String>) {
    val d = readLine()!!.toInt()
    val msg = if(d == 25){
        "Christmas"
    } else if(d == 24){
        "Christmas Eve"
    } else if(d == 23){
        "Christmas Eve Eve"
    } else {
        "Christmas Eve Eve Eve"
    }
    println(msg)
}


Measured memory_bytes: 30076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std ;
using namespace __gnu_pbds;

typedef tree<
pair<int , int> ,
null_type,
less< pair<int , int> >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	ordered_set s ;
	for(int i = 0 ; i < n ; ++i)
		s.insert({arr[i] , i}) ;
	for(int i = 0 ; i < n ; ++i)
	{
		s.erase({arr[i] , i}) ;
		cout<<(*s.find_by_order(n/2-1)).first<<"\n";
		s.insert({arr[i], i}) ;
	}
	return 0 ;
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define fo(a,b) for (int i = a; i < b; i++) 
#define foi(a,b) for (int i = a; i <= b; i++) 
using namespace std;


typedef long long ll;
typedef unsigned long long ull;

int main ()  {

	int a, b;
	cin >> a >> b;

	if ((a%2==1) && (b%2==1)) cout << "Odd";
	else cout << "Even";
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
 
int main()
{
  int a,b;
  char c;
  cin>> a >> c >> b;
  if(c == '+') cout << a+b << endl;
  else cout << a-b << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int main(){

	char buf[16],work[16];
	int length,work_index;

	scanf("%s",buf);

	for(length = 0; buf[length] != '\0'; length++);

	int limit = pow(2,length),calc,maximum = 0,i_count,w_count,iwi_count;
	bool FLG;

	for(int i = 0; i < limit; i++){
		work_index = 0;
		for(int k = 0; k < length; k++){
			if(i & (1 << k)){
				work[work_index++] = buf[k];
			}
		}
		calc = work_index/2-1;
		FLG = true;
		for(int k = 0; k <= calc; k++){

			switch(work[k]){
			case '(':
				if(work[work_index-1-k] != ')'){
					FLG = false;
				}
				break;
			case ')':
				if(work[work_index-1-k] != '('){
					FLG = false;
				}
				break;
			case 'w':
				if(work[work_index-1-k] != 'w'){
					FLG = false;
				}
				break;
			case 'i':
				if(work[work_index-1-k] != 'i'){
					FLG = false;
				}
				break;
			case '[':
				if(work[work_index-1-k] != ']'){
					FLG = false;
				}
				break;
			case ']':
				if(work[work_index-1-k] != '['){
					FLG = false;
				}
				break;
			case '{':
				if(work[work_index-1-k] != '}'){
					FLG = false;
				}
				break;
			case '}':
				if(work[work_index-1-k] != '{'){
					FLG = false;
				}
				break;
			}
			if(!FLG)break;
		}
		if(work_index % 2 == 1 && work[(work_index-1)/2] != 'i' && work[(work_index-1)/2] != 'w')FLG = false;

		if(FLG){
			i_count = 0,w_count=0,iwi_count=0;
			for(int k = 0; k < work_index; k++){
				if(work[k] == 'i'){
					i_count++;
					if(k < work_index-2 && work[k+1] == 'w' && work[k+2] == 'i')iwi_count++;
				}else if(work[k] == 'w'){
					w_count++;
				}
			}

			if(i_count != 2 || w_count != 1 || iwi_count != 1){
				FLG = false;
			}

			if(FLG){
				maximum = max(maximum,work_index);
			}
		}
	}

	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 2880
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	if N%2 == 0 {
		fmt.Println(N)
	} else {
		fmt.Println(N * 2)
	}
}


Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<math.h>
#define pi 3.14159265358979
#define int long long
using namespace std;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
// #ifndef ONLINE_JUDGE
//    freopen ("INPUT.txt" , "r" , stdin);
//    freopen ("OUTPUT.txt" , "w" , stdout);
// #endif

    clock_t clk;
	clk = clock();

// --------------Code s0tarts here---------------------------------------------------------------------

    int n,k;
    cin>>n>>k;
    int a[n+1],f[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>f[i];
    sort(a+1,a+1+n);
    sort(f+1,f+1+n,greater<>());
    int ans=1e18;
    int l=0,r=1e18;
    while (l<=r)
    {
        int temp=k;
        int mid=l+(r-l)/2;
        for(int i=1;i<=n;i++)
        {
            if(a[i]*f[i]>mid)
            {
                int z=mid/f[i];
                temp-=a[i]-z;
            }
        }

        if(temp>=0)
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }   
    }
    
    cout<<ans;
// -------------------------------------Code ends here------------------------------------------------------

    clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 3456
n=int(input())

a=list(map(int,input().split()))

import collections

c = collections.Counter(a)
cc=c.keys()

maxsum=0
for item in cc:
    temp=c[item]
    if temp>1:
        maxsum+=(temp)*(temp-1)//2

for item in a:
    temp=c[item]
    if temp>1:
        t=maxsum-temp*(temp-1)//2+(temp-1)*(temp-2)//2
        print(t)
    else:
        print(maxsum)




Measured memory_bytes: 89932
#include <stdio.h>
int main(void) {
    int a, b;
 
    scanf("%d %d", &a, &b);
    if(a > b) {
        puts("a > b");
        }
    else if(a < b) {
        puts("a < b");
        }
    else {
        puts("a == b");
   }
    return 0;
}

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


def main():
    """Function."""
    s = str(input())
    s1, s2, s3 = "", "", ""
    if s[0] == "1":
        s1 = "9"
    else:
        s1 = "1"
    if s[1] == "1":
        s2 = "9"
    else:
        s2 = "1"
    if s[2] == "1":
        s3 = "9"
    else:
        s3 = "1"
    print(s1+s2+s3)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]
li=[1]*n
for i in ab:
  if h[i[0]-1]>=h[i[1]-1]:
    li[i[1]-1]-=1
  if h[i[0]-1]<=h[i[1]-1]:
    li[i[0]-1]-=1
print(li.count(1))

Measured memory_bytes: 32056
import itertools

h, w, k = map(int, input().split())
mod = 10**9 + 7

# 縦棒を0-indexで考える
# dp[i][j] := 上から高さi(0,1,...,h)までの横棒を配置した時に、
#             0(問題文では1)からスタートしてjで終わるようなものの個数

dp = [[0 for _ in range(w)]for _ in range(h + 1)]
dp[0][0] = 1

# 縦線が1本の場合、以下の議論が成立しない
if w == 1:
    print(1)
    exit()

bridges = list(itertools.product([0, 1], repeat=w - 1))
# print(bridges)

for i in range(h):
    for bridge in bridges:

        # 橋が隣り合っていてはいけない
        tf = True
        for j in range(w - 2):
            if bridge[j] == 1 and bridge[j + 1] == 1:
                tf = False
                break
        if tf == False:
            continue

        for j in range(w):
            # 左端について
            if j == 0:
                # 橋がある時、右から流入
                if bridge[0] == 1:
                    dp[i + 1][j] += dp[i][j + 1]
                # 橋がない時、上から流入
                else:
                    dp[i + 1][j] += dp[i][j]

            # 右端について
            elif j == w - 1:
                # 橋がある時、左から流入
                if bridge[-1] == 1:
                    dp[i + 1][j] += dp[i][j - 1]
                # 橋がない時、上から流入
                else:
                    dp[i + 1][j] += dp[i][j]

            #　両端以外について
            else:
                # 両サイドに橋がない場合
                if bridge[j - 1] == 0 and bridge[j] == 0:
                    dp[i + 1][j] += dp[i][j]
                # 左だけ橋がある場合
                elif bridge[j - 1] == 1 and bridge[j] == 0:
                    dp[i + 1][j] += dp[i][j - 1]
                # 右だけ橋がある場合
                elif bridge[j - 1] == 0 and bridge[j] == 1:
                    dp[i + 1][j] += dp[i][j + 1]

            dp[i + 1][j] %= mod

print(dp[-1][k - 1])


Measured memory_bytes: 74160
import math
a,b,h,m=map(int,input().split())
x=math.radians(6*m)
y=math.radians(30*h+m/2)
print(((b*math.sin(x)-a*math.sin(y))**2+(b*math.cos(x)-a*math.cos(y))**2)**0.5)

Measured memory_bytes: 9572
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
template<typename T> class segtree{
private:
    int n,sz;
    vector<T> node;
public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()){
        while(n < sz) n *= 2;
        node.resize(2*n-1, numeric_limits<T>::min());
        for(int i = 0; i < sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = max(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k,T a){
        k += n-1;
        node[k] = a;
        while(k>0){
            k = (k-1)/2;
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }
    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0) r = n;
        if(r <= a || b <= l){
            return numeric_limits<T>::min();
        }
        if(a <= l && r <= b){
            return node[k];
        }else{
            T vl = query(a,b,2*k+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    void print(){
        for(int i = 0; i < sz; i++){
            cout<<query(i,i+1)<< " ";
        }
        cout<<endl;
    }
};

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(700100);
    segtree<int> sg(p);
    rep(i,n){
        int a;
        cin >> a;
        sg.update(a,sg.query(max(0,a-k),a+k+1)+1);    
    }
    cout << sg.query(0,700000) << endl;
    return 0;
}

Measured memory_bytes: 13996
#include<bits/stdc++.h>
#define long long long
using namespace std;
int a,b,c;
void srt()
{
  if(b<a)swap(a,b);
  if(c<a)swap(a,c);
  if(c<b)swap(b,c);
}
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>a>>b>>c;

  for(int i=0; ;i++)
  {
    srt();
    if(a==b&&b==c)cout<<i<<endl,exit(0);
    if(b<c)a++,b++;
    else a+=2;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long m = N / 1000;
		if (m * 1000 == N) {
			System.out.println(0);
		} else {
			m = m + 1;
			m = m * 1000;
			System.out.println(m - N);
		}
	}
}

Measured memory_bytes: 27024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = n /15;
		int x = 800 * n, y = a * 200;
		int result = x - y;
		System.out.println(result);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
#define MOD long long(1e9+7)
int main(){
	ll n;
	cin>>n;
	vector<ll>a(n);
	map<ll,ll>ans;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i!=0)a[i]+=a[i-1];
		ans[a[i]]++;
	}
	ll sum=0;
	for(auto it:ans){
		if(it.second>=2)sum+=((it.second-1)*it.second)/2;
	}
	cout<<sum+ans[0]<<endl;
}


Measured memory_bytes: 14336
N,M,X = [int(i) for i in input().split(' ')]

A = []
C = []

for i in range(N):
	tmp = [int(i) for i in input().split(' ')]
	C.append(tmp[0])
	A.append(tmp[1:])

import itertools
count = -1
m_li = []
lis = list(range(N))
for i in range(1, N+1):
	for pair in itertools.combinations(lis, i):
		count += 1
		money = 0
		Ad = [0]*M
		for j in pair:
			money += C[j]
			for ind,k in enumerate(A[j]):
				Ad[ind] += k
              	
		flag = True
		for j in range(M):
			if Ad[j]<X:
				flag = False
		if flag:
			m_li.append(money)

if len(m_li)==0:
	print(-1)
else:
	print(min(m_li))
            


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

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

int main(void) {
  int k, x;
  cin >> k >> x;

  if(500*k >= x) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

#define null                ""
#define all(dat)            dat.begin(), dat.end()
#define over(msg)           cout << msg << endl, exit(0);
#define loop(i, to)         for (int i = 0; i < to; ++i)
#define cont(i, to)         for (int i = 1; i <= to; ++i)
#define foreach(i, dat)     for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long           num;

using namespace std;

int n;
double p[3005], dp[3005][3005], ans;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    dp[0][0] = 1;
    cont (i, n) {
        cin >> p[i];
        loop (j, n + 1) {
            dp[i][j] += dp[i - 1][j] * (1 - p[i]);
            dp[i][j + 1] += dp[i - 1][j] * p[i]; 
        }
    }
    for (int i = n / 2 + 1; i <= n; ++i) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<b; i++)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ull M=LLONG_MAX,N=1e7+5,INF=1e18;

void solve()
{
    ll a,b,n,x,mx=0,t;
    cin >> a >> b >> n;

    // f(i,1,n+1)
    // {
    //     t = floor(1.0*a*i/b) - a*floor(1.0*i/b);
    //     mx = max(mx,t);
    // }

    x = min(n,b-1);

    cout << (a*x)/b << endl;
    // cout << mx << endl;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3648
void main()
{
    long n, m;
    rdVals(n, m);

    bool[] ac = new bool[n+1];
    long[] wa = new long[n+1];

    foreach (i; 0 .. m)
    {
        long p;
        string s;
        rdVals(p, s);
        if (s == "AC")
        {
            if (!ac[p]) ac[p] = true;
        }
        else
        {
            if (!ac[p]) ++wa[p];
        }
    }

    long cnt_ac, cnt_wa;
    foreach (i; 1 .. n+1)
    {
        if (ac[i])
        {
            ++cnt_ac;
            cnt_wa += wa[i];
        }
    }

    writeln(cnt_ac, " ", cnt_wa);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;


signed main() {
    string S;
    cin >> S;

    string s, t;
    s.push_back(S[0]); s.push_back(S[1]);
    t.push_back(S[2]); t.push_back(S[3]);

    if(s<="12" && s>"00" && t<="12" && t>"00"){
        cout << "AMBIGUOUS" << endl;
    }
    else if(s<="12" && s>"00"){
        cout << "MMYY" << endl;
    }
    else if(t<="12" && t>"00"){
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

// a^n (mod mod)
int modpow(int a, int n, int mod = MOD){
  int res = 1;
  while(n>0){
    if(n & 1)res = res*a%mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res % mod;
}

int modinv(int a, int mod = MOD) {
    return modpow(a, mod - 2, mod);
}

signed main(){
  const int MAX = 100000;
  int fact[MAX+1];
  fact[0] = 1;
  int inv[MAX+1];
  inv[0] = 1;
  LOOP1(i, MAX){
    fact[i] = fact[i-1]*i % MOD;
    inv[i] = modinv(fact[i]);
    // // cerr << fact[i] << ":" << inv[i] << endl;
  }

  int n,k;
  cin >> n >> k;
  int a[n];
  LOOP(i,n)cin >> a[i];
  sort(a,a+n);
  int ans = 0;
  LOOP(i,n){
    // cerr << a[i] << ":";
    if(i>=k-1){
      int ma = fact[i] * inv[k-1] % MOD;// cerr << ma << ",";
      ma = ma * inv[i-k+1] % MOD;
      // cerr << ma << "(+)";
      ma = ma * a[i] % MOD;
      ans += ma;
    }// max: i C k
    if(n-i >= k){
      int mi = fact[n-i-1] * inv[k-1] % MOD;
      mi = mi * inv[n-i-k] % MOD;
      mi = mi * a[i] % MOD;
      ans += MOD - mi;
      // cerr << mi << "(-)";
    }
    ans %= MOD;
    // cerr << ans << endl;
    // min: n-i-1 C k
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
def main():
    W, H, N = map(int, input().split())
    best = [0, W, 0, H]
    for _ in range(N):
        x, y, a = map(int, input().split())
        if a == 1:
            best[a-1] = max(best[a-1], x)
        elif a == 2:
            best[a-1] = min(best[a-1], x)
        elif a == 3:
            best[a-1] = max(best[a-1], y)
        elif a == 4:
            best[a-1] = min(best[a-1], y)
    # print(H, W)
    # print(best)
    if best[0] >= best[1] or best[2] >= best[3]:
        return 0
    else:
        v =(W-best[1] + best[0])*H + (H-best[3]+best[2])*W
        # print(v)
        v -= (W-best[1])*(H-best[3]) + (W-best[1])*best[2]
        # print(v)
        v -= best[0]*(H-best[3]) + best[0]*best[2]
        return H*W - v

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long 
const int maxn = 1010;
int a[maxn][maxn];
int n,m,x,y;
int main()
{
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for(int i=1;i<=y;i++)
	   for(int j=1;j<=x;j++)
	   a[i][j]=1;
	for(int i=y+1;i<=n;i++)
	   for(int j=x+1;j<=m;j++)
	   a[i][j]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		printf("%d",a[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5120
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

N = int(input())
A = list(map(int, input().split()))
left = [0]*N
right = [0]*N

left[0] = A[0]
for i in range(1, N-1):
    left[i] = gcd(left[i-1], A[i])

right[-1] = A[-1]
for i in range(N-2, 0, -1):
     right[i] = gcd(right[i+1], A[i])

# print(left, right)
max_val = max(left[-2], right[1])
for i in range(1, N-1):
    max_val = max(max_val, gcd(left[i-1], right[i+1]))

print(max_val)


Measured memory_bytes: 89580
#include "bits/stdc++.h"
using namespace std;
typedef vector<vector<long long>> Graph;
vector<bool> seen(110, false);
vector<int> first_order(110);
vector<int> last_order(110);
int ptr = 0;
void dfs(Graph& G, int v) {
    ptr++;
    first_order[v] = ptr;
    seen[v] = true;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
    ptr++;
    last_order[v] = ptr;
    return;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    long long N; cin >> N;
    Graph G(N);
    rep(i, N) {
        int u, k; cin >> u >> k;
        rep(j, k) {
            int v; cin >> v;
            G.at(u - 1).push_back(v - 1);
        }
    }
    rep(i, N) {
        if (!seen.at(i)) dfs(G, i);
    }
    rep(i, N) {
        cout << i + 1 << ' ' << first_order.at(i) << ' ' << last_order.at(i) << endl;
    }
}


Measured memory_bytes: 3156
#include<stdio.h>
#include<string.h>

void input(int *n,double x[],char u[10][5])
{
  scanf("%d",n);
  int i;
  for(i=0;i<*n;i++){
    scanf("%lf %s",&x[i],u[i]);
  }
}

int main(void)
{
  int n;
  double x[10];
  char u[10][5];
  input(&n,x,u);
  
  double sum=0.0;
  int i;
  for(i=0;i<n;i++){
    if(!strcmp("JPY",u[i])){
      sum += x[i];
    }else{
      sum += x[i]*380000.0;
    }
  }
  
  printf("%f\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main( void ) 
{
	char str[1201];
	int alphs[27]={0};
	int i;
	
	while( NULL != fgets( str, 1201, stdin)  ) {	
		for( i=0; '\0'!=str[i]; i++ ) {
			if( 'A'<=str[i] && str[i]<='Z' ) {
				alphs[ str[i]-'A' ]++;
			} else if(  'a'<=str[i] && str[i]<='z'  ) {
				alphs[ str[i]-'a' ]++;
			} else {
				;
			}
		}
	}

	for( i=0; i<26; i++ ) {
		printf( "%c : %d\n", 'a'+i, alphs[i] );	
	}
	return 0;
}

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

map<string, long long> mp;

signed main() {
    int N;
    cin >> N;
    int ans = 0;
    
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define max3(a,b,c) max(max(a,b) ,c)

int main() {
  int A,B;
  cin >> A >> B;
  cout << max3(A+B, A-B, A*B)  << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let n = read_i64() as usize;
    let xs = read_vec_i64();
    let ys = {
        let mut ys = vec![0; n+2];
        for (i,&x) in xs.iter().enumerate() {
            ys[i+1] = x;
        }
        ys
    };
    let mut max_len = 0;
    for ts in ys.windows(2) {
        max_len += (ts[1]-ts[0]).abs();
    }
    for ts in ys.windows(3) {
        let res = max_len - (ts[1]-ts[0]).abs() - (ts[2]-ts[1]).abs() + (ts[2]-ts[0]).abs();
        println!("{}", res);
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	auto calc = [&](ll v) {
		ll tmp = 0;
		rep(i, n) tmp += abs(a[i] - (v + i + 1));
		return tmp;
	};
	ll l = -1e9, r = 1e9;
	rep(ri, 100) {
		ll mid1 = (l * 2 + r) / 3;
		ll mid2 = (l + r * 2) / 3;
		if (calc(mid1) >= calc(mid2)) l = mid1;
		else r = mid2;
	}
	ll ans = linf;
	for (int i = l - 10; i <= l + 10; ++i) {
		ll tmp = calc(i);
		mins(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4768
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
using namespace std;

const double pi=4*atan(1.0);

using cEdges=vector<vector<int>>;

struct cVertex{
	int parent;
	int find_time;
	int key;
};

int dfs(int now,int parent,int& time,const cEdges& Edges,vector<cVertex>& Vertices){
	Vertices[now].find_time=time++;
	Vertices[now].parent=parent;

	int ans=Vertices[now].find_time;
	for(const auto& val:Edges[now]){
		if(Vertices[val].find_time<0){
			ans=min(ans,dfs(val,now,time,Edges,Vertices));
		}
		else{
			ans=min(ans,Vertices[val].find_time);
		}
	}

	Vertices[now].key=ans;
	return ans;
}

int main() {
	int N,M;
	cin>>N>>M;
	cEdges Edges(N);
	for(int i=0;i<M;++i){
		int u,v;
		cin>>u>>v;

		Edges[u].push_back(v);
		Edges[v].push_back(u);
	}

	vector<cVertex> Vertices(N,{-1,-1,-1});
	int time=0;
	dfs(0,-1,time,Edges,Vertices);

	vector<bool> IsArticulation(N,false);
	int root_cnt=0;

	for(const auto& vertex:Vertices){
		if(vertex.parent!=-1 && vertex.parent!=0){
			if(Vertices[vertex.parent].find_time<=vertex.key){
				IsArticulation[vertex.parent]=true;
			}
		}else if(vertex.parent==0){
			++root_cnt;
		}
	}

	if(root_cnt>1)IsArticulation[0]=true;

	for(int i=0;i<IsArticulation.size();++i){
		if(IsArticulation[i])cout<<i<<"\n";
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 4728
//AnkitCode99
#include<bits/stdc++.h>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
 
using namespace std;
 
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
 
ll n;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll dp[maxn][5];
 
int main()
{
    gbtb;
    cin>>n;
    repd(i,1,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    repd(i,2,n)
    {
        dp[i][1]+=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]+=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]+=max(dp[i-1][1],dp[i-1][2])+c[i];
    }
    cout<<max(dp[n][3],max(dp[n][1],dp[n][2]));
    return 0;
}
 
inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A(N);
    int cnt=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i){
            if(A[i]>A[i-1]) cnt++;
        }
    }
    cout<<cnt<<endl;
}





Measured memory_bytes: 3372
#include<stdio.h>
#define N 10000

int main(void){
  int i,num,j;
  int sf,c;
  int a,b;
  int co[110];
  int ans[N];

  sf=0;
  for(i=0;;i++){
    ans[i]=1;
    for(j=0;j<110;j++)
      co[j]=0;
    for(;;){
      c=scanf("%d%d",&a,&b);
      if(c==EOF){
        sf=1;
        break;
      }
      if(a==0 && b==0)
        break;
      co[a]++;
      co[b]++;
    }
    if(sf==1)
      break;
    for(j=1;j<=2;j++)
      if(co[j]%2==0)
        ans[i]=0;
    for(j=3;j<110;j++)
      if(co[j]%2!=0)
        ans[i]=0;
  }
  num=i;
  for(i=0;i<num;i++){
    if(ans[i]==1)
      printf("OK\n");
    else if(ans[i]==0)
      printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int h,n;
	cin>>h>>n;
	long long int a[n],s=0;
	for(long long int i=0;i<n;i++)
	{
		cin>>a[i];
		s=s+a[i];
	}
	if(s>=h)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void debug() {
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	//cin>>t;
	t=1;
	while(t--){
		ll x;
		cin>>x;
		if(x>=30)
			cout<<"Yes";
		else
			cout<<"No";
		
		
		
	}





}


Measured memory_bytes: 3640
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	ll a,b,c;
	cin >> a >> b;
	c = a - (b * 2);
	if (c >= 0) {
		cout<<c;
	}
	else {
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int a[3][10];
	int b[3][10];
	int c[3][10];
	int d[3][10];
	int n;
	cin >> n;

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			a[i][j] = 0;
			b[i][j] = 0;
			c[i][j] = 0;
			d[i][j] = 0;
		}
	}
	for(int i = 0; i < n; i++){
		int B, F, R, V;
		cin >> B >> F >> R >> V;
		F--;
		R--;
		switch(B){
			case 1:
				a[F][R] += V;
				break;
			case 2:
				b[F][R] += V;
				break;
			case 3:
				c[F][R] += V;
				break;
			case 4:
				d[F][R] += V;
				break;
		}
	}

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			cout << ' ' << a[i][j];
		}
		cout << '\n';
	}
	cout << "####################\n";
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			cout << ' ' << b[i][j];
		}
		cout << '\n';
	}
	cout << "####################\n";
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			cout << ' ' << c[i][j];
		}
		cout << '\n';
	}
	cout << "####################\n";
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			cout << ' ' << d[i][j];
		}
		cout << '\n';
	}
}



Measured memory_bytes: 3088
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc064/tasks/abc064_c
N = read_a_int()
A = read_ints()

if N == 1:  # コーナーケースかー
    print(1, 1)
    exit()


# 色は400ごとに変化(400で割っておくと処理が楽そう)
import numpy as np
A = np.array(A) // 400

cnt = Counter(A)
# print(cnt)
ans_min = 0
ans_max = 0
for k, v in cnt.items():
    if k >= 8:
        ans_max += v
    else:
        ans_min += 1
        ans_max += 1
if ans_min == 0:
    ans_min = 1  # 全員レッドコーダー
print(ans_min, ans_max)


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n;cin>>n && n;){
		vi a(n),b(n+1,-1);
		rep(i,n){
			cin>>a[i];
			b[a[i]]=i;
		}
		map<int,int> f;
		f[0]=n;
		ll res=0;
		repi(x,1,n+1){
			int c=b[x];
			auto i=--f.upper_bound(c);
			int l=i->first,r=i->second;
			assert(l<=c && c<r);
			res+=ll(x)*(c-l+1)*(r-c);
			f.erase(i);
			if(l<c) f[l]=c;
			if(c+1<r) f[c+1]=r;
		}
		cout<<res<<endl;
	}
}


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

bool upDown(int a, int b)
{
    return a < b;
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A;
    int in;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        A.emplace_back(in);
    }

    vector<bool> up;
    for (int i = 1; i < N; i++)
    {
        if (A[i - 1] == A[i]) continue;
        up.emplace_back(upDown(A[i - 1], A[i]));
    }
    
    int cnt = 1;
    for (int i = 1; i < up.size(); i++)
    {
        if (up[i - 1] != up[i])
        {
            cnt++;
            i++;
        }

    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#define MAX_N 20
#define INF 1e9
using namespace std;

int dp[MAX_N][MAX_N];
int n,m;

void warshall_froyd(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
}

int main(){
  cin >> n; 
  cin >> m;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      dp[i][j] = (i==j ? 0 : INF);
    }
  }
  
  char camma;
  for(int i=0;i<m;i++){
    int a,b,atob,btoa;
    cin >> a >> camma >> b >> camma >> atob >> camma >> btoa;
    a--; b--;
    dp[a][b] = atob; dp[b][a] = btoa;
  }

  warshall_froyd();

  int start,goal,reward,price;
  cin >> start >> camma >> goal >> camma >> reward >> camma >> price;
  start--; goal--;
  cout << reward - dp[start][goal] - dp[goal][start] - price << endl;
  return 0;
}

Measured memory_bytes: 1160
n,m = map(int,input().split())
xyz = [0]*n
for i in range(n):
    xyz[i] = list(map(int,input().split()))
ans = 0
for i in range(2**3):
    lis = [1,1,1]
    for j in range(3):
        if (i>>j)&1:
            lis[j] = -1
    c = [0]*n
    for i,[x,y,z] in enumerate(xyz):
        c[i] += lis[0]*x + lis[1]*y + lis[2]*z
    c = sorted(c,reverse=True)
    d = sum(c[:m])
    ans = max(ans, d)
print(ans)

Measured memory_bytes: 74292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] chara = {"X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", 
				"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", };
		String string = scan.next();
		int n = string.length();
		for (int i = 0; i < n; i++) {
			for (int j = 3; j < 29; j++) {
				if (string.subSequence(i, i+1).equals(chara[j])) {
					System.out.print(chara[j - 3]);
				}
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 20588