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

using namespace std;

void solve()
{
	int n, k;
	while (cin >> n >> k, n || k)
	{
		bool isBlank = false;
		vector<int> card(k);
		for (int i = 0; i < k; ++i)
		{
			cin >> card[i];
			if (card[i] == 0)
			{
				isBlank = true;
			}
		}
		sort(card.begin(), card.end());
		int pos = 1;
		if (card[0] == 0)
		{
			++pos;
		}
		bool isUsed;
		int ans = 0;
		for (int i = pos; i < k; ++i)
		{
			if (isBlank)
			{
				isUsed = false;
			}
			else
			{
				isUsed = true;
			}
			int count = 1;
			int pre = card[i - 1];
			for (int j = i; j < k; ++j)
			{
				if (pre == card[j] - 1)
				{
					++count;
					ans = max(ans, count);
					pre = card[j];
				}
				else
				{
					if (isUsed)
					{
						count = 0;
						break;
					}
					else
					{
						isUsed = true;
						++count;
						ans = max(ans, count);
						pre = card[j] - 1;
						--j;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
const int mod=1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
ll fact[100001],factiv[100001];
int finiv(int a,int b,int *x,int *y)
{
    if(a==0)
    {
        *x=0;*y=1;
        return b;
    }
    int x1,y1;
    int gcd=finiv(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return gcd;
}
int inv(int i)
{
    int x,y;
    finiv(i,mod,&x,&y);
    return x;

}
void factf()
{
    fact[1]=1;factiv[1]=1;factiv[0]=1;
    //invt[1]=1;
    for(int i=2;i<100001;i++)
    {
        fact[i]=fact[i-1]*i%mod;
       // invt[i] =mod - invt[mod % i] * (mod / i) % mod;
        factiv[i]=factiv[i-1]*inv(i)%mod;
    }

}
ll comb(int a,int b)
{
    if(a<b) return 0;
  //  if (a < 0 || b < 0) return 0;
    return fact[a]*(factiv[a-b]*factiv[b]%mod)%mod;
}
int main()
{
    fastio;
    factf();
    //fopen();
    int n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    ll c=0;
    //cout<<fact[5]<<endl;
    rep(i,n)
    {
        //cout<<c<<endl;
        ll r=(comb(i,k-1)-comb(n-i-1,k-1)+mod)%mod;
        //cout<<r<<endl;
        c+=(r*(a[i]+mod)%mod)%mod;
        c%=mod;
    }
    cout<<c;


}

Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    ll T;
    cin >> T;
    ll S;
    cin >> S;
    if(T*S>=D)prt("Yes");
    else prt("No");

    return 0;
}



Measured memory_bytes: 3652
N = int(input())
list = input().split(' ')
list = [int(i) for i in list ]

list.sort()
while len(list) > 1:
    # print(list)
    list.sort()
    x = (list[0] + list[1]) / 2.0
    list.append(x)
    del list[:2]
print('{:.08f}'.format(list[0]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, count = 0;
    string x;

    cin >> a;

    for(int i = 0; i < a; i++){
      cin >> x[i];
    }
    for(int i = 0; i < a-2; i++){
      if(x[i]=='A' && x[i+1]=='B' && x[i+2]=='C'){
        count++;
      }
    }
    
    cout << count << endl;
    return 0;

    }

Measured memory_bytes: 256
# 整数 a と、英小文字からなる文字列 s が入力されます。
# a が 3200以上なら s と出力し、a が 3200 未満なら red と出力するプログラムを書いてください。

# 標準入力から 整数a と文字列s を取得する
input_a = int(input())
input_s = input()

# a が3200以上／3200未満 なのかを判定する
# # output_s = 'Error: Input Value is OutOfRange. Sorry!'
# # if (input_a <= 2800) or (input_a >= 5000):
# #     output_s = output_s
# else:

output_s = 'pink'
if input_a >= 3200:
    output_s = input_s
elif input_a < 3200:
    output_s = 'red'

# 結果を出力する
print(output_s)


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

string S;

int main(){
    cin >> S;

    // 1文字目が0から始まるパターン
    int s_0 = 0;
    
    for(int i = 0;i < S.length() ;i++){
        if(i % 2 == 0){
            if(S.substr(i,1) == "1"){
                s_0++;
            }
        }else{
            if(S.substr(i,1) == "0"){
                s_0++;
            }
        }
    }

    // 1文字目が1から始まるパターン
    int s_1 = 0;
    for(int i = 0;i < S.length() ;i++){
        if(i % 2 == 0){
            if(S.substr(i,1) == "0"){
                s_1++;
            }
        }else{
            if(S.substr(i,1) == "1"){
                s_1++;
            }
        }
    }

    // 出力
    if(s_1 <= s_0){
        cout << s_1 << endl;
    }else{
        cout << s_0 << endl;
    }


}

Measured memory_bytes: 512
/*
all[i] = is the begining collection turkey. And 1 turn will die one and the other will have chance to survice all. And after M action turkey i will survice.

if turkey i and j survice if only all[i] and all[j] don't have together turkey. Because if in action i that turkey die => his friend will die in another
*/

#include <bits/stdc++.h>

using namespace std;

const int maxn = 410;
const int M = 1e5+10;

int n,m,res,x[M],y[M],die[maxn],all[maxn][maxn];

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=m;i++) cin>>x[i]>>y[i];
    for (int i=1;i<=n;i++) all[i][i]=1;
    for (int u=1;u<=n;u++)
        for (int i=m;i>=1;i--) {
            die[u] |= (all[u][x[i]] & all[u][y[i]]);
            int in = all[u][x[i]] | all[u][y[i]];
            all[u][x[i]] = in;
            all[u][y[i]] = in;
        }
    res=0;
    for (int u=1;u<=n;u++)
        for (int v=u+1;v<=n;v++) {
            int need = !die[u] & !die[v];
            //cout<<u<<" and "<<v<<" "<<die[u]<<" "<<die[v]<<endl;
            for (int i=1;i<=n;i++)
                need &= ((all[u][i]&all[v][i])==0);
            res+=need;
        }
    cout<<res<<endl;
}


Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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


#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    mem(a)       memset(a,0,sizeof(a))
const ll mod = 1000000007;

void fio()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}

template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}


//BFS CODE===================================================================

const int N = 2e6 + 5;

vector<ll> adj[N];
bool visited[N];
ll val[N];
ll depth[N];
ll parent[N];


void clear_all() {
    for (auto& v : adj) {
        v.clear();
    }
    mem(visited);
    mem(val);
    mem(depth);
    mem(parent);
   
}


 
 
void bfs(ll s) {
    queue<ll> q;
    q.push(s);
    visited[s] = true;
    depth[s] = 0;
    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (ll u : adj[v]) {
            if (!visited[u]) {
                visited[u] = true;
                parent[u] = v;
                q.push(u);
                depth[u] = depth[v] + 1;
            }
        }
    }
}


void dfs(ll v) {
    visited[v] = true;
    for (ll u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
}


// left shift << multiply by 2
// right shift >> divide by 2


//MODULAR EXPONENTION (pow(x,y)%p)=========================================================================
ll modexp(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 


bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
} 





void solve(){
 string s;
 cin>>s;
 int r=0, rmax=0;
 for(int i=0;i<3;i++){
    if(s[i]=='R')
        r++;
    if(s[i]=='S'){
        if(r>rmax)
            rmax=r;
        r=0;
    }
 }

 if(r>rmax)
            rmax=r;

cout<<rmax;
}


int main()
{
    // auto start = chrono::high_resolution_clock::now();
    boost;
    fio();
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    
      
    // auto end = chrono::high_resolution_clock::now();
    // TIME(start, end);
    return 0;
}

Measured memory_bytes: 50532
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};

/* ここからコード開始 */

int main(){
  kyopro;
  ll A, B, K;
  cin >> A >> B >> K;
  ll w{max(A, B)+1}, ans;
  rep(i, 0, K){
    w--;
    if(A%w || B%w) i--;
    ans = w;
  }
  cout << ans << rt;
}

Measured memory_bytes: 256
import collections

c = collections.Counter

n = int(input())
v = list(map(int, input().split()))

even_v = [v[i] for i in range(n) if i % 2 == 0]
odd_v = [v[i] for i in range(n) if i % 2 == 1]

c1 = c(even_v).most_common(2)
c2 = c(odd_v).most_common(2)
# print(c1)
# print(c2)

def calc(x, y):
    # print('x:', x, 'y:', y)
    # print('x[1]:', x[1], 'y[1]:', y[1])
    return len(even_v) - x[1] + len(odd_v) - y[1]

def main():
    if c1[0] != c2[0]:
        # print('c1[0] != c2[0]:')
        return calc(c1[0], c2[0])

    if len(c1) == 1 and len(c2) == 1:
        # print('len(c1) == 1 and len(c2) == 1:')
        return len(odd_v)

    if calc(c1[0], c2[1]) < calc(c1[1], c2[0]):
        # print('calc(c1[0], c2[1]) < calc(c1[1], c2[0]):')
        return calc(c1[0], c2[1])

    else:
        # print('else')
        return calc(c1[1], c2[0])

print(main())


Measured memory_bytes: 15964
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for(int i = 0; i < n; i++){
            v[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            c[i] = sc.nextInt();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(v[i] - c[i] > 0){
                ans += v[i] - c[i];
            }
        }
        // 出力
        System.out.println(ans);

    }

}


Measured memory_bytes: 22612
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    const M = 102;
    int F[M][M];
    int W, H; scanf("%d %d\n", &W, &H);
    foreach (i; 1 .. H + 1) {
        foreach (j; 1 .. W + 1) {
            int d; scanf("%d", &d);
            F[i][j] = d;
        }
    }

    bool used[M][M];
    static const 
        dy = [
            [-1, -1, 0, 0, 1, 1,], 
            [-1, -1, 0, 0, 1, 1,], 
        ],
        dx = [
            [-1, 0, -1, 1, -1, 0], // y is even
            [0, 1, -1, 1, 0, 1], // y is odd
        ];
    void dfs(int y, int x) {
        foreach (i; 0 .. 6) {
            int ny = y + dy[y % 2][i],
                nx = x + dx[y % 2][i];
            if (ny < 0 || ny >= M) continue;
            if (nx < 0 || nx >= M) continue;
            if (used[ny][nx]) continue;
            used[ny][nx] = true;
            if (F[ny][nx]) continue;
            dfs(ny, nx);
        }
    }
    dfs(0, 0);
    int ans = 0;
    foreach (i; 0 .. M) {
        foreach (j; 0 .. M) {
            if (F[i][j] && used[i][j]) {
                foreach (k; 0 .. 6) {
                    int ny = i + dy[i % 2][k],
                        nx = j + dx[i % 2][k];
                    if (ny < 0 || ny >= M) continue;
                    if (nx < 0 || nx >= M) continue;
                    if (!F[ny][nx] && used[ny][nx]) ans++;
                }
            }
        }
    }
    ans.writeln;
}

Measured memory_bytes: 3028
// AOJ 2353 Four Arithmetic Operations
// 2017.11.27 bal4u@uu

#include <stdio.h>
#define LIM 2147483648LL
#define P   4294967311LL		// ???= 0x???10000000F??¬??¬, prime number??¬
#define M1	20					// 2^20 = 0x100000 = 1048576
#define M2  0xfffff				// = 2^20 -1

#define mul(x,y)	(((((x)*((y)>>M1)%P)<<M1)+(x)*((y)&M2))%P)

char buf[15], *p;
int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

long long egcd(long long a, long long b, long long *x, long long *y)
{
	long long d;

	if (b == 0) { *x = 1; *y = 0; return a; }
	d = egcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}

int main()
{
	int n, c, y;
	long long x;

	fgets(p=buf, 10, stdin), n = getint();
	x = 0;
	while (n--) {
		fgets(p=buf, 15, stdin);
		c = *p, p+=2, y = getint();
		if (c == '1') {
			x += y; if (x < 0) x += P; if (x >= P) x -= P;
		} else if (c == '2') {
			x -= y; if (x < 0) x += P; if (x >= P) x -= P;
		} else if (c == '3') {
			if (y < 0) x = mul(x, (P+y));
			else       x = (x*y) % P;
		} else {  // div
			long long t1, t2, yy;
			yy = y; if (yy < 0) yy += P;
			egcd(yy, P, &t1, &t2);
			if (t1 < 0) t1 += P;
			x = mul(x, t1);
		}
	}
	if (x >= LIM) x -= P;
	printf("%lld\n", x); 
	return 0;
}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}

   
 bool isPowerOfTwo(ll x)
    {
        // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
        return (x && !(x & (x - 1)));
    }

ll ldd(ll n)
{
  for (ll i=3;i*i<=n;i+=2)
    if(n%i==0)
      return i;
}

void solve()
{
  ll n,x;
  cin>>n;
  map <ll,ll> mp;
  rep(i,0,n) 
  {
    cin>>x;
    mp[x]++;
  }
  ll ans=0;
  for (auto i:mp)
    ans+=i.fr*i.sc;
  ll q;cin>>q;
  while(q--)
  {
    ll a,b;
    cin>>a>>b;
    ans=ans-a*mp[a]+b*mp[a];
    if(mp.find(b)!=mp.end())
      mp[b]+=mp[a];
    else
      mp.insert({b,mp[a]});
    mp.erase(a);
    cout<<ans<<"\n";
  }
}


int main()       
{
  fastio
  ll t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 7520
function main(input){
    let nums = input.split("\n");
    let i=0;
    while(nums[i]!=="0"){
        let sum=0;
        while(nums[i].length>0){
            let char = nums[i].slice(-1);
            nums[i] = nums[i].slice(0,-1);
            sum+= parseInt(char);
        }
        console.log(sum);
        i++;
    }
    
    
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 16508
#include <iostream>
using namespace std;
 
int main() {
  int h, w;
  char s[50][50];
  cin >> h >> w;
  int sum;

  for(int i =0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }

  for(int i =0;i<h;i++){
    for(int j=0;j<w;j++){
      sum = 0;
      if(s[i][j] == '.'){
        for(int k=-1; k<2;k++){
          for(int l=-1;l<2;l++){
            if(i+k>=0&&j+l>=0&&i+k<h&&j+l<w){
              if(s[i+k][j+l]=='#') sum++;
            }
          }
        }
        cout << sum;
      }
      else cout << '#';
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;
int dp[110][100009];
int s[110][100009];
const int mod=1e9+7;
int main()
{
    scanf("%d%d",&n,&k);
    dp[0][k]=s[0][k]=1;
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        for(int j=1;j<=k;j++)
            dp[i][j]=(s[i-1][min(k,j+x)]-s[i-1][j-1]+mod)%mod;
        s[i][0]=dp[i][0]=s[i-1][x];
        for(int j=1;j<=k;j++)
            s[i][j]=(s[i][j-1]+dp[i][j])%mod;
    }
    cout<<dp[n][0]<<endl;
    return 0;
}

Measured memory_bytes: 82176
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;
int a[200001];
map<int, int> mp;

signed main() {
	int i;
	
	cin >> n >> k;
	rep(i, n) cin >> a[i + 1];
	rep(i, n) a[i + 1]--;
	
	rep(i, n) a[i + 1] += a[i];
	rep(i, n + 1) a[i] %= k;
	
	int ans = 0;
	rep(i, n + 1) {
		if (i >= k) mp[a[i - k]]--;
		ans += mp[a[i]];
		mp[a[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
n, y = list(map(int, input().split()))

flag = False

for i in range(0, n + 1):
    for j in range(0, n + 1 - i):
        k = n - i - j
        money = 10000 * i + 5000 * j + 1000 * k

        if money == y:
            print(i, j, k)
            flag = True # 多重ループ抜ける用
            break

    if flag:
        break


if not(flag):
    print(-1, -1, -1)


Measured memory_bytes: 3060
import sys

N = int(input())
WLst = [0] * N

for i in range(N):
    WLst[i] = input()

if WLst.count(WLst[0]) != 1:
    print('No')
    sys.exit()

for i in range(1, N):
    if WLst[i - 1][-1] != WLst[i][0]:
        print('No')
        sys.exit()
    if WLst.count(WLst[i]) != 1:
        print('No')
        sys.exit()

print('Yes')


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

main()
{
	int n,k;
	cin >> n >> k;
	int h[n];
	int dp[n];
	
	for(int i=0;i<n;i++)
		cin >> h[i];
		
	dp[0]=0;
	
	
	for(int i=1;i<n;i++)
	{
		int mini = INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)
			mini = min((dp[i-j]+abs(h[i]-h[i-j])),mini);
		}
		
		dp[i]=mini;
	}
	
	
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <string.h>

#include <algorithm>
#include <iostream>
#include <vector>

#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main(void) {
  int N;
  cin >> N;
  int D[100][2];

  for (int i = 0; i < N; i++) {
    cin >> D[i][0] >> D[i][1];
  }

  int cnt = 0;
  bool flag = false;

  for (int i = 0; i < N; i++) {
    if (D[i][0] == D[i][1]) {
      cnt++;
    } else {
      cnt = 0;
    }

    if (cnt == 3) {
      flag = true;
      break;
    }
  }

  if (flag == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    bool a[100100];
    REP(i,N+1) a[i] = true;
    REP(i,M){
        int x;
        cin >> x;
        a[x] = false;
    }
    ll dp[100100];
    REP(i,N+1){
        if(i == 0) dp[i] = 1;
        else if(i == 1){
            if(a[i]) dp[i] = 1;
            else dp[i] = 0;
        }
        else{
            if(a[i]) dp[i] = dp[i-1] + dp[i-2];
            else dp[i] = 0;
        }
        dp[i] %= mod;
    }
    cout << dp[N] << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    int cnt = 0;
    bool judge = true;
    
    while(judge){
        for(int i = 0; i < N; i++){
            if(A[i] % 2 != 0){
                judge = false;
                break;
            }
            
            else{
                A[i] /= 2;
            }
        }
        
        if(!judge){
            break;
        }
        
        cnt++;
    }
    
    cout << cnt << endl;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  ll n;
  cin >> n;
  ll a[3 * n];
  rep(i, 0, 3 * n) cin >> a[i];
  ll leftSum[n + 1], rightSum[n + 1];
  memset(leftSum, 0, sizeof(leftSum));
  memset(rightSum, 0, sizeof(rightSum));
  priority_queue<ll> leftQ, rightQ;

  rep(i, 0, n) {
    leftSum[0] += a[i];
    leftQ.push(-a[i]);
  }
  for(int i = 3 * n - 1; i >= 2 * n; --i) {
    rightSum[0] += a[i];
    rightQ.push(a[i]);
  }
  rep(i, n, 2 * n) {
    leftQ.push(-a[i]);
    ll tmpL = leftQ.top(); leftQ.pop();
    leftSum[i - n + 1] = leftSum[i - n] + tmpL + a[i];
  }
  for(int i = 2 * n - 1; i >= n; --i) {
    rightQ.push(a[i]);
    ll tmpR = rightQ.top(); rightQ.pop();
    rightSum[2 * n - i] = rightSum[2 * n - i - 1] - tmpR + a[i];
  }

  ll ans = leftSum[0] - rightSum[n];
  rep(i, 1, n + 1) ans = max(ans, leftSum[i] - rightSum[n - i]);
  cout << ans << endl;

}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	rep(i,5){
		int a;cin>>a;
		if(a==0){
			cout<<i+1<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	long long A[200010] = {}; 
	long long S[200010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; S[i] = S[i-1] + A[i]; 
	}
	long long ans = 1e18; 
	for(int i = 0; i <= N; i++){
		long long tmp1 = S[i]; 
		long long tmp2 = S[N] - S[i]; 
		ans = min(ans, abs(tmp1 - tmp2)); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    print(min(a+b,b+c,c+a))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
//ll least_prime[10000005]; 

int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while ( t--)  
{
  ll a;
  cin>>a;
  ll tt;
  tt=a+a*a+a*a*a;
  cout<<tt<<"\n";
  
 
}

 return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll dp[102][100005];
ll a[105],w[105],n,t;
void solve(ll n,ll t)
{
	if(dp[n][t]!=-1)
	{
		return;
	}
    if(n==0)
	{
		if(t==0)
		{
			dp[n][t]=0;
			return;
		}
		if(t==a[0])
		{
			dp[n][t]=w[0];
			return;
		}
		dp[n][t]=1e18;
		return;
	}
	if(a[n]>t)
	{
		solve(n-1,t);
		dp[n][t]=dp[n-1][t];
		return;
	}
	solve(n-1,t);
	solve(n-1,t-a[n]);
	dp[n][t]=min(dp[n-1][t],dp[n-1][t-a[n]]+w[n]);
	return;

}
int main()
{
	cin>>n>>t;
	ll k=0,i=0;
	for(ll i=0;i<n;i++)
	{
    	cin>>w[i]>>a[i];
		k+=a[i];
	}
	memset(dp,-1,sizeof(dp));
	for(i=k;i>=0;i--)
	{
		solve(n-1,i);
		if(dp[n-1][i]<=t)
		{
			cout<<i;
			break;
		}
	}
}


Measured memory_bytes: 80000
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;

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

  long long L[3]={2LL,1LL,0LL};

  if(N==1){
    cout<<L[1];
    return 0;
  }

  for(int i=2;i<=N;i++){
    L[i%3]=L[(i+1)%3]+L[(i+2)%3];
    if(i==N)
      cout<<L[i%3];
  }
}


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

ans = []
if n % 2 == 0:
    for e in a[n-1::-2]:
        ans.append(str(e))
    for e in a[0::2]:
        ans.append(str(e))
else:
    for e in a[n-1::-2]:
        ans.append(str(e))
    for e in a[1::2]:
        ans.append(str(e))
print(' '.join(ans))

Measured memory_bytes: 33604
import java.util.Scanner;

class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A = sc.nextInt();

    if (N % 500 <= A){
        System.out.println("Yes");
    }
    else {
        System.out.println("No");

    }
  }
}


Measured memory_bytes: 19924
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)

def lcm(m,n):
    return(m * n // gcd(m,n))

a,b,c,d = map(int,input().split())

a -= 1
n1 = b - b // c - b // d + b // lcm(c,d)
n2 = a - a // c - a // d + a // lcm(c,d)


print(n1 - n2)

Measured memory_bytes: 3064
import sys
import math

s = list(input())

t = list(input())


if s[0]==0 or t[0]==0:
    sys.exit(0)

i = 0
cnt = 0
while i<len(s):
    if i == 2*(pow(10,5)):
        sys.exit(0)
    if s[i]!=t[i]:
        cnt += 1
    i += 1

print(cnt)


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

int main() {
  int N;
  int L[10];
  int max=0;
  int sum=0;

  cin>>N;
  for(int ii = 0; ii < N; ii++){
    cin>>L[ii];
    sum += L[ii];
    if(L[ii]>max) max=L[ii];
  }
  if(sum > 2*max) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;

}


Measured memory_bytes: 256
//shara's here
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,d,a;
	cin>>s>>d>>a;
	char z,g,h;
	z=s[0]-32;
	g=d[0]-32;
	h=a[0]-32;
	cout<<z<<g<<h;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    sort(a.begin(),a.end(),std::greater<ll>());
    
    priority_queue<ll> que;
    que.push(a[0]);
    
    for(ll i=1;i<n;i++){
        ans+=que.top();
        que.pop();
        que.push(a[i]);
        que.push(a[i]);
    }
    
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 6932
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void) {
    LL N;
    cin >> N;
    vector<LL> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    LL c = 1;
    LL b = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == c) {
            c++;
        } else {
            b++;
        }
    }
    cout << (b==N ? -1 : b) << endl;
    return 0;
}



Measured memory_bytes: 1792
# ABC103D - Islands War
from operator import itemgetter as gt


def main():
    N, M, *AB = map(int, open(0).read().split())
    Q = [(a, b) for a, b in zip(*[iter(AB)] * 2)]
    Q.sort(key=gt(1))
    ans, cur = 0, -1
    for a, b in Q:
        if not a < cur <= b:
            ans += 1
            cur = b
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 99824435;
const int N = 2e5 + 50;
int A, B, M;
int a[N], b[N], ans, fr = MOD, mi = MOD;

int main() {
    cin>>A>>B>>M;
    for(int i=1;i<=A;i++) {
        scanf("%d", &a[i]);
        fr = min(fr, a[i]);
    }
    for(int i=1;i<=B;i++) {
        scanf("%d", &b[i]);
        mi = min(mi, b[i]);
    }
    ans = fr + mi;
    int l, r, c;
    for(int i=0;i<M;i++) {
        scanf("%d%d%d", &l, &r, &c);
        ans = min(ans, a[l] + b[r] - c);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,k;
  std::cin>>n>>k;

  std::vector<ll> v(n);
  rep(i,0,n)std::cin>>v[i];

  ll ans=std::numeric_limits<ll>::min();

  rep(a,0,n+1){
    rep(b,0,n+1){
      if(a+b>std::min(n,k))continue;
      std::vector<ll> dewel;
      rep(i,0,a)dewel.push_back(v[i]);
      rep(i,0,b)dewel.push_back(v[n-1-i]);
      std::sort(all(dewel));
      ll val=std::accumulate(all(dewel),0);
      rep(i,0,std::min(k-a-b,a+b)){
        if(dewel[i]>=0)break;
        val-=dewel[i];
      }
      debug(a,b,dewel,val);
      chmax(ans,val);
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int t,sum1,sum2;
  sum1 = sum2 = 0;
  for(int i = 0 ; i < 4 ; i++){
    cin >> t;
    sum1+= t;
  }
  for(int i = 0 ; i < 4 ; i++){
    cin >> t;
    sum2+= t;
  }
  if(sum1 > sum2)cout << sum1 << endl;
  else cout << sum2 << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>


// Union-Find Tree
class DisjointSet {
private:
    struct Node {
        int parent;
        int rank;
    };

public:
    DisjointSet(size_t n) : _nodes(n) {
        int i = 0;
        for (auto& node : _nodes) {
            node.parent = i;
            node.rank = i;
            ++i;
        }
    }

    bool same(int a, int b) {
        return find(a) == find(b);
    }

    void unite(int a, int b) {
        link(find(a), find(b));
    }

    int find(int x) {
        if (x != _nodes[x].parent) {
            // path compression
            _nodes[x].parent = find(_nodes[x].parent);
        }
        return _nodes[x].parent;
    }

    void link(int a, int b) {
        if (_nodes[a].rank > _nodes[b].rank) {
            _nodes[b].parent = a;
        } else {
            _nodes[a].parent = b;
            if (_nodes[a].rank == _nodes[b].rank) {
                ++(_nodes[b].rank);
            }
        }
    }

private:
    std::vector<Node> _nodes;
};


int main()
{
    using namespace std;

    int n, q;
    cin >> n >> q;

    DisjointSet ds(n);


    for (int j = 0; j < q; j++) {
        int c, x, y;
        cin >> c >> x >> y;

        if (c) {
            if (ds.same(x, y))
                cout << 1 << endl;
            else
                cout << 0 << endl;
        } else {
            ds.unite(x, y);
        }
    }
}

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

int main() {
	int N,M,C;cin>>N>>M>>C;

	vector<int>B(M);
	for (int j = 0; j < M; j++)
	{
		cin>>B[j];
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int res = C;
		for (int j = 0; j < M; j++)
		{
			int a;cin>>a;
			res += a*B[j];
		}

		if(res > 0)ans++;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 888
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;






public class Main {

	
	 
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static int N = (int) 1e5;
	public static void main(String[] args) {
		 FastReader sc = new FastReader();
		 int n = sc.nextInt();
		 int[] h = new int[n];
			for(int i=0;i<n;++i) {
				h[i] = sc.nextInt();
			}
			boolean yes = true;
			h[0]--;
		for(int i=1;i<n && yes;++i) {
			
			if(h[i]-1>=h[i-1]) h[i]--;
			else if(h[i]<h[i-1]) yes = false;
		}
		
		 if(yes) out.print("Yes");
		 else  out.print("No");
			 out.close();
		}
		
	 
		
	}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素
int n,k,d,a;
set<int> s;
int main(){
    cin>>n>>k;
    REP(i,k){
        cin>>d;
        REP(j,d){
            cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size();
    return 0;
}

Measured memory_bytes: 3644
/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MAXN=3000+20;
bool dp[MAXN];//第i个点，已经用了	 
bool vis[MAXN];
int n;
int a[3000+20];
vector<int> g[3000+20];
bool check(int now){
	if(vis[now]) return dp[now];
	vis[now]=1;
	bool& rest=dp[now];
	int maxi=a[now]-1;
	for(auto it:g[now]){
		if(maxi>=a[it]){
//			cout<<maxi<<" "<<a[it]<<endl;
			bool ok=1;
			for(auto itt:g[it]){
//				cout<<a[itt]<<" "<<itt<<endl;
				if(a[itt]>=a[it]||check(itt));
				else
				{
					ok=0;
				}
			}
			if(ok){
				rest=1;
				break;
			}
		}
	}
	return rest;
}
int main(){
//	freopen("in50.txt","r",stdin);
//	freopen("in50.ans","w",stdout);
	fastio;
	R(n);
	rb(i,1,n)
		R(a[i]);
	rb(i,1,n-1){
		int u,v;
		R2(u,v);
		g[u].PB(v);
		g[v].PB(u);
	}		 
//	cout<<check(924,0)<<endl<<"-----------------------------------"<<endl;
//	cout<<check(1185)<<endl;
	rb(i,1,n){
		if(check(i)){
			cout<<i<<" ";
		}
	}
	cout<<endl;
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


Measured memory_bytes: 3860
x, y = map(int, input().split())
group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]
group3 = [2]
if ((x in group1) and (y in group1)) or ((x in group2) and (y in group2)):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    int t = i * 108 / 100;
    if (t == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


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

    cout<<max(c-(a-b),0LL);


    return 0;
}


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

int main()
{

	int N, K, P;
	int W[1000];

	cin >> N;

	for( int i = 0; i < N; i++ ) {

		cin >> K >> P;

		if( K % P != 0 ) W[i] = K % P;
		else W[i] = P;

	}

	for( int i = 0; i < N; i++ ) cout << W[i] << endl;

	return 0;

}

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

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


Measured memory_bytes: 3108
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define OrderSetTree tree<ll,null_type/*mapped_type*/,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    //OrderSetTree ost;
    ll i,j,t,n,p;
    string s;
    cin>>s;

    if(s[s.size()-1]=='s')
        cout<<s<<"es";
    else
        cout<<s<<"s";

    cout<<"\n";
    return 0;   //:D
}




Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////



int main(){
    int n;
    I(n);
    int ar[n+2];
    int mp[n+2];
    SET(mp);

    ll res = 0;
    for(int i = 1;i<=n;i++){cin>>ar[i];
      res += (mp[ar[i]]);
      mp[ar[i]] ++;
    }

    for(int i = 1;i<=n;i++){
        cout<<(res-mp[ar[i]]+1)<<endl;
    }
    return 0;
}

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

using namespace std;

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

    long long h,n,w,t;

    for(h=1;h<=3500;h++){
        for(n=1;n<=3500;n++){
            t=4*h*n-N*(n+h);

            if(t>0)w=N*h*n/t;
            else continue;

            if(4*h*n*w==(w*(n+h)+h*n)*N){
                cout<<h<<' '<<n<<' '<<w;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256