akhauriyash/Code-Regression huggingface dataset:
N = int(input())

divisors = [[] for _ in range(N + 1)]

for i in range(1, N + 1):
    num = 2 * i
    while num <= N:
        divisors[num].append(i)
        num += i
ans = []
balls = [0] * (N + 1)
A = [int(x) for x in input().split()]
for i in reversed(range(1, N+1)):
    if balls[i] != A[i-1]:
        ans.append(i)
        balls[i] ^= 1
        for d in divisors[i]:
            balls[d] ^= 1

print(len(ans))
if ans:
    print(*ans)


Measured memory_bytes: 125360
def examA():
    X = I()
    X -= 400
    ans = 8 - X//200
    print(ans)
    return

def examB():
    A, B, C = LI()
    K = I()
    cnt = 0
    while(A>=B):
        B *= 2
        cnt += 1
    while(B>=C):
        C *= 2
        cnt += 1

    if cnt<=K:
        print("Yes")
    else:
        print("No")
    return

def examC():
    N, K = LI()
    A = LI()
    ans = ["Yes"]*(N-K)
    for i in range(N-K):
        if A[i+K]<=A[i]:
            ans[i] = "No"
    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 33108
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <bitset>
#include <functional>

using namespace std;

#define FOR(i,n) 		for(int(i)=0;(i)<(int)(n);(i)++)
#define FORN(i,a,b,c) 	for(int(i)=a;i<(int)(b);i+=(c))
#define RES(x,nilai)	memset(x,nilai,sizeof(x));
#define pb              push_back
#define mp              make_pair
#define INF				1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

inline string IS(int a){
    char x[100];
    sprintf(x,"%d",a); string s = x;
    return s;
}

inline int SI(string a){
    char x[100]; int res;
    strcpy(x,a.c_str()); sscanf(x,"%d",&res);
    return res;
}

//==============================================

bool cmp(int x,int y) {return x>y;}

ll x,y;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("13.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	while (cin >> x >> y) {
		x += y;
		int ans = 0;
		while (x > 0) {
			x/=10;
			ans++;
		} cout << ans << endl;
		
	}
		
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    string S;
    cin >> S;
    if (S[2]==S[3] and S[4]==S[5]) cout << "Yes" << endl;
    else cout <<"No" << endl;
}


Measured memory_bytes: 3560
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50 == x:
                ans += 1

print(ans)

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

#define INF (1 << 30)

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m, x, ans = INF;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector< vector<int> > a(n, vector<int>(m));
    for (int i = 0; i < n; ++i) {
        cin >> c.at(i);
        for (int j = 0; j < m; ++j) cin >> a.at(i).at(j);
    }
    for (int i = 0; i < (1 << n); ++i) {
        bool f = true;
        int tc = 0;
        vector<int> v(m);
        for (int j = 0; j < n; ++j) if (i & (1 << j)) {
            tc += c.at(j);
            for (int k = 0; k < m; ++k) v.at(k) += a.at(j).at(k);
        }
        for (int k = 0; k < m; ++k) if (v.at(k) < x) f = false;
        if (f) {
            ans = min(ans, tc);
        }
    }
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
const int MAX=2e5+5;
const int MAAX=1e9;
const int MOD=1e9+7;
int n,a[MAX],inp[MAX];
in main()
{

cin>>n;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    inp[i]=a[i];
}
sort(a,a+n);
for(int i=0;i<n;i++)
{
    cout<<a[n-1-(inp[i]==a[n-1])]<<endl;
}
    return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		used = new boolean[n];
		v = new int[n];
		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();
		}

		System.out.println(dfs(0, n));

	}

	static boolean used[];
	static int v[];
	static int c[];

	static int dfs(int depth, int n){
		if(depth == n){
			int result = 0;
			for(int i = 0; i < n; i++){
				if(used[i]){
					result += v[i] - c[i];
				}
			}

			return result;
		}

		int result = Integer.MIN_VALUE;;
		used[depth] = false;
		result = Math.max(result, dfs(depth + 1, n));
		used[depth] = true;
		result = Math.max(result, dfs(depth + 1, n));

		return result;
	}
}


Measured memory_bytes: 23128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5+5;
int n,q,pre[maxn],clr[maxn],ans[maxn];
int lsb(int x){
	return (x&(-x));
}	
int bit[maxn];
void add(int x,int z){
	while (x<=n){bit[x]+=z;x+=lsb(x);}	
}
int query(int x){
	int ans = 0;
	while (x){
		ans += bit[x];
		x -= lsb(x);
	}
	return ans;
}
struct quest{
	int id,l,r;
	bool operator < (const quest &b) const {
		return r < b.r;	
	}
} qs[maxn];

int main(){
	cin >> n >> q;
	for (int i=1;i<=n;i++){
		scanf("%d",&clr[i]);
		pre[i]=ans[clr[i]];		
		ans[clr[i]]=i;
	}
	for (int i=1,l,r;i<=q;i++){
		scanf("%d%d",&l,&r);
		qs[i]=(quest){i,l,r};	
	}
	sort(qs+1,qs+q+1);
	int bd=0;
	for (int i=1;i<=q;i++){
		while (qs[i].r > bd) add(pre[++bd]+1,1);
		ans[qs[i].id]=query(qs[i].l)-qs[i].l+1;
	}
	for (int i=1;i<=q;i++){
		printf("%d\n",ans[i]);	
	}
	return 0;
}

Measured memory_bytes: 17188
#include <stdio.h>
#include <math.h>

int main()
{
	int		a,b,h,m;

	double	ax,ay;
	double	bx,by;
	double  cx,cy;
	double  ab;
	double pai = 3.141592653589793238462643383279L;
	
	scanf("%d %d %d %d", &a, &b, &h, &m);

	ax = a *  sinl( (((2*pai) / 12) * h) + ((((2*pai) / 12) / 60) * m));
	ay = a * -cosl( (((2*pai) / 12) * h) + ((((2*pai) / 12) / 60) * m));

	bx = b * sinl(((2*pai) / 60) * m);
	by = b * -cosl(((2*pai) / 60) * m);
/*
	printf("%lf %lf\n", ax,ay);
	printf("%lf %lf\n", bx,by);
*/
	cx = fabs(ax - bx);
	cy = fabs(ay - by);
	ab = sqrt((cx*cx) + (cy*cy));

/*	printf("%lf %lf\n", cx,cy);*/
	printf("%22.20lf\n", ab);
/*
//5.00000000000000000000
//4.56425719433005567605
//4.56425719433005383507
*/
    return 0;
}


Measured memory_bytes: 2524
import collections

n, m = map(int, input().split())
if m == 0:
    print(1)
    exit()
if m == 1:
    print(2)
    exit()
boss = list(range(n))

def look_boss(target):
    num = target
    while num != boss[num]:
        num = boss[num]
    boss[target] = num
    return num

for _ in range(m):
    a, b = map(int, input().split())
    boss_a = look_boss(a-1)
    boss_b = look_boss(b-1)
    if boss_a != boss_b:
        boss[boss_b] = boss_a

count = [0]*n
for i in range(n):
    count[look_boss(i)] += 1
print(max(count))


Measured memory_bytes: 18760
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll D[5];
int P[10]={0,0,0,0,0,0,1,1,1,2};
int Q[10]={1,1,1,2,2,3,2,2,3,3};
int R[10]={2,3,4,3,4,4,3,4,4,4};

int main(int argc, char const *argv[]) {
  int N; cin >> N;
  string s;
  map<char,ll> dict;
  REP(i,N) {
    cin >> s;
    dict[s[0]]++;
  }
  ll ans=0;
  string march="MARCH";
  REP(i,5) D[i]=dict[march[i]];
  REP(i,10) ans+=D[P[i]]*D[Q[i]]*D[R[i]];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let mut ans = 0.0;
    for _ in 0..n {
        let l = scan!();
        let mut iter = l.split_whitespace();
        let x = iter.next().unwrap().parse::<f64>().unwrap();
        let u = iter.next().unwrap();
        if u == "JPY" {
            ans += x
        } else {
            ans += x * 380_000.0;
        }
    }
    println!("{}", ans)
}


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

int main(){
    int n, l, s;
    int minl;
    cin >> n >> l;
    s = n * (l - 1) + n * (n + 1) / 2;
    minl = abs(l);
    for ( int i = 0; i < n ; i++){
        minl = min (minl, abs(l + i));
    }
    if (s >= 0){
        cout << s - minl << endl;
    }
    else{
        cout << s + minl << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        System.out.print(C + " " + A + " "+ B);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <cassert>
using namespace std;
bool is_valid(string const & s) {
    int nest = 0;
    for (char c : s) {
        nest += (c == '(') ? +1 : -1;
        if (nest < 0) return false;
    }
    return nest == 0;
}
int main() {
    int n; string s; cin >> n >> s;
    int dangling_close = 0;
    int dangling_open = 0; {
        int & nest = dangling_open;
        for (char c : s) {
            if (c == '(') {
                nest += 1;
            } else {
                if (nest == 0) {
                    dangling_close += 1;
                } else {
                    nest -= 1;
                }
            }
        }
    }
    s = string(dangling_close, '(') + s + string(dangling_open, ')');
    assert (is_valid(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    rep(i, N) cin >> v[i] >> w[i];
    int dp[W+1];
    fill(dp, dp+W+1, 0);
    rep(i, W+1){
        rep(j, N){
            if(i-w[j] < 0) continue;
            chmax(dp[i], dp[i-w[j]]+v[j]);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <iterator>
typedef long long ll;
typedef unsigned int uint;
using namespace std;


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

    int n;
    cin >> n;

    multiset<ll> st;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        st.insert(a);
    }

    int ans = 0;
    while (!st.empty()) {
        ll mx = *--st.end();
        st.erase(--st.end());

        for (int i = 0; i <= 32; i++) {
            ll mn = (1LL << i) - mx;
            if (st.find(mn) != st.end()) {
                ans++;
                st.erase(st.find(mn));
                break;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 9600
#include <cstdio>
#include <algorithm>
#include <stdint.h>

const int64_t MOD=998244353;

int64_t fact[300001]={1};

int64_t modexp(int64_t base,int64_t exp){
  int64_t ac=1;
  for(;exp>0;exp>>=1){
    if(exp&1) ac=ac*base%MOD;
    base=base*base%MOD;
  }
  return ac;
}

int64_t inverse(int64_t x){
  return modexp(x%MOD,MOD-2);
}

int main(){
  int64_t N,A,B,K;
  scanf("%ld %ld %ld %ld",&N,&A,&B,&K);
  for(int64_t i=1;i<=N;i++){
    fact[i]=fact[i-1]*i%MOD;
    //printf("%ld!=%ld\n",i,fact[i]);
  }
  int64_t j=N;
  int64_t total=0;
  for(int64_t i=0;i<=N;i++){
    while(A*i+B*j>K){
      j--;
    }
    if(j<0) break;
    if(A*i+B*j==K){
      /*
      printf("ADD %ld,%ld =>%ld*%ld\n",i,j,fact[N]*inverse(fact[i]*fact[N-i])%MOD,
	     fact[N]%MOD*inverse(fact[j]*fact[N-j])%MOD);
      */
      total=(total+fact[N]*inverse(fact[i]*fact[N-i])%MOD*
	     fact[N]%MOD*inverse(fact[j]*fact[N-j])%MOD)%MOD;
    }
  }
  printf("%ld\n",total);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;

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

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

   cout<<sum;
   

   return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
ans = ['*'] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] == '*':
        ans[s - 1] = str(c)
    elif ans[s - 1] != str(c):
        print(-1)
        exit()
if ans[0] == '*' and N > 1:
    ans[0] = '1'
print(-1 if ans[0] == '0' and N > 1 else ''.join(ans).replace('*', '0'))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

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

  vector<vector<int>> dp1(N+1, vector<int>(T));
  vector<vector<int>> dp2(N+1, vector<int>(T));

  rep(i,N) {
    rep(j,T) {
      if (j < A[i]) dp1[i+1][j] = dp1[i][j];
      else dp1[i+1][j] = max(dp1[i][j-A[i]] + B[i],dp1[i][j]); 
    }
  }

  rep(i,N) {
    rep(j,T) {
      if (j < A[N-1-i]) dp2[N-1-i][j] = dp2[N-i][j];
      else dp2[N-1-i][j] = max(dp2[N-i][j-A[N-1-i]] + B[N-1-i],dp2[N-i][j]);
    }
  }
  int ans = 0;
  rep(i,N) {
    rep(j,T-1) {
      int k = dp1[i][j] + dp2[i+1][T-1-j] + B[i];
      ans = max(ans,k);   
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7 ;
#define pb push_back
#define all(v) v.begin(),v.end()
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll q,n,m,k,l,y,x,z=0,ans=0,lang; string s ; bool ok ;


void solve()
{
    cin>>n>>m>>q;
    vector < ll > v ;
    for(int i=0;i<n;i++)
    cin>>x,v.pb(x);
    ans = 1e18;
    for(int i=0;i<n;i++)
    {
        vector < pair < ll,ll> > good;
        ll l=0,r=0;
        for(int j=0;j<n;j++)
            if(v[j]>=v[i]){
                l = r = j ;
                while(r<n && v[r]>=v[i]) r++;
                r--;
                good.pb({l,r});
                j=r;
            }

        vector < ll > ok ;
        ok.clear();
        for(int j=0;j<good.size();j++)
            {
                l = good[j].first ; r = good[j].second ;
                priority_queue< ll > pq ;
                for(int k =l;k<=r;k++) pq.push(-1*v[k]);

                for(int k=l;k<=r-m+1;k++)
                {
                    ok.pb(-1*pq.top());
                    pq.pop();

                }


            }
        if(ok.size()<q) continue ;

        sort(all(ok));
        ans = min(ans , ok[q-1]-ok[0]);
    }
    cout<<ans<<'\n';
}






int main()
{


    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    srand (time(NULL));
   // freopen("test.in","r",stdin);
    //freopen("out.txt","w",stdout);
    int t;
     solve();

    return 0;
}


Measured memory_bytes: 384
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    a=list(map(lambda x:int(x)-1,readline().split()))

    flags=[False]*N
    res=0
    for i in range(N):
        j=a[i]
        if flags[j]==False and a[j]==i:
            flags[i]=True
            flags[j]=True
            res+=1

    print(res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 14068
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val w, h, x, y, r = sc.nextInt
  val lx = x - r
  val rx = x + r
  val ly = y - r
  val ry = y + r

  def inBounds(x: Int, y: Int): Boolean = {
    0 <= x & x <= w & 0 <= y & y <= h
  }

  println(if (inBounds(lx, ly) & inBounds(rx, ry)) "Yes" else "No")
}

Measured memory_bytes: 45128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll dp[2020][2020];
int main(void){
    ll n;
    cin>>n;
    vector<pair<ll,ll>>p(n);
    rep(0,i,n){
        cin>>p[i].first;
        p[i].second=i;
    }
    sort(p.rbegin(),p.rend());
    //rep(0,i,n)cout<<P[i].first<<" "<<P[i].second<<endl;
    dp[0][0]=0;
    rep(0,i,n+1)rep(0,j,n+1)dp[i][j]=0;
    //rep(0,i,n+1){rep(0,j,n+1){cout<<dp[i][j]<<" ";}cout<<endl;}
    //rep(0,i,n)cout<<P[i].first<<" "<<P[i].second<<endl;
    rep(0,i,n){
        ll k=p[i].first;
        ll r=p[i].second;
        //cout<<k<<" "<<r<<endl;
        rep(0,x,i+1){
            ll y=i-x;
            //cout<<x<<" "<<y<<endl;
            dp[x+1][y]=max(dp[x+1][y],dp[x][y]+k*abs(x-r));
            dp[x][y+1]=max(dp[x][y+1],dp[x][y]+k*abs(n-1-y-r));
            //cout<<"dp["<<x+1<<"]["<<y<<"]="<<dp[x+1][y]<<endl;
            //cout<<"dp["<<x<<"]["<<y+1<<"]="<<dp[x][y+1]<<endl;
        }
    }
    ll ans=0;
    //rep(0,i,n+1)cout<<dp[n][n-i]<<" ";
    rep(0,i,n+1)ans=max(ans,dp[i][n-i]);
    cout<<ans;
}

Measured memory_bytes: 35244
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define dump(x) cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

int N, A, B;

void solve() {
    cin >> N >> A >> B;
    if (A > B || (N == 1 && A != B)) cout << 0 << endl;
    else cout << ((N - 1) * B + A) - ((N - 1) * A + B) + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<cmath>
#define ll long long
#define eps 1e-8
using namespace std;
struct node
{
    int l,r;
};
int cmp(node a,node b)
{
    if(a.l<b.l)return 1;
    else if(a.l==b.l&&a.r<b.r)return 1;
    return 0;
}
int main()
{
    int n,a,b,ans=0;
    cin>>n;
    vector<node>v;
    for(int i=0;i<n;i++)
    {
        node tmp;
        cin>>tmp.l>>tmp.r;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end(),cmp);
    for(int i=0;i<n;i++)
    {
        if(i!=0)
        {
            if(v[i].l<v[i-1].r&&v[i].r>v[i-1].r)
            {
                ans+=v[i].r-v[i-1].r;
            }else if(v[i].r<=v[i-1].r);
            else ans+=v[i].r-v[i].l+1;
        }
        else ans+=v[i].r-v[i].l+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
#define P pair<ll,ll>
#define fs first
#define sc second
using namespace std;

const ll MOD = 1e9+7;

template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    

    bool operator!() const{return !x;}

    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }

    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }

    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }

    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }

    modint operator-() const{ return modint(-x); }

    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }


    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }

    modint inv() const{
        ll a = x,b = MOD,u = 1,v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a,b);
            u -= t*v; swap(u,v);
        }
        u %= MOD;
        if(u < 0) u += MOD;
        return modint(u);
    }

    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }

    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

int main(){

  ll h,w,k;
  cin >> h >> w >> k;

  mint dp[h+1][w];

  rep(i,0,h+1) rep(j,0,w) dp[i][j] = 0;
  dp[0][0] = 1;

  rep(i,0,h){
    rep(j,0,w){
      rep(l,0,1 << w-1){

        ll temp = l;
        bool flag = false;
        rep(m,0,w-2) if((temp >> m) & 1 && (temp >> m+1) & 1) flag = true;

        if(flag) continue;

        if(j != 0 && (temp >> j-1) & 1) dp[i+1][j-1] += dp[i][j];
        else if(j != w-1 && (temp >> j) & 1) dp[i+1][j+1] += dp[i][j];
        else dp[i+1][j] += dp[i][j];
      }
    }
  }

  cout << dp[h][k-1] << endl;
  return 0;
}

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

int main(void){
    int N,K;
    int p[1010];
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p,p+N);

    int total=0;
    for(int j=0;j<K;j++){
        total += p[j];
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3600
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> void _read( T &x ) { cin>>x; }
void _read(int &x) { scanf("%d", &x); }
void _read(LL &x) { scanf("%lld", &x); }
void _read(double &x) { scanf("%lf", &x); }
void _read(char &x) { scanf(" %c", &x); }
void _read(char *x) { scanf("%s", x); }
void read() {}
template<class T, class... U>
void read( T& head, U&... tail ) {
    _read(head);
    read(tail...);
}

template<class T> void _print( const T &x ) { cout << x; }
void _print( const int &x ) { printf("%d", x); }
void _print( const LL &x ) { printf("%lld", x); }
void _print( const double &x ) { printf("%.16f\n",x); }
void _print( const char &x ) { putchar(x); }
void _print( const char *x ) { printf("%s",x); }
template<class T> void _print( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _print(*i++)) if (i != x.cbegin()) putchar(' '); }
void print() {}
template<class T, class... U> void print( const T& head, const U&... tail ) {
    _print(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005

int indeg[MAX_N];
LL pos[MAX_N];
bool visited[MAX_N];
vector<pair<int, LL>> G[MAX_N];

bool dfs(int v, int d) {
    if(visited[v]) {
        if(d != pos[v]) {
            return false;
        }
        return true;
    }
    visited[v] = true;
    pos[v] = d;

    REPIT(ii, G[v]) {
        int u, D;
        tie(u, D) = *ii;
        bool ret = dfs(u, d + D);
        if(ret == false) {
            return false;
        }
    }
    return true;
}

int main()
{
    int n, m;
    read(n, m);
    REP(i, m) {
        int L, R, D;
        read(L, R, D);
        G[L].PB({R, D});
        indeg[R] += 1;
    }
    REP(i, 1, n+1) {
        if(indeg[i] == 0) {
            bool ret = dfs(i, 0);
            if(ret == false) {
                printf("No\n");
                return 0;
            }
        }
    }
    REP(i, 1, n+1) {
        if(not visited[i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 9472
#ABC166B_TrickorTrear.rb
n,k = gets.split.map(&:to_i)
ar = []
(1..k).each do |kk|
  d = gets.chomp.to_i
  a = gets.split.map(&:to_i)
  ar << a
end
kashi = ar.flatten.uniq.size
puts n - kashi



Measured memory_bytes: 14584
let r()=List.map int_of_string(Str.split(Str.regexp_string" ")(read_line()))open Array;;match r()with|[n;m;l]->(let($)s t=let a=make_matrix s t 0in for i=0to s-1do let x=of_list(r())in for j=0to t-1do a.(i).(j)<-x.(j)done done;a in let a=n$m and b=m$l in for i=0to n-1do for j=0to l-1do let c=ref 0in for k=0to m-1do c:=!c+a.(i).(k)*b.(k).(j)done;Printf.printf(if j=0then"%d"else" %d")!c done;print_newline()done)|_->()

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

int main(){
	// sengen
	int a,b;
	// nyuryoku
	cin >> a >> b;
	// keisan
	if(a <= b){
		for(int i=1;i<=b;i++) cout << a;
	}else{
		for(int i=1;i<=a;i++) cout << b;
	}
	// syutsuryoku
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,mx=0;
    long long ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        mx=max(mx,x);
        ans+=mx-x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
int prime(int x) {
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main() {
	int a, d, n;
	while (scanf("%d %d %d",&a,&d,&n),a,d,n) {
		vector<int>v;
		for (int i = a; i <= 1000000; i+=d) {
			if (prime(i)) v.push_back(i);
		}
		 printf("%d\n",v[n-1]);
	}
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  ll ans = 0;
  rep(i, n) {
    cin >> a[i];
    ans += a[i];
  }
  vector<ll> power(40, 1);
  rep(i, 39) {
    power[i+1] = power[i] * 2;
  }
  ll ck = 0;
  repr(i, 39) {
    ck += power[i];
    if (ck > k) {
      ck -= power[i];
      continue;
    }
    ll cans = 0;
    rep(j, n) {
      cans += ck ^ a[j];
    }
    if (cans < ans) {
      ck -= power[i];
      continue;
    }
    ans = cans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N=int(input())
S=[input() for i in range(N)]
St=list(map(''.join,zip(*S)))
r=0
for k in range(N):
    f=1
    for i in range(N):
        if S[i][k:]+S[i][:k]!=St[i+k-N]:
            f=0
            break
    if f:
        r+=N
print(r)

Measured memory_bytes: 3188
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    string s;
    cin >> s;

    string month = s.substr(5, 2);

    if (atoi(month.c_str()) <= 4) {
        cout << "Heisei" << endl;
        return 0;
    }
    cout << "TBD" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n;

void dane() {
	cin>>n;
	int maxi = -1;
	bool ans = true;
	F(i,0,n) {
		int a;
		cin>>a;
		if(a-1 >= maxi && a-1>=0) {
			a--;
		}
		if(maxi > a) {
			ans = false;
		}
		maxi = a;
	}
	cout<<(ans?"Yes":"No")<<endl;
}

int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

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

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>>a(n,vector<int>(m));
    vector<int>c(n);
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }
    ll ans=INF;

    rep(s,1<<n){
        ll cost=0;
        vector<int>d(m);
        rep(i,n){
            if(s>>i&1){
                cost+=c[i];
                rep(j,m)d[j]+=a[i][j];
            }
        }
        bool ok=true;
        rep(j,m){
            if(d[j]<x)ok=false;
        }
        if(ok)ans=min(ans,cost);
    }
    if(ans==INF)cout<<"-1"<<endl;
    else cout<<ans<<endl;

}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <map>
#include <set>

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	string l;
	int p,a,b,c,d,e,f,s,m;

	while(1){
		cin>>n;
		if(n==0) break;

		map<double,set<string> > mp;
		for(int i1=0;i1<n;i1++){
			cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			int sumt=a+b+c+m*(d+e);
			int money=f*s*m-p;
			double ratio=(double)money/(double)sumt;

			mp[ratio].insert(l);
		}

		for(map<double,set<string> >::reverse_iterator it=mp.rbegin();it!=mp.rend();it++){
			for(set<string>::iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++){
				cout<<(*it2)<<endl;
			}
		}
		cout<<"#"<<endl;


	}
	return 0;
}

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

int main()
{
    long long n,m;
    cin>>n>>m;
    long long a[m],sum=0;
    for(int i=0; i<m; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<n) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[100 + 1];
    int k = 0;

    scanf("%s", s);
    int n = strlen(s); 
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] == s[n - 1 - i])
        {
        }
        else
        {
          s[n -1] = s[n];
            k++ ;
        }
    }
    printf("%d\n",k);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		String S1="";
		String S2="";
		int Slen=S.length();
		int z=0,y=Slen-7,x=0;
		while(y<Slen){
			S1=S.substring(0,z);
			S2=S.substring(y,Slen);
			if((S1+S2).equals("keyence")){
				x++;
				break;
			}
			z++;y++;
		}
		if(x==1)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 23508
#include <iostream>


using namespace std;



int main() {
	int a[5], b = 0, c = 0, d = 0, tmp = 114514810, sum = 0;
	bool is = false;
	for (int i = 0; i < 5; i++) {
		cin >> b;
		c = b % 10;

		if (c != 0 && c < tmp) {
			tmp = c;
			d = i;
			is = true;
		}

		a[i] = c;
		if (c == 0) {
			sum += b;
			continue;
		}
		sum += b - c + 10;
	}

	if(is) cout << sum - 10 + a[d] << endl;
	else cout << sum << endl;


	//system("pause");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int seikai,seikai2;
int main(){
	cin>>s;
	int f=s.length();
	for(int i=0;i<f;i++){
		if(i%2==0&&s[i]!='0')seikai++;
		else if(i%2==1&&s[i]!='1')seikai++;
	}
	for(int i=0;i<f;i++){
		if(i%2==0&&s[i]!='1')seikai2++;
		else if(i%2==1&&s[i]!='0')seikai2++;
	}
	cout<<min(seikai,seikai2)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    string s;
    cin >> s;

    int k;
    cin >> k;

    string ans;
    for (int i = 0; i < s.size(); i++) {
        if(s[i] == 'a'){
            ans += 'a';
            continue;
        }
        int tp = s[i] - 'a' + 1;
        if (tp + k > 26) {
            ans += 'a';
            k -= 27 - tp;
        } else {
            ans += s[i];
        }
    }
    k %= 26;
    int tp = ans.back() - 'a';
    tp = (tp + k) % 26;
    ans.back() = tp + 'a';
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    //    cin >> t;

    while (t--)
        solve();
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    int b[3];
    rep(i, 3) b[i] = c[0][i];
    int a[3];
    rep(i, 3) a[i] = c[i][0] - b[0];

    rep(i, 3)
    {
        rep(j, 3)
        {
            if (a[i] + b[j] != c[i][j])
            {
                OP("No");
                return 0;
            }
        }
    }
    OP("Yes");

    return 0;
}

/*
int main()
{
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    rep(i, 101)
    {
        rep(j, 101)
        {
            rep(k, 101)
            {
                int b1 = c[0][0] - i;
                int b2 = c[0][1] - i;
                int b3 = c[0][2] - i;
                if (b1 == c[1][0] - j && b1 == c[2][0] - k && b2 == c[1][1] - j && b2 == c[2][1] - k && b3 == c[1][2] - j && b3 == c[2][2] - k)
                    if (0 <= b1 && b1 <= 100 && 0 <= b2 && b2 <= 100 && 0 <= b3 && b3 <= 100)
                    {
                        OP("Yes");
                        return 0;
                    }
            }
        }
    }

    OP("No");
    return 0;
}
*/

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

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

const long long INF = 1LL << 60;
using namespace std;

int main() {
	int N; cin >> N;
	long long dp[110000];
	for (int i = 0; i < 110000; i++) dp[i] = INF;

	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int pow6 = 1; i + pow6 <= N; pow6 *= 6) {
			chmin(dp[i + pow6], dp[i] + 1);
		}

		for (int pow9 = 1; i + pow9 <= N; pow9 *= 9) {
			chmin(dp[i + pow9], dp[i] + 1);
		}
	}

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define sc second
#define fr first
#define mp make_pair
const int N = 2e5 + 10, OO = 1e9 + 5000,MOD = 1e9 + 7;
int a[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)cin >> a[i];
	for (int i = 2; i <= n; ++i) {
		if (a[i] > a[i - 1]) {
			--a[i];
			continue;
		}
		else if (a[i] == a[i - 1])
			continue;
		else {
			cout << "No" << endl;
			exit(0);
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[2000000];
		int x = sc.nextInt();
		long count = 0;
		while(true) {
			if(x>=500) {
				x=x-500;
				count=count+1000;
			}
			else if(x>=5) {
				x=x-5;
				count=count+5;
			}
			else {
				break;
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
ll A[100000];
ll dp[100000][2];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N) cin>>A[i];
    if(A[0]%2) dp[0][1]=A[0]/2;
    else dp[0][0]=A[0]/2;
    rep(i,1,N){
        if(A[i]%2){
            dp[i][1]=max(dp[i-1][0]+A[i]/2, dp[i-1][1]+A[i]/2);
            if(dp[i-1][1]>0) dp[i][0]=dp[i-1][1]+(A[i]+1)/2;
            else dp[i][0]=0;
        }
        else{
            if(A[i]>0) dp[i][1]=max(dp[i-1][1]+(A[i]+1)/2, dp[i-1][0]+A[i]/2-1);
            else dp[i][1]=0;
            dp[i][0]=max(dp[i-1][0], dp[i-1][1])+A[i]/2;
        }
    }
    cout <<max(dp[N-1][0], dp[N-1][1])<<"\n";
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
		A.at(i)+=K;
	}

	vector<long long> sum(N+1,0);
	for(int i=0;i<N;i++)	sum.at(i+1)=sum.at(i)+A.at(i);

	map<long long,long long> mp;
	long long ans=0;
	mp[0]++;
	for(int i=1;i<=N;i++){
		long long x=(sum.at(i)-i)%K;
		if(i-K>=0)	mp[(sum.at(i-K)-(i-K))%K]--;
		if(mp.count(x))	ans+=mp.at(x);
		mp[x]++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15872