akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solve() {
    int k;
    cin >> k;
    vector<ll> ans;
    queue<ll> que;
    rep(i, 9) {
        ans.push_back(i+1);
        que.push(i+1);
    }

    while (ans.size() <= 100001) {
        ll x = que.front(); que.pop();
        for (int i = -1; i <= 1; i++) {
            ll r = x % 10;
            if (0 <= r + i && r + i < 10) {
                ans.push_back(x * 10 + r + i);
                que.push(x * 10 + r + i);
            }
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans[k-1] << endl;
}

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


Measured memory_bytes: 4644
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){
	
	ll n, a[100001], b[100001], ans=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i=n-1; 0<=i; i--){
		ll s=(b[i]-(a[i]%b[i]))%b[i];
		ans+=s;
		a[i-1]+=ans;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	rep(i,N) cin >> P[i];
	sort(P.begin(),P.end());
	int sum = 0;
	bool aaa = false;
	for(int i = 0; i < N; i++){
		sum += P[i];
		if(sum - P[N-1] > P[N-1]){
			aaa = true;
		}
	}
	if(aaa){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  if (n >= 65 && n <= 90) {
    cout << "1\n";
  } else if (n >= 97 && n <= 122) {
    cout << "2\n";
  } else {
    cout << "0\n";
  }
}


Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N, S; cin >> N >> S;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	int tmp = a[0];
	int l = 0, r = 1;
	int ans = INF;
	while (true) {
		dump(l, r);
		dump(tmp);
		if (tmp >= S) {
			chmin(ans, r - l);
			tmp -= a[l], l++;
		}
		else {
			if (r == N)break;
			tmp += a[r], r++;
		}
	}
	cout << (ans == INF ? 0 : ans) << endl;
	return 0;
}

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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}
double distance(double x1, double y1, double x2, double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int cur = 0;
    int ans = 0;
    while (a[cur] != -1)
    {
        if (cur == 1)
        {
            cout << ans << endl;
            return 0;
        }
        int t = a[cur] - 1;
        a[cur] = -1;
        cur = t;
        ans++;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    while(M--) {
        int A;
        cin >> A;
        N -= A;
    }

    if(N < 0) {
        cout << -1 << endl;
    } else {
        cout << N << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
use proconio::input;
use std::cmp::max;

fn main() {
	input!(n: usize, w_lim: usize, items: [(usize, i64); n]);
	let mut dp = vec![vec![0; n+1]; w_lim+1];
	for w in 1..=w_lim {
		for i in 0..n {
			let mut v = dp[w][i];
			if w >= items[i].0 { v = max(v, dp[w - items[i].0][i] + items[i].1) };
			dp[w][i+1] = v;
		}
	}

	println!("{}", dp[w_lim][n]);
}

Measured memory_bytes: 83876
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    FOR(i, 1, N + 1) cin >> A[i];
    set<int> res;
    vector<int> boxes(N + 1);
    for(int i = N; i >= 1; i--) {
        int sum = 0;
        for(int j = i; j <= N; j += i) {
            sum += boxes[j];
        }
        sum = sum % 2;
        if(sum != A[i]) {
            boxes[i]++;
            res.insert(i);
        }
    }
    cout << res.size() << endl;
    for(int x : res) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 8448
from itertools import groupby, accumulate
N, K = map(int, input().split())
S = groupby(list(input()))
state = []
number = []
for i, j in S:
    state.append(i)
    number.append(len(list(j)))

answer = 0

if len(state) == 1:
    print(number[0])
    exit()

number = list(accumulate([0] + number))
l = len(number) - 1

if state[0] == '0':
    answer = number[min(l, 2 * K)] - number[0]

start = state.index('1') + 1
for i in range(start, l + 1, 2):
    answer = max(answer, number[min(2 * K + i, l)] - number[i - 1])

print(answer)

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

int main(){
  string n1, n2;
  cin >> n1;
  n2 = n1;
  reverse(n2.begin(), n2.end());
  if(n1 == n2){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt,maxn=-2147483647,minn=2147483647;
int main(){
	cin>>s;cin>>s;
	for(int i=s.size()-1;i>=0;i--)
		if(s[i]=='(')cnt--,minn=min(cnt,minn);
		else cnt++;
	cnt=0;
	for(int i=0;i<s.size();i++)
		if(s[i]==')')cnt++,maxn=max(cnt,maxn);
		else cnt--;
	for(int i=0;i<maxn;i++)s='('+s;
	for(int i=minn;i<0;i++)s=s+')';
	cout<<s;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 222;
const int MOD = 1e9+7;
ll dp[MAXN][MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s;
    for (int i = 0; i < N; i++) {
        char c;
        cin >> c;
        if (c != '-') s += c;
    }
    N = s.size();
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            if (s[i] == 'D') {
                dp[i+1][j] += dp[i][j] * j % MOD;
                if (j) dp[i+1][j-1] += dp[i][j] * j * j % MOD;
            } else {
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j] += dp[i][j] * j;
            }
        }
        for (int j = 0; j <= i+1; j++)
            dp[i+1][j] %= MOD;
    }
    cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main(){
    int A,B,C;
    cin >> A >>B;
    int P[B],X=0;
    for(int i=0;i<B;i++){
        cin >> P[i];
        X=X+P[i];
    }
    C=X/(A+1);
    if(X%(A+1)!=0){
        C=C+1;
    }
    cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(15)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=3e5+5;
const int MOD=998244353;

int main(void){
    FAST_IO;
    int n;
    cin >> n;
    vector<int> l(n+1),r(n+1);
//    cout << a[0]<<endl;
    for(int i=1;i<=n;i++){
        int a,b;
        cin >> a >>b;
        l[i]=a,r[i]=b;
    }
    sort(l.rbegin(),l.rend());
    sort(r.begin(),r.end());
    ll ans=0;
    for(int i=0;i<=n;i++){
        if(l[i]>r[i]){
            ans+=2*(l[i]-r[i]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <sstream>
#include <algorithm>
#define fastio() ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long 
#define MOD 1000000007
#define inf 9223372036854775807ll
using namespace std;

class Item{
public:
	int weight;
	int value;
};

ll solveRecursive(Item *item, int n, int W, ll dp[101][100001]){
	if(n < 0 || W <= 0) return 0;
	
	if(dp[n][W] != -1) return dp[n][W];

	ll op1, op2, ans = 0;
	if(item[n].weight <= W){
		op1 = 0 + (ll)solveRecursive(item, n - 1, W, dp);
		op2 = item[n].value + (ll)solveRecursive(item, n - 1, W - item[n].weight, dp);
	}
	else{
		op1 = 0 + (ll)solveRecursive(item, n - 1, W, dp);
		op2 = 0;
	}
	ans = max(op1, op2);
	return dp[n][W] = ans;
}

ll solveIteratively(Item *item, int n, int w){
	ll dp[101][100001];
	memset(dp, 0, sizeof(dp));

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= w; j++){
			dp[i][j] = dp[i - 1][j];
			if(j >= item[i - 1].weight){
				dp[i][j] = max(dp[i][j], (ll)item[i - 1].value + dp[i - 1][j - item[i - 1].weight]);
			}
			//cout << dp[i][j] << " ";
		}
		//cout << "\n";
	}
	return dp[n][w];
}

int main(){
	int n, W; cin >> n >> W;
	Item item[101];
	for(int i = 0; i < n; i++){
		cin >> item[i].weight;
		cin >> item[i].value;
	}

	cout << solveIteratively(item, n, W);

	return 0;
}

Measured memory_bytes: 79104
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0
j = 100
for i in A:
  sum += B[i-1]
  if i == j+1:
    sum += C[j-1]
    
  j = i

print(sum)

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


typedef long long ll; 
#define sz(a) ((int)(a.size()))

const int mod=1e9+7; 
const int nax=42;

int mul(int a, int b){
  return (ll)a*b%mod; 
}
void add_self(int &a, int b){
  a+=b; 
  if(a>= mod) a-=mod; 
}
void mul_self(int &a, int b){
  a=(ll)a*b%mod; 
}
void sub_self(int &a, int b){
  a-=b; 
  if(a<0) a+=mod;
}
int exp(int a, int b){
  int ret=1; 
  while(b){
    if(b%2){
      mul_self(ret,a); 
    }
    mul_self(a,a); 
    b/=2; 
  }
  return ret; 
}
int dp[nax][1<<18]; 

void solve(){
  int n,x,y,z; cin>>n>>x>>y>>z;   
  int prev[20]; 
  dp[0][0]=1;  
  for(int i=0;i<n;i++){
    for(int j=0;j<(1<<16);j++){
      int p=-1; 
      bool good=1; 
      int prev_sz=0; 
      for(int k=0;k<16;k++){
        if((1<<k)&j){
          prev[prev_sz++]=(k-p); 
          if(k-p>10) good=0; 
          p=k; 
        }
      }
      if(!good) continue; 
      //reverse(prev.begin(),prev.end()); 
      for(int k=1;k<=10;k++){
        bool can=1; 
        int zz=k,yy=0,xx=0; 
        for(int qq=0;qq<prev_sz;qq++){
          int q=prev[qq]; 
          if(zz<z) zz+=q; 
          else if(yy<y) yy+=q; 
          else if(xx<x) xx+=q; 
        }
        if(xx==x && yy==y && zz==z) can=0; 
        if(can){
          int mask=1<<(k-1); 
          int acc=k-1; 
          for(int qq=0;qq<prev_sz;qq++){
            int q=prev[qq];
            acc+=q; 
            if(acc<16){
              mask^=(1<<acc); 
            }
            else break; 
          }
          add_self(dp[i+1][mask],dp[i][j]); 
        }
      }
    }
  }
  int ans=exp(10,n); 
  for(int i=0;i<(1<<16);i++){
    sub_self(ans,dp[n][i]); 
  }
  cout<<ans<<endl; 
}


int main(){
  clock_t beg=clock(); 
  solve(); 
  clock_t end=clock(); 
  fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
}

Measured memory_bytes: 41472
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


rei = "CODEFESTIVAL2016"
s = input()

ans = 0
for i in range(len(s)):
	if rei[i] != s[i]:
		ans += 1

print(ans)


Measured memory_bytes: 3064
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

int n;
string s;

void solve () {
    cin >> n;
    cin >> s;
    string t = "";
    for (int i = 0; i < sz(s); ++i) {
        t += s[i];
        if (t + t == s) {
            cout << "Yes";
            return;
        } 
    }
    cout << "No";
}

signed main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while (t --) {
    	solve ();
    }
    return 0;
}





Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int A, X;
	scanf("%d%d", &X, &A);
	if (X >= A) {
		printf("10");
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
import numpy as np
S = np.array(list(input()))
count = 0
if len(S) >= 2:
    if S[0] == 'R' and S[1] == 'R':
        count += 1
    if S[-1] == 'L' and S[-2] == 'L':
        count += 1
for i in range(1, N-1):
    if S[i] == 'R' and S[i+1] == 'R':
        count += 1
    if S[i] == 'L' and S[i-1] == 'L':
        count += 1
count += K * 2
print(min(count, N-1))

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

using namespace std;

int n, c, k, t[100005], a, ans, b   ;
bool ok;

int main (){

cin >> n >> c >> k;

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

sort(t + 1, t + 1 + n);

for(int i = 1; i <= n; ++i){
    if(b == c){
        ok = 1;
        a = t[i] + k;
        ans++;
        b = 0;
    }
    if(ok){
        if(t[i] > a){
            ok = 0;
        }
        else b++;
    }
    if(!ok){
        ok = 1;
        a = t[i] + k;
        ans++;
        b = 1;
    }
}

cout << ans;

return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<utility>

using namespace std;

int n;
int A[100100];


int partition(int A[], int p, int r){
    int x = A[r];
    int i = p - 1;
    int temp = 0;
    for(int j = p; j < r; j++){
        if(A[j] <= x){
            i = i + 1;
            swap(A[i], A[j]);
            //temp = A[i];
            //A[i] = A[j];
            //A[j] = temp;
        }
    }
    swap(A[i + 1], A[r]);
    //temp = A[i + 1];
    //A[i + 1] = A[r];
    //A[r] = temp;
    return i + 1;
}


int main(){
    cin >>n;
    for(int i = 0; i < n; i++){
        cin >>A[i];
    }
    //int p = A[n - 1];
    int t = partition(A, 0, n - 1);
    for(int i = 0; i < n; i++){
        if(i){
            cout << " ";
        }
        if(i == t){
            cout << "[" << A[i] << "]";
        }else{
            cout << A[i];
        }
    }
    cout << endl;

}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

VI zalgorithm(const string &s) {
	VI prfx(s.size());
	for(int i =1, j =0; i < sz(s); i++) {
		if(i + prfx[i - j] < j + prfx[j]) {
			prfx[i] = prfx[i - j];
		} else {
			int k = max(0, j + prfx[j] - i);
			while(i + k < sz(s) && s[k] == s[i + k]) ++k;
			prfx[i] = k;
			j = i;
		}
	}
	prfx[0] = sz(s);
	return prfx;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; string s;
	cin >>n >>s;
	int ans = 0;
	rep(i, n){
		string z = s.substr(i);
		auto v = zalgorithm(z);
		rep(j, sz(z)){
			int q=v[j];
			q = min(q, j);
			ans = max(ans, q);
		}
	}
	
	cout <<ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   int n, k; cin >> n >> k;
   vector<int> p(n);
   rep(i, n) cin >> p.at(i);

   sort(p.begin(), p.end());
   int cnt =0;
   rep(i, k){
      cnt += p.at(i);
   }
   cout << cnt << endl;
   return 0;
}


Measured memory_bytes: 3624
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 500 * i + 100 * j + 50 * k == X:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	
	cout << (h2 - h1) * 60 + (m2 - m1) - k << endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
i64 N, K;
string s;
i64 A[MAX_N];

int main() {
    cin >> N >> K;
    cin >> s;
    REP(i, N) A[i] = ((s[i] - '0') ? 1 : -1);

    vector<i64> rl;
    rl.reserve(N);
    i64 c;
    REP(i, N) {
        if (i == 0) {
            c = A[i];
        } else {
            if (A[i - 1] == A[i]) {
                c += A[i];
            } else {
                rl.pb(c);
                c = A[i];
            }
        }
        if (i == (N - 1)) rl.pb(c);
    }

    i64 m = rl.size();

    // 累積和
    vector<i64> C(m + 1, 0);
    REP(i, m) {
        C[i + 1] = C[i] + abs(rl[i]);
    }

    // しゃくとり法
    i64 maxl = 0;
    i64 j = 0;
    i64 n_neg = 0;
    REP(i, m) {
        while(j < m && n_neg < K) {
            if (rl[j] < 0) n_neg++;
            j++;
        }

        chmax(maxl, C[min(j + 1, m)] - C[i]);

        if (rl[i] < 0) n_neg--;
    }
    cout << maxl << endl;

    return 0;
}

Measured memory_bytes: 2896
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int n,i;
    cin>>n;
    string s,a;
    a="...";
    cin>>s;
    if(s.size()<=n)
        cout<<s;
    else
    {
        for(i=0;i<n;i++)
        {
            cout<<s[i];
        }

        cout<<a;

    }


}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>

int main()
{
  std::string s;
  std::cin >> s;
  std::unordered_map<int64_t, int64_t> modMap;
  const int64_t mod = 2019;
  int64_t tmp = 0;
  int64_t digit = 1;
  modMap[0] = 1;
  for (int i = s.size() - 1; i >= 0; --i)
  {
    int num = static_cast<int>(s[i] - '0');
    digit %= mod;
    tmp = tmp + digit * num;
    tmp %= mod;
    if (modMap.find(tmp) != modMap.end())
    {
      modMap[tmp]++;
    }
    else 
    {
      modMap[tmp] = 1;
    }
    
    digit *= 10;
  }

  int64_t ans = 0;
  for (auto itr : modMap)
  {
    ans += itr.second * (itr.second - 1) / 2;
  }

  std::cout << ans << std::endl;
  return 0;
}

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

using namespace std;

const int N = 111111;

int a[N];
long long pre[N];
long long suf[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1] + abs(a[i - 1] - a[i]);
  }
  for (int i = n; i > 0; --i) {
    suf[i] = suf[i + 1] + abs(a[i + 1] - a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    printf("%lld\n", pre[i - 1] + abs(a[i - 1] - a[i + 1]) + suf[i + 1]);
  }
  return 0; 
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n, k; cin >> n >> k;
    set<int> st;
    rep(i,k) {
        int d; cin >> d;
        st.insert(d);
    }
    while (true) {
        int x = n;
        bool ok = true;
        while (x > 0) {
            int tmp = x % 10;
            if (st.find(tmp) != st.end()) ok = false;
            x /= 10;
        }
        if (ok) {cout << n << endl; return 0;}
        else n++;
    }
}

Measured memory_bytes: 3592
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if(B - A <= 0){
            System.out.println("delicious");
        }else if(B -A <= X){
            System.out.println("safe");
        }else{
            System.out.println("dangerous");
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int a[] = {46656, 7776, 1296, 216, 36, 6};
int b[] = {59049, 6561, 729, 81, 9};
int t[100001];

int main(){
	int n; cin >> n;
	t[1] = 1;
	for(int i = 2; i <= 100000; i++){
		int s = i;
		for(int j = 0; j < 6; j++){
			if(i - a[j] >= 0){
				s = min(t[i - a[j]] + 1, s);
			}
			if(j < 5 && i - b[j] >= 0){
				s = min(t[i - b[j]] + 1, s);
			}
		}
		t[i] = s;
	}
	cout << t[n] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+ 5;
ll arr[maxn];
ll C(ll n, ll m) {
    ll res = 1;
    for (ll i = n; i > n - m; --i)
        res *= i;
    for (ll i = 2; i <= m; ++i)
        res /= i;
    return res;
}
ll bf(string &t, string &s, int k) {
    if (t > s) return 0;
    if (!k) return t <= s;
    if (t.length() == s.length()) return t <= s && k == 0;
    ll res = 0;
    for (int i = 0; i <= 9; ++i) {
        t.push_back('0' + i);
        res += bf(t, s, (i? k - 1: k));
        t.pop_back();
    }
    return res;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    int k; cin >> k;
    ll ans = 0;
    for (int i = k; i < s.length(); ++i)
        ans += pow(9, k) * C(i - 1, k - 1);
    for (int i = 1; i <= 9; ++i) {
        string t = string(1, '0' + i);
        ans += bf(t, s, k - 1);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a.at(K-1) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int a,alice=0,bob=0;
    cin >> a;
    vector<int>x(a);
    for(int i=0;i<a;i++){
        cin >> x[i];
    }
    sort(x.begin(),x.end(),greater<int>());
    for(int i=0;i<a;i++){
        if(i%2==0){
            alice+=x[i];
        }else{
            bob+=x[i];
        }
    }
    cout << alice-bob;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll tx; tx=1; while(tx--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll r,c,i,j;
        cin>>r>>c;
        char mat[r][c];
        for(i=0;i<r;i++){
            for(j=0;j<c;j++){
                cin>>mat[i][j];
            }
        }
        // Starting from (1,1) we will move to (r,c);
        ll dp[r][c];
        dp[0][0]=1;
        for(i=1;i<r;i++){
            if(mat[i][0]=='#'){
                dp[i][0]=0;
            }
            else{
                dp[i][0]=dp[i-1][0];
            }
        }
        for(i=1;i<c;i++){
            if(mat[0][i]=='#'){
                dp[0][i]=0;
            }
            else{
                dp[0][i]=dp[0][i-1];
            }
        }
        for(i=1;i<r;i++){
            for(j=1;j<c;j++){
                if(mat[i][j]=='#'){
                    dp[i][j]=0;
                }
                else{
                    dp[i][j]=dp[i-1][j]+dp[i][j-1];
                    dp[i][j]%=mod;
                }
            }
        }
        cout<<dp[r-1][c-1]<<endl;
    }
	return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF 1e17

#define MAX_N 1000

int n;
char s[555][555];

int main(){
	cin.sync_with_stdio(false);
	ll res=INF;
	cin>>n;
	rep(i,n)cin>>s[i];
	rep(fi,n){
		bool ok=false;
		rep(i,n)if(s[i][fi]=='#')ok=true;
		if(ok){
			ll cnt=0;
			rep(j,n)if(s[fi][j]=='.')cnt++;
			rep(j,n){
				bool dame=false;
				rep(i,n)if(s[i][j]=='.')dame=true;
				if(dame)cnt++;
			}
			minch(res,cnt);
		}else{
			bool ok2=false;
			rep(j,n)if(s[fi][j]=='#')ok2=true;
			if(ok2){
				ll cnt=0;
				rep(j,n)if(s[fi][j]=='.')cnt++;
				rep(j,n){
					bool dame=false;
					rep(i,n)if(s[i][j]=='.')dame=true;
					if(dame)cnt++;
				}
				minch(res,cnt+1);
			}
		}
	}
	if(res==INF)cout<<-1<<endl;
	else cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.next());
		int m = Integer.parseInt(in.next());
		int x = Integer.parseInt(in.next()) - 1;
		int y = Integer.parseInt(in.next()) - 1;
		int xx = Integer.parseInt(in.next()) - 1;
		int yy = Integer.parseInt(in.next()) - 1;
		char[][] grid = new char[n][m];
		int[][] seen = new int[n][m];
		List<Node> queue = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			String cur = in.next();
			grid[i] = cur.toCharArray();
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				seen[i][j] = -1;
			}
		}
		if(grid[x][y] != '#') {
			dfs(grid, seen, queue, x, y, n, m, 0);
		}
		int cnt = 0; 
		while(cnt < queue.size()) {
			int a = queue.get(cnt).x;
			int b = queue.get(cnt).y;
			int load = queue.get(cnt).time;
			for(int i = Math.max(0, a - 2); i <= Math.min(n - 1, a + 2); i++) {
				for(int j = Math.max(0, b - 2); j <= Math.min(m - 1, b + 2); j++) {
					if(grid[i][j] == '#') continue;
					if(seen[i][j] != -1) continue;
					else {
						dfs(grid, seen, queue, i, j, n, m, load + 1);
					}
				}
			}
			cnt += 1;
		}
		System.out.println(seen[xx][yy]);
	}
	public static void dfs(char[][] grid, int[][] seen, List<Node> queue, int i, int j, int n, int m, int load) {
		seen[i][j] = load;
		queue.add(new Node(i, j, load));
		int[] a = {1, -1, 0, 0};
		int[] b = {0, 0, 1, -1};
		for(int k = 0; k < 4; k++) {
			int x = i + a[k];
			int y = j + b[k];
			if((x < 0) || (x >= n)) continue;
			if((y < 0) || (y >= m)) continue;
			if(seen[x][y] != -1) continue;
			if(grid[x][y] == '#') continue;
			dfs(grid, seen, queue, x, y, n, m, load);
		}
	}
}
class Node {
	int x;
	int y;
	int time;
	public Node(int x, int y, int time) {
		this.x = x;
		this.y = y;
		this.time = time;
	}
}

Measured memory_bytes: 72712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int mod=998244353;
ll dp[3001][3001][2];
int n,s;
int a[3001];
int main(){
    cin>>n>>s;
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n){
        rep(j,s){
            if(j+a[i]<=s){
                dp[i+1][j+a[i]][1]+=dp[i][j][1];
                if(j==0) dp[i+1][j+a[i]][1]+=i+1;
                dp[i+1][j+a[i]][1]%=mod;
                if(j+a[i]==s){
                    ans+=dp[i+1][j+a[i]][1]*(n-i);
                    ans%=mod;
                }
            }
            dp[i+1][j][1]+=dp[i][j][1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  rep(i,N){
  cin >> S.at(i);
  }
  
  int x= 0,y = 0,z = 0,w = 0;
  rep(i,N){
  if("AC" == S.at(i)){
  x++;
  }
    else if("WA" == S.at(i)){
    y++;
    }
    else if("TLE" == S.at(i)){
    z++;
    }
    else if("RE" == S.at(i)){
    w++;
    }    
  }
  

  
cout<< "AC x " << x << endl;
cout<< "WA x " << y << endl;
cout<< "TLE x " << z << endl;
cout<< "RE x " << w << endl;

  
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define MAX 310
using namespace std;

int graph[MAX][MAX];
pair<int, int> dp[MAX][MAX];
pair<int, int> dist[MAX];
int visit[MAX];

int main(void)
{
	int N, M, L;
	cin >> N >> M >> L;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++) graph[i][j] = -1;
	}
	for (int i = 0; i < M; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (c > L) continue;
		a--;
		b--;
		graph[a][b] = c;
		graph[b][a] = c;
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (graph[i][j] == -1) dp[i][j] = {-1, 0};
			else dp[i][j] = {0, graph[i][j]};
		}
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++) dist[j] = {-1, 0};
		for (int j = 0; j < N; j++)
		{
			visit[j] = 0;
			if (graph[i][j] >= 0) dist[j] = {0, graph[i][j]};
		}
		visit[i] = 1;
		for (int j = 1; j < N; j++)
		{
			int idx = -1;
			pair<int, int> smallest = {-1, 0};
			for (int k = 0; k < N; k++)
			{
				if (dist[k].first < 0 || visit[k]) continue;
				if (idx < 0 || smallest > dist[k])
				{
					idx = k;
					smallest = dist[k];
				}
			}
			if (idx < 0) break;
			visit[idx] = 1;
			for (int k = 0; k < N; k++)
			{
				if (visit[k] || graph[idx][k] < 0) continue;
				pair<int, int> n = smallest;
				n.second += graph[idx][k];
				if (n.second > L)
				{
					n.first++;
					n.second = graph[idx][k];
				}
				if (dist[k].first < 0 || dist[k] > n) dist[k] = n;
			}
			dp[i][idx] = smallest;
		}
	}
	int Q;
	cin >> Q;
	for (int q = 0; q < Q; q++)
	{
		int s, t;
		cin >> s >> t;
		s--;
		t--;
		cout << dp[s][t].first << "\n";
	}
	return 0;
}


Measured memory_bytes: 1664
input1 = list(map(int,input("").split(" ")))
N = input1[0]
A = input1[1]
B = input1[2]
C = input1[3]
D = input1[4]

flag = False
for x in range(N-1):
	y = N -1 - x
	if (C*y - D*x) <= (B-A) and (B-A) <= -1*C*x + y*D:
		flag = True
		break

if flag == True:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, M;
  cin >> N >> M;
  vector<vll> to(N);

  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].pb(b);
    to[b].pb(a);
  }

  rep(i, to[N - 1].size()) {
    ll f = to[N - 1][i];
    for (auto ff : to[f]) {
      if (ff == 0) {
        COUT("POSSIBLE");
        return 0;
      }
    }
  }

  COUT("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 15672
#include <stdio.h>
#include <string.h>
 
int main(){
    char str[33] = {0};
    char ls[1000][33] = {0};
    int  len = 0, i, j;
    int  num[1000] = {0};
     
    while(scanf("%s", ls[len]) != EOF){
        if('A' <= ls[len][0] && ls[len][0] <= 'Z')
            ls[len][0] -= 'A';
            
        if(strlen(str) < strlen(ls[len]))
            strcpy(str, ls[len]);
            
        for(i = 0; i < len; i++)
            if(!strcmp(ls[len], ls[i])){
                num[i]++;
                len--;
                break;
            }
        
        len++;
    }
            
    for(j = 0, i = 1; i <= len; i++)
        if(num[j] < num[i]) j = i;
            
    printf("%s %s\n", ls[j], str);
    
    return 0;
}

Measured memory_bytes: 600
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1000000007;
const llint big=(llint)(2.19e15)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	int n;cin>>n;
	cout<<n/3<<endl;
	RE;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



int main() {
    int N,K; cin >> N >> K;
    int ans = 0;
    rep(i,N){
        int h; cin >> h;
        if(h >= K) ans++;
    }
    cout << ans << endl;
  
}

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int n = 100*r + 10*g + b;
  if(n % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,a,b,c = inm()
s = []
for i in range(n):
    s.append(ins())
ans = []
for i in range(n):
    #ddprint(f"{i=} si {s[i]} {a=} {b=} {c=}")
    if s[i]=='AB':
        if a==b==0:
            print('No')
            exit()
        elif a>b or a==b and i<n-1 and s[i+1]=='BC':
            ans.append('B')
            a -= 1
            b += 1
        else:
            ans.append('A')
            b -= 1
            a += 1
    if s[i]=='AC':
        if a==c==0:
            print('No')
            exit()
        elif a>c or a==c and i<n-1 and s[i+1]=='BC':
            ans.append('C')
            a -= 1
            c += 1
        else:
            ans.append('A')
            c -= 1
            a += 1
    if s[i]=='BC':
        if c==b==0:
            print('No')
            exit()
        elif c>b or c==b and i<n-1 and s[i+1]=='AB':
            ans.append('B')
            c -= 1
            b += 1
        else:
            ans.append('C')
            b -= 1
            c += 1
print('Yes')
for x in ans:
    print(x)


Measured memory_bytes: 85628
n = gets.to_i - 1
a = gets.split.map &:to_i
c = 0
n.times do |i|
  m = i
  i.upto(n) do |j|
    m = j if a[j] < a[m]
  end
  a[i], a[m] = a[m], a[i]
  c += 1 if i != m
end
puts sprintf("%s\n%d\n", a.join(' '), c)

Measured memory_bytes: 8580
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int px = 0; int py = 0; int pt = 0;

		for (int i = 0; i < N; i++) {
			int t = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int dt = t - pt;
			int dist = Math.abs(px - x) + Math.abs(py - y);

			if (dt >= dist && dt % 2 == dist % 2) {
				px = x;
				py = y;
				pt = t;
				continue;
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 87704
#include <iostream>
#include <map>

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::map<uint32_t, uint32_t> dict;

  for (size_t i = 0; i < N; i++) {
    uint32_t A = 0;
    std::cin >> A;
    dict[A]++;
  }

  uint32_t count = 0;
  for (auto &&d : dict) count += d.second % 2;
  std::cout << count << std::endl;

  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

struct Node{
    int id;
    int v;
    bool done = false;
    Node(int id, int v=1e9): id(id), v(v) {}
    Node(): id(0), v(1e9) {}
};

bool operator>(Node a, Node  b){
    return a.v > b.v;
}

struct Edge{
    int from, to, id;
    int cost;
    Edge(int from, int to, int cost=1, int id=-1): from(from), to(to), cost(cost), id(id) {}
};

struct Graph{
    int N;
    vector<vector<Edge>> adj;
    vector<Node> node;

    Graph(int N): N(N) {
        adj.assign(N, vector<Edge>());
        node.assign(N, Node());
        for(int i=0; i<N; ++i) node[i].id = i;
    }

    Graph() {}

    void add_edge(int i, int j, int cost=1, int id=-1){
        Edge e(i, j, cost, id);
        adj[i].emplace_back(e);
    }

    vector<Edge> get_adj(Node node){
        return adj[node.id];
    }

    void assign(int n){
        N = n;
        adj.assign(N, vector<Edge>());
        node.assign(N, Node());
        for(int i=0; i<N; ++i) node[i].id = i;
    }

    void reset(){
        for(int i=0; i<N; ++i){
            node[i].done = false;
            node[i].v = 1e9;
        }
    }
};

int main(void){
    int N,M; cin >> N >> M;
    Graph G(3*N);
    REP(i,M){
        int u,v; cin >> u >> v; u--; v--;
        G.add_edge(3*u, 3*v+1);
        G.add_edge(3*u+1, 3*v+2);
        G.add_edge(3*u+2, 3*v);
    }
    int S,T; cin >> S >> T; S--; T--;
    queue<Node> q;
    q.push(Node(3*S,0));
    while(q.size()){
        Node n = q.front(); q.pop();
        if(G.node[n.id].done) continue;
        G.node[n.id].done = true;
        if(chmin(G.node[n.id].v, n.v)){
            for(Edge e : G.get_adj(n)) q.push(Node(e.to, n.v+1));
        }
    }
    int ans = G.node[3*T].v;
    cout << (ans<1e9 ? ans/3 : -1) << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A, B, C, K;

    cin >> A >> B >> C >> K;

    if( K <= (A+B) ){
        cout << ((K<=A)?K:A) << endl;
    }else{
        cout << A - (K-(A+B)) << endl;
    }
}


Measured memory_bytes: 3620
h,w=map(int,input().split())
n=int(input())
a=list(map(int, input().split()))

ans=[[0]*w for _ in range(h)]
color=0
cnt=0
for i in range(h):
    for j in range(w):
        if i%2==0:
            cnt+=1
            ans[i][j]=color+1
        else:
            cnt+=1
            ans[i][w-j-1]=color+1
        if cnt==a[color]:
            color+=1
            cnt=0

for ans_i in ans:
    print(*ans_i)

Measured memory_bytes: 3920