akhauriyash/Code-Regression huggingface dataset:
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    n = int(input())
    s = input()
    cnt = 0
    for i in range(10):
        x = s.find(str(i))
        if x == -1:
            continue
        else:
            for j in range(10):
                y = s.find(str(j), x + 1)
                if y == -1:
                    continue
                else:
                    for k in range(10):
                        z = s.find(str(k), y + 1)
                        if z == -1:
                            continue
                        else:
                            cnt += 1

    print(cnt)


resolve()

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

using namespace std;

int main(){
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if(s[i]=='7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
ll A[200010];
ll sums[200010];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) sums[i + 1] = sums[i] + A[i];

    ll ans = 1LL << 60;
    // [0, i) [i, N) に分ける
    for(int i = 2; i < N - 1; i++){
        vector<int> bef, aft;
        {
            int lb = -1;
            int ub = i;
            while(ub - lb > 1){
                int mid = (ub + lb) / 2;
                ll a = sums[mid + 1];
                ll b = sums[i] - sums[mid];
                if(a >= b) ub = mid;
                else lb = mid;
            }
            if(ub > 0) bef.push_back(ub - 1);
            bef.push_back(ub);
        }
        {
            int lb = i - 1;
            int ub = N;
            while(ub - lb > 1){
                int mid = (ub + lb) / 2;
                ll a = sums[mid + 1] - sums[i];
                ll b = sums[N] - sums[mid];
                if(a >= b) ub = mid;
                else lb = mid;
            }
            if(ub > i) aft.push_back(ub - 1);
            aft.push_back(ub);
        }
        for(int b : bef){
            for(int a : aft){
                int f1 = 0;
                int t1 = b;
                int f2 = b + 1;
                int t2 = i - 1;
                int f3 = i;
                int t3 = a;
                int f4 = a + 1;
                int t4 = N - 1;
                ll v1 = sums[t1 + 1] - sums[f1];
                ll v2 = sums[t2 + 1] - sums[f2];
                ll v3 = sums[t3 + 1] - sums[f3];
                ll v4 = sums[t4 + 1] - sums[f4];
                ll vs[] = {v1, v2, v3, v4};
                sort(vs, vs + 4);
                ans = min(ans, vs[3] - vs[0]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
from itertools import product
N, K = map(int, input().split())
D = set(map(int, input().split()))
C = set(i for i in range(10))
C -= D
B = sorted(str(c) for c in C)
for i in range(1, 10):
    for p in product(B, repeat=i):
        s = "".join(p)
        if int(s) >= N:
            print(s)
            exit()


Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
A,B,N=map(int,input().split())

num=N//B
if num==0:
    n=N
else:
    n=B*num-1

#print(n)
temp1=(A*n)/B//1
temp2=A*((n/B)//1)

print(int(temp1-temp2))


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,k,a,b;
    cin >> n >> k;
    vector<pair<ll, ll>> ab(n);
    rep(i, n){
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());
    rep(i, n){
        k -= ab[i].second;
        if (k <= 0) {
            cout << ab[i].first << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#define ll long long int
#define f(i,n) for(long long int i=0;i<n;i++)
#define fx(i,x,n) for(long long int i=x;i<n;i++)
#define fxe(i,x,n) for(long long int i=x;i<=n;i++)
#define MAX 1000000
#include<bits/stdc++.h>
using namespace std;
int main(){
    ll x,a,b;
    cin>>x>>a>>b;
    ll left=x-a;
    cout<<left-b*(left/b);
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int add = a + b;
    int sub = a - b;
    int mul = a * b;
    int m = max(add, sub);
    m = max(m, mul);
    cout << m;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<ll> A(N);
    REP(i,N)A[i] = in<ll>();
    vector<ll> B(0);
    sort(ALL(A),greater<>());
    REP(i,N){
        if(A[i] == A[i+1]){
            B.pb(A[i]);
            A[i+1] = 0;
        }
        if(B.size() == 2)break;
    }
    if(B.size() == 2){
        cout << B[0]*B[1] << "\n";
    }else{
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    readLine()
    var inputs = readLine()!!.split(" ").map(Integer::parseInt).toList()

    var count: Int = 0
    
    while(inputs.filter { it % 2 == 1 }.size == 0) {
        inputs = inputs.map { it / 2}
      	count++
    } 
    
    println(count)
}

Measured memory_bytes: 37748
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   ll n;
   cin>>n;
   ll a[n];
   lp(0,n) cin>>a[i];
   ll b[n];
   lp(0,n) b[i]=a[i];
   ll ans=0;
   ll mod = 1000000007;
   for(int j=n-2; j>=0; j--){
       a[j] = (a[j]+a[j+1])%mod;
   }
   lp(0,n-1){
       ans = (ans + (b[i]*a[i+1])%mod)%mod;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 6820
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int n,Q;
char s[N];
class BIT{
public:
	vector<int>sum;
	void init(int SIZE){
		sum.resize(SIZE,0);
	}
	void ins(const int &x,const int &v){
		for(int i=x;i<=n;i+=i&-i)sum[i]+=v;
	}
	int ask(const int &x)const {
		int ans=0;
		for(int i=x;i;i&=i-1)ans+=sum[i];
		return ans;
	}
}bit[26];
int main(){
	cin>>n;
	scanf("%s",s+1);
	for(int i=0;i<26;i++)bit[i].init(n+1);
	for(int i=1;i<=n;i++)bit[s[i]-'a'].ins(i,1);
	scanf("%d",&Q);
	while(Q--){
		int op;
		scanf("%d",&op);
		if(op==1){
			int x;char c;
			scanf("%d %c",&x,&c);
			if(s[x]==c)continue;
			bit[s[x]-'a'].ins(x,-1);
			bit[c-'a'].ins(x,1);
			s[x]=c;
		}else{
			int l,r;
			scanf("%d%d",&l,&r);
			int ans=0;
			for(int i=0;i<26;i++)ans+=bit[i].ask(r)-bit[i].ask(l-1)>0;
			printf("%d\n",ans);
		}
	}		
}


Measured memory_bytes: 51584
#include <algorithm>
#include <cassert>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

#define all(x) begin(x), end(x)

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    a[i] = i + 1;
  }
  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; ++i) {
      cin >> p[i];
  }
  for (int i = 0; i < n; ++i) {
      cin >> q[i];
  }
  bool contig[2] = {true, true};
  int res[2] = {-1, -1};
  int count = 1;
  do {
      if (a == p) {
          res[0] = count;
      }
      if (a == q) {
          res[1] = count;
      }
    count++;
  } while (std::next_permutation(a.begin(), a.end()));

  cout << abs(res[0] - res[1]) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool yoko( char key, int i, char data[3][3] ){
	if( data[0][i] == key && data[1][i] == key && data[2][i] == key ) return true;
	return false;
}

bool tate( char key, int i, char data[3][3] ){
	if( data[i][0] == key && data[i][1] == key && data[i][2] == key ) return true;
	return false;
}

bool hantei( char key, char data[3][3] )
{
	for( int i = 0;i < 3;i++ ){
		if( yoko( key, i, data ) ) return true;
		if( tate( key, i, data ) ) return true;
	}

	if( data[0][0] == key && data[1][1] == key && data[2][2] == key ) return true;

	if( data[2][0] == key && data[1][1] == key && data[0][2] == key ) return true;
	 return false;
}

int main(void)
{
	char data[3][3];

	while( true ){
		for( int i = 0;i < 3;i++ ){
			for( int j = 0;j < 3;j++ ){
				if( !( cin >> data[i][j] ) ) return 0;
			}
		}

		if( hantei( 'o', data ) ){
			cout << "o" << endl;
			continue;
		} else if( hantei( 'x', data ) ){
			cout << "x" << endl;
			continue;
		}

		cout << 'd' << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    a = collections.defaultdict(list)
    for _ in range(m):
        a[int(input().rstrip('\n'))]
    ls = [0] * (n + 1)
    ls[0] = 1 if 0 not in a else 0
    ls[1] = 1 if 1 not in a else 0
    for i in range(2, n + 1):
        if i not in a:
            ls[i] = (ls[i-1] + ls[i-2]) % mod
        else:
            ls[i] = 0
    print(ls[-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 52696
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N<10)
  {
    cout << N << endl;
  }
  else if(10<=N&&N<100)
  {
    cout << 9 << endl;
  }
  else if(100<=N&&N<1000)
  {
    cout << 9+N-99 << endl;
  }
  else if(1000<=N&&N<10000)
  {
    cout << 909 << endl;
  }
  else if(10000<=N&&N<100000)
  {
    cout << 9+900+N-9999 << endl;
  }
  else
  {
    cout << 90909 <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
ABCD=input()
A,B,C,D=int(ABCD[0]),int(ABCD[1]),int(ABCD[2]),int(ABCD[3])

l={'+++':A+B+C+D,
   '++-':A+B+C-D,
   '+--':A+B-C-D,
   '+-+':A+B-C+D,
   '-++':A-B+C+D,
   '-+-':A-B+C-D,
   '--+':A-B-C+D,
   '---':A-B-C-D}

for key,value in l.items():
    if value==7:
        print(str(A)+key[0]+str(B)+key[1]+str(C)+key[2]+str(D)+'=7')
        break

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<double>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)A[i]=1.0/A[i];
  double sum=0;
  for(auto it:A)sum+=it;
  cout<<fixed<<setprecision(20)<<1/sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	long long int n;
	long long int k;
	cin >> n >> k;
	vector<long long int>s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	if (k >= s.size()) {
		cout << 0;
		return 0;
	}
	else {
		sort(s.begin(), s.end(), greater<long long int>());
		long long int ans = 0;
		for (int i = k; i < s.size(); i++) {
			ans = ans + s[i];
		}
		cout << ans;
	}
}


Measured memory_bytes: 2548
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();

            HashSet<State> used = new HashSet<>();
            used.add(new State(A, B, C));

            int count = 0;
            for (;; count++) {
                if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
                    System.out.println(count);
                    break;
                }

                int nextA = B / 2 + C / 2;
                int nextB = A / 2 + C / 2;
                int nextC = A / 2 + B / 2;

                A = nextA;
                B = nextB;
                C = nextC;

                boolean add = used.add(new State(A, B, C));

                if (add == false) {
                    System.out.println(-1);
                    break;
                }
            }

        }
    }
}

class State {
    int a;
    int b;
    int c;

    public State(int a, int b, int c) {
        super();
        this.a = a;
        this.b = b;
        this.c = c;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + a;
        result = prime * result + b;
        result = prime * result + c;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        State other = (State) obj;
        if (a != other.a)
            return false;
        if (b != other.b)
            return false;
        if (c != other.c)
            return false;
        return true;
    }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

double dp[3000][3000];

void solve() 
{
    int n;cin>>n;
    dp[0][0]=1;
    double p;
    REP(i,n){
        cin>>p;
        REP(j,i+1){
            dp[i+1][j]+=dp[i][j]*p;
            dp[i+1][j+1]+=dp[i][j]*(1-p);
        }
    }
    p=0;
    REP(i,(n+1)/2)p+=dp[n][i];
    //REP(i,n+1){REP(j,i+1)cout<<dp[i][j]<<" ";cout<<endl;}
    cout<<fixed<<setprecision(10)<<p<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 68864
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,begin,end) for(int i=(begin),i##_end = (end);i<i##_end;i++)

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<iomanip>
//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;


int main()
{
	int N;
	cin >> N;
	static long array[2000000] = { 0 }, b[2000000] = { 0 }, c[2000000] = { 0 }, e[2000000] = { 0 }, d = 0;
	for (int x = 0; x < N; x++)cin >> array[x];
	//sort(array, array + SIZE_OF_ARRAY(array), greater<>());
	for (int x = 0; x < N; x++) {
		b[array[x]]++;
	}
	for (int x = 1; x <= N; x++) {
		if (b[x] >= 1)
			c[x] = b[x] * (b[x] - 1) / 2;
	}
	for (int x = 1; x <= N; x++) {
		if (b[x] >= 2)
			e[x] = (b[x] - 1)* (b[x] - 2) / 2;
	}
	for (int x = 1; x <= N; x++)d += c[x];
	for (int x = 0; x < N; x++)cout << d - c[array[x]] + e[array[x]] << endl;
	return 0;
}

Measured memory_bytes: 15488
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int min( int a, int b) { return a < b ? a : b;}
int main(){
	int n, k;
	const int ias = 2000100000;
	scanf("%d %d", &n, &k);
        int h[n];
	for(int i = 0; i < n ; i++)scanf("%d", &h[i]);
	int dp[n];
	for(int i = 0; i < n; i++)dp[i] = ias;
	//dp[i] is the min cost to reach i from initial pos
	dp[0] = 0;
	for(int i = 1; i < n; i++)
	{	
		for(int j = 1; j <= k && i - j >= 0; j++){
			dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
		}
	} 
	printf("%d", dp[n -1]);

}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  string S;
  cin >> N >> K >> S;
  int cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == S[i + 1]) cnt++;
  }
  cout << min(N - 1, cnt + 2 * K) << '\n';
  return 0;
}


Measured memory_bytes: 512
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int ans = (H2 * 60 + M2 - K) - (H1 * 60 + M1);
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[225816],segtree[816225],ans[225816];
std::vector<int> g[225816];
std::set<int> st;

void solve(int v, int p){
	int u,i,sv;
	if(st.lower_bound(a[v])==st.end()){
		sv = INF;
	}else{
		sv = *st.lower_bound(a[v]);
		st.erase(sv);
	}
	st.insert(a[v]);
	ans[v] = st.l_ength();
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(u == p){
			continue;
		}
		solve(u,v);
	}
	st.erase(a[v]);
	if(sv<INF){
		st.insert(sv);
	}
}

int main(void){
	int n,u,v,i;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	for(i=1; i<n; ++i){
		std::cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	solve(0,-1);
	for(i=0; i<n; ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 30948
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
ll ans[100005] = {};
int main() {
	int n;
	cin >> n;
	vector<ll>A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	ll ans = 0;
	ll count = 1;
	for (int i = 0; i < n-1; i++) {
		if (A[i] == A[i + 1]) {
			count++;
		}
		else {
			if (count % 2 == 1) {
				ans++;
			}
			count = 1;
		}
	}
	if (count % 2 == 1) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int n,a = 0;
    bool ans = true;
    cin >> n;
    rep(i,n){
        string str;
        cin >> str;
        if(str == "A") a++;
        else a--;
        if(a < 0) ans = false;
    }
    if(a != 0) ans = false;
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3156
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef long long ll;

template<class T>
bool chmin(T& a, const T& b) {
    if(b<a) {
        a=b;
        return true;
    }

    return false;
}

struct Edge {
    int to,cost;
    int h,r;
    Edge(int to,int cost,int h,int r) :
        to(to),cost(cost),h(h),r(r){}
};
struct Passport{
    int len;
    int d;
    int S;
    int comps[10];
};

int N,M,H,K;
vector<Edge> G[102];
vector<Passport> pass;

typedef pair<int,pair<int,int> > Pi;
int d[102][30];
int dijk(int s,int t,int S) {
    typedef pair<int,int> P;
    rep(i,102) rep(j,30) d[i][j]=INF;
    d[s][0]=0;

    priority_queue<Pi,vector<Pi>,greater<Pi> > que;
    que.push(Pi(0,P(s,0)));

    while(que.size()) {
        Pi pi=que.top(); que.pop();
        int v=pi.sc.fr;
        int h=pi.sc.sc;

        rep(i,G[v].size()) {
            Edge e=G[v][i];
            int cost = e.cost;
            if((S>>e.r)&1) {
                cost=0;
            }

            if(h+e.h<=H && chmin(d[e.to][h+e.h],d[v][h]+cost)) {
                que.push(Pi(d[e.to][h+e.h],P(e.to,h+e.h)));
            }
        }
    }

    int ret=INF;
    rep(i,H+1) chmin(ret,d[t][i]);

    return ret;
}

int dp[300][1<<8];
int calc_dp() {
    dp[0][0]=0;
    // dp[i][S] i番目までSを作るときの最小コスト
    rep(i,pass.size()) rep(S,1<<8) {
        int d=pass[i].d;
        int S_n=S|pass[i].S;

        chmin(dp[i+1][S_n],dp[i][S]+d);
        chmin(dp[i+1][S],dp[i][S]);
    }

}

void solve() {
    rep(i,300) rep(j,1<<8) dp[i][j]=INF;
    int P;
    int s,t;
    rep(i,102) G[i].clear();
    pass.clear();
    rep(i,M) {
        int a,b,c,h,r;
        cin>>a>>b>>c>>h>>r;
        r--;
        G[a].pb(Edge(b,c,h,r));
        G[b].pb(Edge(a,c,h,r));
    }
    cin>>s>>t;
    cin>>P;
    pass.resize(P);
    rep(i,P) {
        int l,d;
        cin>>l>>d;
        pass[i].len=l;
        pass[i].d=d;
        int Set=0;
        rep(j,l) {
            int k;
            cin>>k;
            k--;
            Set|=1<<k;
            pass[i].S=Set;
        }
    }

    calc_dp();

    int ans=INF;
    // rep(i,1<<3) printf("%d %d\n",i,dp[2][i]);
    rep(S,1<<8) {
        chmin(ans, dijk(s,t,S)+dp[pass.size()][S]);
    }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;

}

int main() {
    while(cin>>N>>M>>H>>K) {
        if(N+M+H+K==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int M;

vvi mat_mul(const vvi &A, const vvi &B) {
    int sn = sz(A);
    int sm = sz(A[0]);
    assert(sz(B) == sm);
    int sl = sz(B[0]);

    vvi ret(sn, vi(sl));
    rep(y, 0, sn) {
        rep(x, 0, sl) {
            int tmp = 0;
            rep(k, 0, sm) {
                tmp += A[y][k] * B[k][x] % M;
                tmp %= M;
            }
            ret[y][x] = tmp;
        }
    }
    return ret;
}

vvi mat_pow(vvi A, int pw) {
    assert(sz(A) == sz(A[0]));
    int size = sz(A);
    
    vvi ret(size, vi(size, 0));
    rep(i, 0, size) ret[i][i] = 1;

    while (pw) {
        if (pw & 1) {
            ret = mat_mul(ret, A);
        }
        A = mat_mul(A, A);
        pw >>= 1;
    }
    return ret;
}

signed main() {
    int L, A, B;
    cin >> L >> A >> B >> M;
    vi first(21), last(21);

    int p = 10;
    rep(k, 1, 19) {
        last[k] = (p - A - 1) / B;
        if (last[k] < 0) {
            last[k] = -1;
        }
        first[k + 1] = last[k] + 1;
        p *= 10;
    }
    
    vvi v = {{0}, {A % M}, {B % M}};
    p = 10;
    rep(k, 1, 19) {
        int num = last[k] - first[k] + 1;
        if (first[k] > L) break;
        if (last[k] > L - 1) {
            num = L - 1 - first[k] + 1;
        }
        chmax(num, 0);
        dump(k, first[k], last[k]);

        vvi X = {{p % M, 1, 0}, {0, 1, 1}, {0, 0, 1}};
        X = mat_pow(X, num);
        v = mat_mul(X, v);
        p *= 10;
    }
    cout << v[0][0] << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int c = 0;
	string s;
	cin >> s;
	rep(i, 3) if (s[i] == 'o') c++;
	cout << 700 + c * 100 << endl;
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String firstStr = fs.nextLine();
		
		StringBuffer frontStr = new StringBuffer();
		StringBuffer tailStr = new StringBuffer();
		
		int inverceCnt=0;
		int q = fs.nextInt();
		
		for(int i = 0; i < q; i++) {
			int queryNum = fs.nextInt();
			if(queryNum == 1) {
				inverceCnt++;
			}else {
				int posNum = fs.nextInt();
				// 前付け
				if((inverceCnt % 2 == 0 && posNum == 1) || (inverceCnt % 2 == 1 && posNum == 2)) {
					frontStr.insert(0, fs.next());
				}else {
					tailStr.append(fs.next());
				}
			}
		}
		
		StringBuffer ans = new StringBuffer();
		ans.append(frontStr).append(firstStr).append(tailStr);
		String ansStr = ans.toString();
		if(inverceCnt % 2 == 0) {
			System.out.println(ansStr);
		}else {
			for(int i = 0; i < ansStr.length(); i++) {
				System.out.print(ansStr.charAt(ansStr.length() - i - 1));
			}
			System.out.print("\n");
		}
	}
	
	public class FastScanner {
		
		BufferedReader reader;
		private StringTokenizer st;
		
		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		
		public String next() throws IOException {
			if(st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}
		
		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}
		
		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		
		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for(int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}
		
		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for(int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}
		
		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 46888
def inpl():
    return list(map(int, input().split()))


L, R = inpl()

if R - L >= 673:
    print(0)
    exit()

ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int f=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;a--;
        f+=a;
    }
    cout<<f<<endl;
    return 0;
}


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

struct segtree{
private:
  vector<ll> node;
  int siz;
public:
  segtree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,(ll)2147483647);
  }
  void upd(int pos,int x){
    pos+=siz-1;
    node[pos]=x;
    while(pos>0){
      pos=(pos-1)/2;
      node[pos]=min(node[pos*2+1],node[pos*2+2]);
    }
  }
  ll get_min(int a,int b,int pos,int l,int r){
    if(a<=l&&r<=b) return node[pos];
    if(r<=a||b<=l) return 2147483647;
    int mid=(l+r)/2;
    ll lb=get_min(a,b,pos*2+1,l,mid);
    ll rb=get_min(a,b,pos*2+2,mid,r);
    return min(lb,rb);
  }
  ll min_q(int a,int b){
    return get_min(a,b,0,0,siz);
  }
};

struct seg2ree{
private:
  vector<ll> node;
  int siz;
public:
  seg2ree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,0);
  }
  void upd(int pos,int x){
    pos+=siz-1;
    node[pos]=x;
    while(pos>0){
      pos=(pos-1)/2;
      node[pos]=max(node[pos*2+1],node[pos*2+2]);
    }
  }
  ll get_max(int a,int b,int pos,int l,int r){
    if(a<=l&&r<=b) return node[pos];
    if(r<=a||b<=l) return 0;
    int mid=(l+r)/2;
    ll lb=get_max(a,b,pos*2+1,l,mid);
    ll rb=get_max(a,b,pos*2+2,mid,r);
    return max(lb,rb);
  }
  ll max_q(int a,int b){
    return get_max(a,b,0,0,siz);
  }
};
ll sbubun[200005];
int main(){
  vector<ll> vec;
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  sbubun[n-1]=1;
  for(int i=n-2;i>=0;i--){
    if(vec[i]<vec[i+1]) sbubun[i]=sbubun[i+1]+1;
    else sbubun[i]=1;
  }

  //for(int i=0;i<n;i++) cout<<sbubun[i]<<" ";
  //cout<<endl;

  segtree seg=segtree(n+5);
  seg2ree seg2=seg2ree(n+5);
  for(int i=0;i<n;i++) {
    seg.upd(i,vec[i]);
    seg2.upd(i,vec[i]);
  }
  ll ans=1;
  ll f=0;
  if(sbubun[0]>=k) {
    f=1;
    ans=0;
  }
  for(int i=0;i+k<n;i++){
    if(sbubun[i+1]>=k){
      f=1;
    //  cout<<"F1";
    }
    else if(vec[i]!=seg.min_q(i,i+k)||vec[i+k]<seg2.max_q(i,i+k)) {
      ans++;
    //  cout<<"F2";
    }
  //  cout<<vec[i]<<" "<<seg.min_q(i,i+k)<<" "<<vec[i+k]<<" "<<seg2.max_q(i,i+k)<<endl;
  }
  cout<<ans+f<<endl;
}


Measured memory_bytes: 12144
s = input()
n = len(s)
def palindrome(string):

    if(string == string[::-1]):

        return 0

    else:

        return 1

first = palindrome(s)
if(first == 0):
    second = palindrome(s[0:(n-1)//2])
    if(second == 0):
        third = palindrome(s[((n+3)//2)-1:n])
        if(third == 0):
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

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

using namespace std;

int main(){
    int N;
    cin >>N;
    vector<int> vec(N);
    int S=0;
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
        S+=vec.at(i);
    }
    
    int ans;
    sort(vec.begin(), vec.end());
    if(S%10==0){
        for(int i=0; i<N; i++){
            if(vec.at(i)%10!=0){
                ans=S-vec.at(i);
                break;
            }
            else{
                ans=0;
            }
            
            
        }
    }
    else{
        ans=S;
    }
    
    cout << ans <<endl;
}
        

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
using namespace std;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)

int main(){
  double A, B, H, M, theta_ji, theta_fu, d;
  pair <double, double> P_ji, P_fu;
  cin >> A >> B >> H >> M;
  theta_ji = 2 * M_PI / 12 * (H + M / 60);
  theta_fu = 2 * M_PI / 60 * M;
  P_ji.first = A * cos(theta_ji);
  P_ji.second = A * sin(theta_ji);
  P_fu.first = B * cos(theta_fu);
  P_fu.second = B * sin(theta_fu);
  d = sqrt(pow(P_ji.first-P_fu.first, 2) + pow(P_ji.second-P_fu.second, 2));
  cout << setprecision(30) << d << endl;
  return 0;
}

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

int main(){
  int ans = 0;
  int N;  cin >> N;
  long long D;  cin >> D;
  long long sikii = D*D;
  for(int i=0;i<N;i++){
    long long x,y;  cin >> x >> y;
    if(x<0) x *= -1;
    if(y<0) y *= -1;
    if(x > D || y > D)  continue;
    long long d = x*x + y*y;
    if(d <= sikii){
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : actualN(n), N(calcN_(n)), def(def), mVal(2*calcN_(n), def) {}
    void update(int idx, T value){
        int i = N + idx;
        update_(mVal[i], value);
        for(int t=i/2;t>=1;t/=2){
            mVal[t] = operate(mVal[2*t], mVal[2*t+1]);
        }
    }
    T get(int l, int r){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        T resL = def;
        T resR = def;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ resL = operate(resL, mVal[offset+l]); l++; }
            if(r&1){ resR = operate(mVal[offset+r-1], resR); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
        return operate(resL, resR);
    }
    int maxRight(int l, T v){
        l = max(0, l) + N;
        T resL = def;
        while(l){
            if(l&1){
                T next = operate(resL, mVal[l]);
                if(next >= v){
                    while(l < N){
                        l *= 2;
                        next = operate(resL, mVal[l]);
                        if(next < v){
                            resL = next;
                            ++l;
                        }
                    }
                    return l - N;
                }
                resL = next;
                if(!(l&(l+1))) break;
                l++;
            }
            l /= 2;
        }
        return actualN;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return max(a, b); }
    const int N;
    const int actualN;
    const T def;
    vector<T> mVal;
};

int main(){
    int N, Q; cin >> N >> Q;
    SegTree<int> seg(N, 0);
    for(int i=0;i<N;i++){
        int a; cin >> a;
        seg.update(i, a);
    }
    for(int i=0;i<Q;i++){
        int t, x, v; cin >> t >> x >> v;
        if(t==1){
            seg.update(x-1, v);
        } else if(t==2){
            cout << seg.get(x-1, v) << endl;
        } else {
            cout << seg.maxRight(x-1, v) + 1 << endl;
        }
    }
}

Measured memory_bytes: 5280
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N;
  cin >> N;
  vector<ll> H(N);
  ll mx = -1;
  REP(i, N) {
    ll a;
    cin >> a;
    if(a<mx){
      puts("No");
      return 0;
    }
    if(mx==a){
      mx = max(mx, a);
    }else if(mx<a+2){
      mx = max(mx, a - 1);
    }else if(mx==a+1){
      mx = max(mx, a-1);
    }
    
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 200005;
const ll M = 100005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        rep(i, n){
            cin >> a[i];
            if(!i){
                cnt = a[i];
            }else{
                cnt = gcd(cnt, a[i]);
            }
            maxs(mx, a[i]);
        }
        if(m > mx || m % cnt){
            print("IMPOSSIBLE");
            return 0;
        }else{
            print("POSSIBLE");
        }
    }
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();
		int odd = 0, even = 0;
		if(total == 1){
			System.out.println("YES");
		}
		for (int i = 0; i < total; i++) {
			if (sc.nextInt() % 2 == 0) {
				even++;
			} else {
				odd++;
			}
		}
		if (odd % 2 != 0) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 30200
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main(){
    
    ll n,a[6];
    
    cin >> n>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
    
    ll ans=0;
    ll rt;
    ll tamari=n;
    
    //最後尾の人が待ち始めた時に何人の人がいるのか
    
    for(int i=1;i<=5;i++){
        if(tamari>a[i]){
            if(tamari%a[i]==0){
                ans+=tamari/a[i]-1;
            }else{
                ans+=tamari/a[i];
            }
        }
        ans++;//t=ansに次の駅に町に着く
        if(i==5)break;
        rt=tamari%a[i];
        tamari=max(n-rt-a[i+1]*(ans-i),(ll)0)+rt;
        
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;

class MainClass
{
    public static void Main(string[] args)
    {
        string str=Console.ReadLine();
        int w=Convert.ToInt32(str.Split(' ')[0]);
        int h=Convert.ToInt32(str.Split(' ')[1]);
        int x=Convert.ToInt32(str.Split(' ')[2]);
        int y=Convert.ToInt32(str.Split(' ')[3]);
        int r=Convert.ToInt32(str.Split(' ')[4]);

        if((x-r)>=0&&(y-r)>=0&&(x+r)<=w&&(y+r)<=h){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 9012
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,W = mi()
vl=[-1]*(W+1)
w_list=[]
for i in range(n):
    vt,wt =mi()
    if wt>W: continue
    vl[wt] = max(vl[wt], vt)
for k,i in enumerate(vl):
    if i!= -1:
        w_list.append(k)
dp = [0]*(W+1)
for i in w_list:
    w = i
    v = vl[w]
    for i in range(w,W+1):
        dp[i] = max(dp[i],dp[i-w]+v)
print(dp[W])



Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))
 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
void solve() {

    string s;
    cin >>s;
    ll ans=0;
    for(auto u:s)
    {
        ans+=u-'0';
    }
    if(ans%9==0)
    {
        cout <<"Yes\n";
    }
    else
    {
        cout <<"No\n";
    }
}
 
int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solve();
    return 0;
}

Measured memory_bytes: 3740