akhauriyash/Code-Regression huggingface dataset:
ABlist = list()

for x in range(0,3):
    S = list(map(int,input().split()))
    ABlist.append(S[0])
    ABlist.append(S[1])

number = 0
for x in range(1,5):
    n = ABlist.count(x)
    if n > number:
        number = n

if number == 3:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] nt = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nt[0];
        var t = nt[1];
        long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long[] tmp = new long[n - 1];
        for (int i = 0; i < n - 1; i++)
        {
            if (t - (x[i + 1] - x[i]) > 0)
            {
                tmp[i] = t - (x[i + 1] - x[i]);
            }
        }

        var ans = n * t - tmp.Sum();
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 32544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  int maxa = A[N-1];
  int cnt = 0;
  int profit = 0;

  for (int i = N - 2; i >= 0; i--) {
    int prof_now = maxa - A[i];
    if (prof_now > profit) {
      cnt = 1;
      profit = prof_now;
    } else if (prof_now == profit) {
      cnt++;
    }

    maxa = max(maxa, A[i]);
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 640
from collections import deque
s = input()
queue = deque(list(s))
q = int(input())
pre = 0
reverse = 0
for _ in range(q):
    query = input()
    if query == '1':
        if pre:
            pre = 0
        else:
            pre = 1
        reverse += 1
    else:
        _, f, c = query.split()
        if f == '1':
            if pre == 0:
                # s = c + s
                queue.appendleft(c)
            else:
                # s = s + c
                queue.append(c)
        else:
            if pre == 1:
                # s = c + s
                queue.appendleft(c)
            else:
                # s = s + c
                queue.append(c)
if reverse % 2 == 1:
    queue = reversed(queue)
print(''.join(queue))


Measured memory_bytes: 74472
#include"bits/stdc++.h"
#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 all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    string s;
    cin >> s;
    cout << s;
    if (s[s.size() - 1] == 's')cout << "es" << endl;
    else cout << "s" << endl;
    return 0;
}

Measured memory_bytes: 3592
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    // 型を指定すること！
    let mut ans:u64 = 0;
    let mut white:u64 = 0;
    // 後ろから見ていき、黒について、自身より後ろにある白の数だけ操作可能
    let N = S.len();
    for i in 0..N{
        if S[N-1-i]=='B'{
            ans += white;
        }else{
            white += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
N = gets.to_i
array = [1]
ret = [0]
(1..N).each {|i| ret.push(100000)}
(1..6).each {|i| array.push(6**i)}
(1..5).each {|i| array.push(9**i)}
(1..N).each do |i|
    array.each do |a|
        next if i - a < 0
        ret[i] = [ret[i], (ret[i-a] + 1)].min
    end
end
puts ret[N]

Measured memory_bytes: 3836
n, m = [int(i) for i in input().split()]
a = [0 for i in range(m)]
b = [0 for i in range(m)]

s = [[0, 0] for i in range(m)]
for i in range(m):
    a[i], b[i] = [int(i) for i in input().split()]
    s[i] = [b[i], a[i]]
count = 0
s = sorted(s)
#print(s)
i = 0
pivot = -1

for i in range(m):
    if s[i][1] >= pivot:
        count += 1
        pivot = s[i][0]
        #print("i :{} piv:{}".format(i, pivot))

"""
    count += 1
    pivot = s[i][0]
    print("i :{} piv:{}".format(i, pivot))
    i += 1
    if i < m:
        while s[i][1] < pivot:
            i += 1
            print("i2:{} piv:{}".format(i, pivot))
"""
print(count)



Measured memory_bytes: 22380
/***********************************************
 *                   _ooOoo_                   *
 *                  o8888888o                  *
 *                  88" . "88                  *
 *                  (| -_- |)                  *
 *                  O\  =  /O                  *
 *               ____/`---'\____               *
 *             .'  \\|     |//  `.             *
 *            /  \\|||  :  |||//  \            *
 *           /  _||||| -:- |||||-  \           *
 *           |   | \\\  -   * |    |           *
 *           | \_|  ''\---/''  |   |           *
 *           \  .-\__  `-`  ___/-. /           *
 *         ___`. .'  /--.--\  `. . __          *
 *      ."" '<  `.___\_<|>_/___.'  >'"".       *
 *     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     *
 *     \  \ `-.   \_ __\ /__ _/   .-` /  /     *
 *======`-.____`-.___\_____/___.-`____.-'======*
 *                   `=---='                   *
 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define ll long long
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?EOF:*p1++)
using namespace std;
char buf[(1<<22)],*p1=buf,*p2=buf;
inline ll read(){
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
const int maxn=4005;
int main()
{
    #ifdef DanDan
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //DanDan
    string s;
    while(cin>>s){
        if(s=="Sunny")cout<<"Cloudy\n";
        if(s=="Cloudy")cout<<"Rainy\n";
        if(s=="Rainy")cout<<"Sunny\n";
    }

    #ifdef DanDan
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n\n\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //DanDan
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> B(A.size() + 1, 0);
    partial_sum(A.begin(), A.end(), B.begin() + 1);

    ll ans = 1e16;
    for (int i = 2; i <= N - 2; i++) {
        ll P, Q, R, S;
        ll front_sum = B[i] - B[0];
        ll back_sum = B[N] - B[i];

        ll gap = 1e16;
        int p;
        p = lower_bound(B.begin(), B.end(), front_sum / 2) - B.begin() - 1;
        for (int j = p; j < i; j++) {
            ll f = B[j] - B[0];
            ll b = front_sum - f;
            if (gap > abs(b - f)) {
                P = f;
                Q = b;
                gap = abs(b - f);
            }
            if (b - f < 0) break;
        }

        gap = 1e16;
        p = lower_bound(B.begin() + i + 1, B.end(), B[i] + back_sum / 2) -
            B.begin() - 1;
        for (int j = p; j < N; j++) {
            ll f = B[j] - B[i];
            ll b = back_sum - f;
            if (gap > abs(b - f)) {
                R = f;
                S = b;
                gap = abs(b - f);
            }
            if (b - f < 0) break;
        }

        ans = min(ans, (max({P, Q, R, S}) - min({P, Q, R, S})));
    }

    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int W,H;
vector<int> q,p;
ll R[100005];
int main(){
  cin >> W >> H;
  p.resize(W);
  q.resize(H);
  for( int &a : p ) cin >> a;
  for( int &a : q ) cin >> a;
  
  sort( q.begin(), q.end() );
  for( int i=0;i<H;i++)
    R[i+1] = R[i] + q[i];
  ll res = 0;
  for( int a : p ) res += a;
  for( int a : q ) res += a;
  
  for( int i=0;i<(int)p.size();i++ ){
    int k = (int)(upper_bound( q.begin(), q.end(), p[i] ) - q.begin());
    res += R[k] + (ll)( H-k ) * (ll)p[i];
  }
  cout << res << endl;
}


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

signed main(){
	int k, n;
	cin >> k >> n;
	int a[n];
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a, a + n);
	int sum = 1e18, cursum = 0;
	for(int i = 0; i < n; ++i){
		cursum += (a[i] - a[(i - 1 + n) % n] + k) % k;
	}	
	for(int i = 0; i < n; ++i){
		int temp = (a[i] - a[(i - 1 + n) % n] + k) % k;
		if(cursum - temp < sum){
			sum = cursum - temp;
		}
	}
	cout << sum;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a, b, c,i,j;
	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i <= b; i++)
	{
		if (c%i == 0)
		{
			j++;
		}
	}
	printf("%d\n", j);
	return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0; i<s.length(); i++){
        int x = s[i]-'A';
        x = (x+n)%26;
        cout << char ('A' + x);
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

void solve(){

}

#else

const int MAXN = 1e3 + 9;

void solve() {

    int x, a;
    int c;
    int y, b;

    cin >> x >> y >> a >> b >> c;
    vector<pair<ll, int>> v;
    for (int i = 0; i < a; ++i){
        ll c;
        cin >> c;
        v.push_back({c, 1});
    }
    for (int i = 0; i < b; ++i){
        ll c;
        cin >> c;
        v.push_back({c, 0});
    }

    for (int i = 0; i < c; ++i){
        ll c;
        cin >> c;
        v.push_back({c, -1});
    }

    sort(v.rbegin(), v.rend());
    int ea = 0;
    ll answr = 0;

    int ea_red = 0;
    int ea_green = 0;

    for (int i = 0; i < a + b + c; ++i){
        if (ea == x + y)
            break;
        if (v[i].second == 1){
            if (ea_red < x){
                ++ea_red;
                answr += v[i].first;
                ++ea;
            }
        }
        if (v[i].second == 0){
            if (ea_green < y){
                ++ea_green;
                answr += v[i].first;
                ++ea;
            }
        }
        if (v[i].second == -1){
            answr += v[i].first;
            ++ea;
        }
    }

    cout << answr;
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++)  << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 10476
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
// #define INF 1LL<<60
const int INF = 1e9;

int N;
vector<int> a;
vector<int> result;
int cnt = 0;

void dfs(int from, int prev, vector< vector<int> >& edges, vector<int>& dp) {

    auto itr = lower_bound(dp.begin(), dp.end(), a[from]);
    bool increment = false;
    if(*itr == INF) {
        cnt++;
        increment = true;
    }

    int old = *itr;
    *itr = a[from];

    result[from] = cnt;

    for(int next: edges[from]) {
        if(next != prev) {
            dfs(next, from, edges, dp);
        }
    }

    *itr = old;
    if(increment) {
        cnt--;
    }
}

int main() {
    cin >> N;
    a.resize(N);
    result.resize(N);
    REP(i, N) cin >> a[i];
    vector< vector<int> > edges(N, vector<int>());

    REP(i, N-1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }

    vector<int> dp(N, INF);
    dfs(0, -1, edges, dp);
    REP(i, N) cout << result[i] << endl;
    return 0;
}

Measured memory_bytes: 30976
#include <stdio.h>
int main (void){
 long long int N=0,i;
  long long int ans=0;
  scanf("%lld",&N);
  for(i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0){ 
     ans+=i;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int ketawa(int n){
  int res = 0;
  
  while(n>0){
    res += n%10;
    n /=10;
  }
  return res;
}

int main(){
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  int i;
  int ans=0;
  
  for(i=1;i<=n;++i){
    int sum = ketawa(i);
    if(a<=sum && sum<=b) ans+=i;
  }
  
  printf("%d\n",ans);
}


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  ll ans = 0;
  for(auto&e:v) cin >> e, ans += e-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

string s, t;
int sum[2][2][112345]; // s,t a,b 累積和

int main() {
	cin >> s >> t;
	
	REP(i, s.size()) {
		if (s[i] == 'A') sum[0][0][i + 1]++;
		else sum[0][1][i + 1]++;
	}
	
	REP(i, t.size()) {
		if (t[i] == 'A') sum[1][0][i + 1]++;
		else sum[1][1][i + 1]++;
	}
	
	REP(i, 2) REP(j, 2) FOR(k, 1, 112345) sum[i][j][k] += sum[i][j][k - 1];
	
	int q;
	cin >> q;
	while (q--) {
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		
		int acnt[2] = {sum[0][0][b] - sum[0][0][a - 1], sum[1][0][d] - sum[1][0][c - 1]}; 
		int bcnt[2] = {sum[0][1][b] - sum[0][1][a - 1], sum[1][1][d] - sum[1][1][c - 1]};
		
		int tmp;
		if (acnt[0] < acnt[1]) {
			tmp = acnt[1] - acnt[0];
			acnt[0] += tmp;
			bcnt[0] += tmp;
		}
		
		if (acnt[0] > acnt[1]) {
			bcnt[0] += (acnt[0] - acnt[1]) * 2;
		}
		
		int sa = abs(bcnt[1] - bcnt[0]);
		
		if (sa % 3 == 0) puts("YES");
		else puts("NO");
	}
	
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int a,b,c;
    vector<int> l(3);
    rep(i,3) cin >> l[i];
    sort(l.begin(),l.end());
    a=l[0];
    b=l[1];
    c=l[2];
    int cou = 0;
    while(!(a==b &&b==c)||cou%2==1){
        cou++;
        if(a<=b && a<=c){
            a++;
        }else if (b<=a && b<=c){
            b++;
        }else {
            c++;
        }
    }
    cou/=2;
    cout << cou << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    int ans = 1, H, W;
    char[][] maze;
    int[] dr = new int[]{1,0,-1,0}, dc = new int[]{0,1,0,-1};
    static public void main(String[] args) throws Exception{
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ")
        Main main = new Main();
        System.out.println(main.solve());
    }
    int solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int ans = 0;
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            if(a>=k) ans += 1;
        }
        return ans;
    }

}



Measured memory_bytes: 48604
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s, t;
    cin >> s >> t;
    s = s + s;
    REP(i, SZ(t)) {
        if (s.substr(i, SZ(t)) == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
*D, = map(int, input().split())
m = int(input())
*T, = map(int, input().split())
D.sort()
T.sort()
j = 0
for i in range(n):
    if j == m:
        break
    if D[i] == T[j]:
        j += 1
if j == m:
    print('YES')
else:
    print('NO')


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))

int main(){
  int ans = 0;
  INT(n); INT(m);
  map<int, vector<int>> gr;
  vector<pair<int, int>> es;
  REP(m){
    INT(a); INT(b);
    gr[a].PB(b);
    gr[b].PB(a);
    es.EB(a, b);
  }
  auto check = [&](int a0, int b0){
    set<int> vs = {1};
    stack<int> st; st.push(1);
    while(!st.empty()){
      int v = st.top(); st.pop();
      for(int u: gr[v]){
        if (min(u, v) == a0 && max(u, v) == b0){
          continue;
        } else if (!vs.count(u)){
          vs.insert(u);
          st.push(u);
        }
      }
    }
    if (SZ(vs) < n){
      ans++;
    }
  };
  for(auto ab: es){
    check(ab.first, ab.second);
  }
  printf("%d\n", ans);
  return 0;
}

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

int main(){
  string sen,word;
  cin >> sen >> word;
  sen = sen + sen;
  if(sen.find(word)!=-1)
  {
    cout << "Yes" << endl;
  }else 
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3196
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;

class Main{
    static int[] numbers;
    static int n;

    static boolean check(int index, int sum){
        if(sum == 0){
            return true;
        }

        if(index >= n){
            return false;
        }

        boolean result = check(index+1, sum) || check(index+1, sum-numbers[index]);
        return result;
    }

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        n = Integer.parseInt(br.readLine());
        numbers = new int[n];
        String[] inputn = br.readLine().split(" ");
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(inputn[i]);
        }

        int q = Integer.parseInt(br.readLine());
        String[] inputs = br.readLine().split(" ");

        for(int i = 0; i < q; i++){
            if(check(0,Integer.parseInt(inputs[i]))){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }

    }
}


Measured memory_bytes: 24760
N = int(input())
l = [None]*N
for i in range(N):
    l[i] = [int(x) for x in input().split()]
new_list = sorted(l, key = lambda z:z[1])
total_time = 0
for i in range(N):
    total_time += new_list[i][0]
    if total_time > new_list[i][1]:
        print('No')
        exit()
else:
    print('Yes')


Measured memory_bytes: 42832
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
sizediff_t minIndex(alias pred = "a < b", Range)(Range range)
if (isForwardRange!Range && !isInfinite!Range &&
    is(typeof(binaryFun!pred(range.front, range.front))))
{
    if (range.empty) return -1;

    sizediff_t minPos = 0;

    static if (isRandomAccessRange!Range && hasLength!Range)
    {
        foreach (i; 1 .. range.length)
        {
            if (binaryFun!pred(range[i], range[minPos]))
            {
                minPos = i;
            }
        }
    }
    else
    {
        sizediff_t curPos = 0;
        Unqual!(typeof(range.front)) min = range.front;
        for (range.popFront(); !range.empty; range.popFront())
        {
            ++curPos;
            if (binaryFun!pred(range.front, min))
            {
                min = range.front;
                minPos = curPos;
            }
        }
    }
    return minPos;
}


void selsort(alias pred = "a < b", T)(T a, out int sw)
{
    sw = 0;
    for (size_t i = 0; i < a.length; i++)
    {
        auto min = a[i..$].minIndex!pred + i;
        swap(a[i], a[min]);
        sw++;
    }
}
void bblsort(alias pred = "a < b", T)(T a, out int sw)
{
    sw = 0;
    for (size_t i = 0; i < a.length; i++)
    {
        for (size_t j = a.length - 1; j >= i + 1; j--)
        {
            if (binaryFun!pred(a[j], a[j - 1]))
            {
                swap(a[j], a[j - 1]);
            }
        }
    }
}
void main()
{
    readln;
    auto a = readln().strip.split(" ").array;
    int sw;
    auto b = a.dup;
    auto c = a.dup;
    b.bblsort!((x,y) => x[1..$].to!int < y[1..$].to!int)(sw);
    writeln(b.join(" "));
    writeln("Stable");
    c.selsort!((x,y) => x[1..$].to!int < y[1..$].to!int)(sw);
    writeln(c.join(" "));
    if (b.join(" ") != c.join(" "))
    {
        writeln("Not stable");
    }
    else
    {
        writeln("Stable");
    }
}


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

int main( int argc, char *argv[] )
{
int i;
int N;
int a;
int iMax;
int iMin;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> a;
	iMax = a;
	iMin = a;
	for( i = 1; i < N; i++ )
	{
		cin >> a;
		if( iMax < a ) iMax = a;
		if( iMin > a ) iMin = a;
	}

	cout << iMax - iMin << endl;

	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    int n, q;
    string s;
    int i, j;
    set<int> alphabet[30];
    int x, y, z;
    char c;

    cin >> n >> s >> q;

    rep(i, 0, n)
    {
        alphabet[s[i] - 'a'].insert(i);
    }

    rep(i, 0, q)
    {
        cin >> x >> y;

        y--;

        if (x == 1)
        {
            cin >> c;
        }
        else
        {
            cin >> z;
            z--;
        }

        if (x == 1)
        {
            alphabet[s[y] - 'a'].erase(y);
            s[y] = c;
            alphabet[c - 'a'].insert(y);
        }
        else
        {
            int ans = 0;

            rep(j, 0, 26)
            {
                auto it = alphabet[j].lower_bound(y);

                if (z >= *it && it != alphabet[j].end())
                {
                    ans++;
                }
            }

            printf("%d\n", ans);
        }
    }
}

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

#define LL long long
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int ans[32]={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},k;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>k;
	cout <<ans[k-1];
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

string s;
int ramen;

int main(){
	cin>>s;
	ramen=700;
	Rep(i,3){
		if(s[i]=='o') ramen+=100;
	}
	cout<<ramen<<endl;
	
	  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                        
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = (int)1e5 + 5;
const int mod = (int)1e9 + 7;

int n, k;
int a[N];
int fac[N], inv[N];

int binpow(int x, int y) {
    int res = 1LL;
    x %= mod;
    while (y) {
        if (y & 1) res = (res * x) % mod;
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

void init() {
    fac[0] = 1;
    for (int i = 1; i < N; i++)
        fac[i] = (i * fac[i - 1]) % mod;
    inv[1] = 1;
    for (int i = 2; i < N; i++)
        inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
}

int mod_inv(int x) {
    return binpow(x, mod - 2);
}

int choose(int n, int r) {
    if (n < r) return 0;
    return (fac[n] * (mod_inv(fac[r]) * mod_inv(fac[n - r]) % mod)) % mod;
}

                
int32_t main() {
    fast_cin(); 
    init(); 
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (a[i] * choose(i - 1, k - 1)) % mod;
        ans %= mod;
        ans -= (a[i] * choose(n - i, k - 1)) % mod;
        ans = (ans + mod) % mod;
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
vector<bool> ret(100001);
vector<vector<pair<int,int>>> adj(100001);

int main(){
	int n;
	cin >> n;
	for (int i=1; i<n; ++i){
		int a,b,w;
		cin >> a >> b >> w;
		adj[a].emplace_back(b,w);
		adj[b].emplace_back(a,w);
	}
	deque<pair<int,int>> q={{1,0}};
	vector<bool> vu(n+1);
	vu[1]=true;
	ret[1]=true;
	while (!q.empty()){
		auto f=q.front();
		q.pop_front();
		for (auto& i:adj[f.first]){
			if (!vu[i.first]){
				if ((i.second+f.second)%2 == 0) ret[i.first]=true;
				vu[i.first]=true;
				q.emplace_back(i.first,(i.second+f.second)%2);
			}
		}
	}
	for (int i=1; i<=n; ++i) cout << ret[i] << '\n';
}


Measured memory_bytes: 6400
#include<stdio.h>

int main()
{
  int N;
  int n;
  
  scanf("%d",&N);
  n=N%10;
  if(n==3)
  {
    printf("bon");
  }
  else if(n==0 || n==1 || n==6 || n==8)
  {
    printf("pon");
  }
  else
  {
    printf("hon");
  }
}

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

using namespace std;

int main(){
    int A;
    //Aを定義
    int B;
    //Bを定義
    cin >> A >> B;
    if(A % 2 != B % 2){
        cout << "IMPOSSIBLE" << endl;
        //条件を満たす整数が存在しなければ、代わりにIMPOSSIBLEと出力
    } else {
        cout << (A + B) / 2 << endl;
        //A + B して2で割った数字を出力
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        for (int a=0;a<=N;a++) {
        	for (int b=0;b<=N-a;b++) {

        		if(10000*a+5000*b+1000*(N-a-b)==Y) {
        			System.out.println(a+" "+b+" "+(N-a-b));
        			return;
        		}
        	}
        }

        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 23252
// AtCoder ABC124: B - Great Ocean View
// 2019.9.9 bal4u

#include <stdio.h>

int main()
{
	int i, ans, ma, N, H;
	
	scanf("%d", &N);
	scanf("%d", &ma), ans = 1;
	for (i = 1; i < N; i++) {
		scanf("%d", &H);
		if (H >= ma) ma = H, ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

#define N 10000

int isPrime(int);

int main()
{
  int a[N];
  int n=0,i,j,x;

  scanf("%d",&x);
  for(i = 0; i < x; i++){
    scanf("%d",&a[i]);
  }

  for(i = 0; i < x; i++){
    if(isPrime(a[i]) == 1) n++;
  }

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

  return 0;
}


/*isPrime( x )の擬似コード
    if x <= 1
        return false

    for i = 2 to x-1
        if x % i == 0
            return false

    return true*/
int isPrime(int x){
  int count=0;
  if(x == 2) return 1;
  else if(x < 2 || x % 2 == 0) return 0;

  int i = 3;
  while(i <= sqrt(x)){
      if(x % i == 0) return 0;
      i = i+2;
  } return 1;

}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  ULL N, A, B;
  cin >> N >> A >> B;
  if (A > B) swap(A, B);
  if ((B - 1 - A) % 2 == 1) {
    cout << (B - 1 - A+1) / 2 << endl;
    return 0;
  }
  if (A <= (N - B)) {
    ULL ans = A;
    B -= A;
    A = 1;
    if ((B - A) % 2 != 0) {
      ans++;
      B--;
    }
    ans += (B - A) / 2;
    cout << ans << endl;
  } else {
    ULL ans = N-B;
    A += (N - B);
    B = N;
    if ((B -1- A) % 2 != 1) {
      ans++;
      A++;
    }
    ans += (B - A) / 2;
    cout << ans << endl;
  }

  return 0;
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> X(M), L(M);int ans;
	if (N < M) {
		for (int i = 0;i < M;i++) {
			cin >> X[i];
		}
		sort(X.begin(), X.end());
		for (int j = 0;j < M - 1;j++) {
			L[j] = X[j + 1] - X[j];
		}
		sort(L.begin(), L.end(), greater<int>());
		int Lsum = 0;
		for (int i = 0;i < N - 1;i++) {
			Lsum += L[i];
		}
		ans = X[M - 1] - X[0] - Lsum;
	}
	else if (N >= M) {
		ans = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース

*/
//main.cpp----------------------------
#define max_h 100
#define max_w 100

void solve();
void dfs(int, int, char);


int h, w;
char c[max_h+1][max_w+1];

int main() {

  solve();

  return 0;
}

void solve() {

  cin >> h >> w;
  while(1) {
    if(h==0&&w==0) return;

    rep(i, h) {
      rep(j, w) cin >> c[i][j];
    }
    int res = 0;
    rep(i, h) {
      rep(j, w) {
        if(c[i][j]=='#'||c[i][j]=='@'||c[i][j]=='*') {
          dfs(i, j, c[i][j]);
          ++res;
        }
      }
    }
    cout << res << endl;

    cin >> h >> w;
  }
}

void dfs(int x, int y, char f) {

  c[x][y] = '.';

  for(int dx = -1; dx<=1; dx+=2) {
    if(x+dx>=0&&x+dx<h&&y>=0&&y<w&&c[x+dx][y]==f) {
      dfs(x+dx, y, f);
    }
  }

  for(int dy = -1; dy<=1; dy+=2) {
    if(x>=0&&x<h&&y+dy>=0&&y+dy<w&&c[x][y+dy]==f) {
      dfs(x, y+dy, f);
    }
  }


  return;
}



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

using namespace std;

using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size() > K) {
    cout << S.substr(0, K) << "...\n";
  } else {
    cout << S << endl;
  }
}

Measured memory_bytes: 3656
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MOD = 1000000007;

const int MAX_N = 100000;

int A[MAX_N];

int64 sum = 0;
int cnt[MAX_N+1];
void init(int N){
	FOR(i,N)	sum += A[i], ++cnt[A[i]];
}

void update(int B,int C){
	int64 t = cnt[B];
	sum -= t*B;
	sum += t*C;
	cnt[B] = 0;
	cnt[C] += t;
}




int main(){
	int N;	cin >> N;
	FOR(i,N)	cin >> A[i];

	init(N);

	int Q;	cin >> Q;
	while(Q--){
		int B,C; cin >> B >> C;
		update(B,C);
		cout << sum << endl;
	}

}





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

template<typename T>
T gcd(T a, T b)
{
	return b ? gcd(b, a%b) : a;
}

template<typename T>
T lcm(T a, T b)
{
	return a / gcd(a, b) * b;
}

//(a^e)%mod
template<typename T>
T power(T a, T e, T mod)
{
	if(e == 0)
	{
		return 1;
	}
	if(e % 2 != 0)
	{
		//a^e=a^(e-1)*a
		return (power(a, e - 1, mod) * a) % mod;
	}
	T res = power(a, e / 2, mod);
	//a^e=a^(e/2)*a^(e/2)
	return (res * res) % mod;
}

template<typename T>
class Tree
{
private:
public:
	T data;
	Tree* parent = NULL;
	std::vector<Tree*> children;
	void setData(T x)
	{
		data = x;
	}
	void setParent(Tree* t)
	{
		parent = t;
	}
	void addChild(Tree* t)
	{
		children.push_back(t);
	}
	Tree(){}
	~Tree(){}
	
};

template<typename T>
class Graph
{
public:
	T index;
	vector<T> edge;
	void setEdge(T t)
	{
		edge.push_back(t);
	}
	Graph(){}
	~Graph(){}
};

int main()
{
	using namespace std;
	int n;
	cin >> n;
	Graph<int> G[101];
	for (int i = 0; i < n; ++i)
	{
		int index, k;
		cin >> index >> k;
		G[index].index = index;
		for (int j = 0; j < k; ++j)
		{
			int in;
			cin >> in;
			G[index].setEdge(in);
		}
		sort(G[index].edge.begin(), G[index].edge.end());
	}
	int kyori[101] = {};
	queue<pair<int,int>> Q;
	Q.push(make_pair(1, 0));
	bool visited[101] = {};
	while(!Q.empty())
	{
		pair<int,int> now = Q.front();
		Q.pop();
		if(visited[now.first])
		{
			continue;
		}
		visited[now.first] = 1;
		kyori[now.first] = now.second;
		for (auto a : G[now.first].edge)
		{
			Q.push(make_pair(a, now.second + 1));
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		cout << i << " " << (visited[i]==0?-1:kyori[i]) << endl;
	}
	return 0;
}



Measured memory_bytes: 3164
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

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

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int n;
  cin >> n;
  vector<P> A(n);
  
  rep(i,n){
    int a;
    cin >> a;
    A[i] = {a,i + 1};
  }

  sort(A.begin(), A.end(), [](auto &l, auto &r) {return l.first < r.first;});

  rep(i,n){
    if(i) cout << " ";
    cout << A[i].second;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include<string>
#include<iomanip>
#define N 100
using namespace std;
int main(void) {
	int a;
	int b;
	cin >> a;
	cin >> b;
	if (b%a == 0)
		cout << a + b;
	else
		cout << b - a;

	return 0;
}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N,M = LI()
A = LI()
A.sort(reverse=True)
s = sum(A)
for i in range(M):
    if A[i] < s / (4 * M):
        print ('No')
        exit (0)
print ('Yes')


Measured memory_bytes: 65132
def main():
    N, K = map( int, input().split())
    A = list( map( lambda x: int(x)-1, input().split()))
    T = [0]
    C = [-1]*N
    C[0] = 0
    s = 0
    count = 0
    while True:
        s = A[s]
        count += 1
        if count == K:
            print(s+1)
            return
        if C[s] != -1:
            L = count - C[s]
            break
        C[s] = count
        T.append(s)

    m = len(T) - L
    print( T[-L:][(K-m)%L]+1)
if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  
  for(int i=0; i<10; i++) {
    if(N - 1000 < 0) {
      cout << 1000 - N << endl;
      break;
    }else if(N - 1000 == 0) {
      cout << 0 << endl;
      break;
    }
    N = N - 1000;
    //cout << N << endl;
  }
  return 0;
}

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		map<int, int>mp;
		rep(i, n) {
			int a; scanf("%d", &a);
			mp[a]++;
		}
		for (auto p : mp) {
			if (p.second * 2 > n) { printf("%d\n", p.first); goto g; }
		}
		puts("NO COLOR");
	g:;
	}
}

Measured memory_bytes: 4732