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

using namespace std;

struct State {
	int emp; long long cost;
	int tile[9];
};

bool operator > (const State& s1, const State& s2) {
	return s1.cost > s2.cost;
}

long long ch, cv;
State goal;
map<int, int> hash;

int dx[9][2] = {
	{8, 1}, {0, 2}, {1, 3}, {2, 4}, {3, 5},
	{4, 6}, {5, 7}, {6, 8}, {7, 0}
};

int dy[9][2] = {
	{6, 3}, {7, 4}, {8, 5}, {0, 6}, {1, 7},
	{2, 8}, {3, 0}, {4, 1}, {5, 2}
};

void solve(State start) {
	priority_queue<State, vector<State>, greater<State> > q;
	q.push(start);
	
	while (!q.empty()) {
		State s = q.top(); q.pop();
		
		bool end = true;
		for (int i = 0; i < 9; i++) if (s.tile[i] != goal.tile[i]) end = false;
		if (end) {
			cout << s.cost << endl;
			break;
		}
		
		int j = s.emp;
		
		/********************** left *******************************/
		swap(s.tile[j], s.tile[dx[j][0]]);
		s.emp = dx[j][0];
		s.cost += ch;
		
		int h = 0;
		for (int i = 0; i < 9; i++) h = 10 * h + s.tile[i];
		
		if (hash[h] == 0 || hash[h] > s.cost) {
			q.push(s);
			hash[h] = s.cost;
		}
		swap(s.tile[j], s.tile[dx[j][0]]);
		s.emp = j;
		s.cost -= ch;
		
		/********************** right *******************************/
		swap(s.tile[j], s.tile[dx[j][1]]);
		s.emp = dx[j][1];
		s.cost += ch;
		
		h = 0;
		for (int i = 0; i < 9; i++) h = 10 * h + s.tile[i];
		
		if (hash[h] == 0 || hash[h] > s.cost) {
			q.push(s);
			hash[h] = s.cost;
		}
		
		swap(s.tile[j], s.tile[dx[j][1]]);
		s.emp = j;
		s.cost -= ch;
		
		/********************** top *******************************/
		swap(s.tile[j], s.tile[dy[j][0]]);
		s.emp = dy[j][0];
		s.cost += cv;
		
		h = 0;
		for (int i = 0; i < 9; i++) h = 10 * h + s.tile[i];
		
		if (hash[h] == 0 || hash[h] > s.cost) {
			q.push(s);
			hash[h] = s.cost;
		}
		
		swap(s.tile[j], s.tile[dy[j][0]]);
		s.emp = j;
		s.cost -= cv;
		
		/********************** bottom *******************************/
		swap(s.tile[j], s.tile[dy[j][1]]);
		s.emp = dy[j][1];
		s.cost += cv;
		
		h = 0;
		for (int i = 0; i < 9; i++) h = 10 * h + s.tile[i];
		
		if (hash[h] == 0 || hash[h] > s.cost) {
			q.push(s);
			hash[h] = s.cost;
		}
		
		swap(s.tile[j], s.tile[dy[j][1]]);
		s.emp = j;
		s.cost -= cv;
	}
}

int main() {
	while (1) {
		cin >> ch >> cv; if (ch == 0 && cv == 0) break;
		
		State start;
		start.cost = 0;
		for (int i = 0; i < 9; i++) {
			int d; cin >> d;
			if (d == 0) start.emp = i;
			start.tile[i] = d;
		}
		
		for (int i = 0; i < 9; i++) {
			cin >> goal.tile[i];
		}
		
		hash.clear();
		solve(start);
	}
	
	return 0;
}

Measured memory_bytes: 32432
alp = [chr(i) for i in range(97, 97+26)]
cnt = [0] * 26

w = list(input())

for W in w:
    for i in range(26):
        if W == alp[i]:
            cnt[i] += 1

for i in range(26):
    if cnt[i] % 2 :
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long v = sc.nextLong();
		long b = sc.nextLong();
		long w = sc.nextLong();
		long t = sc.nextLong();
		sc.close();

		// v <= w なら追いつけない
		if (v <= w) {
			System.out.println("NO");
			return;
		}
		// v > w だったらt秒間に間を詰められるか計算する
		if (a < b) {// 鬼が後ろにいる
			BigInteger bigT = BigInteger.valueOf(t);
			BigInteger avt = BigInteger.valueOf(a).add(BigInteger.valueOf(v).multiply(bigT));
			BigInteger bwt = BigInteger.valueOf(b).add(BigInteger.valueOf(w).multiply(bigT));

			if (avt.compareTo(bwt) != -1) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} else { // 鬼が前にいる
			BigInteger bigT = BigInteger.valueOf(t);
			BigInteger avt = BigInteger.valueOf(a).add(BigInteger.valueOf(v).multiply(bigT).negate());
			BigInteger bwt = BigInteger.valueOf(b).add(BigInteger.valueOf(w).multiply(bigT).negate());

			if (avt.compareTo(bwt) != 1) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}


Measured memory_bytes: 27220
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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 A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll H,W; cin >> H >> W;
    ll tmp = 100100100100100100;
    reps(h,1,H-1){
        ll h1 = (H-h)/2;
        chmin(tmp, max(max(h*W, h1*W),(H-h-h1)*W) - min(min(h*W, h1*W),(H-h-h1)*W));
        ll w1 = W/2;
        chmin(tmp, max(max(h*W, w1*(H-h)),(W-w1)*(H-h)) - min(min(h*W, w1*(H-h)),(W-w1)*(H-h)));
    }
    reps(w,1,W-1){
        ll w1 = (W-w)/2;
        chmin(tmp, max(max(w*H, w1*H),(W-w-w1)*H) - min(min(w*H, w1*H),(W-w-w1)*H));
        ll h1 = H/2;
        chmin(tmp, max(max(w*H, h1*(W-w)),(H-h1)*(W-w)) - min(min(w*H, h1*(W-w)),(H-h1)*(W-w)));
    }
    cout << tmp << ednl;
    return 0;
}


Measured memory_bytes: 3672
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;
const ll MOD = pow(10, 9) + 7;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}


int main() {
	ll K;
	ll sum = 0;
	cin >> K;
	for(ll i=1;i<=K;i++)
		for(ll j=1;j<=K;j++)
			for (ll l = 1; l <= K; l++) {
				sum += gcd(i, gcd(j, l));
			}
	cout << sum << endl;
}


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

int main(){
  int sum,max,x;
  max=-1;
  sum=0;
  for(int i=1;i<=3;i++){
  	scanf("%d",&x);
    sum+=x;
    if(max<x) max=x;
  }
  printf("%d",sum-max);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
// #define a first
// #define b second
const int mod = 1e9 + 7;
vector < vi > v(100010);
stack <int > st;
int dp[1010][1010], n, m;
char arr[1010][1010];

int f(int i, int j){
    if(i >= n || j >= m)
        return 0;
    if(arr[i][j] == '#')
        return 0;
    if(i == n - 1  && j == m - 1)
        return 1;
    if(dp[i][j] != -1)  return dp[i][j]%mod;

    return dp[i][j] = (f(i + 1, j)%mod + f(i, j + 1)%mod)%mod;
}



int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);	
    
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            cin >> arr[i][j];
    }

    int ans = f(0, 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11648
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 60;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll as(n);

  rep(i, n) cin >> as[i];
  Sort(as);
  vll bs(n);
  rep(i, n) bs[i] = as[n - 1 - i];

  auto f = [&](ll x) {
    ll ans = 0;
    rep(i, n) {
      ll a = as[i];
      ll l = -1, r = n, m;
      if (a >= 0) {
        while (l + 1 < r) {
          m = (l + r) / 2;
          if (as[m] * a < x)
            l = m;
          else
            r = m;
        }
        ans += r;
      } else {
        while (l + 1 < r) {
          m = (l + r) / 2;
          if (as[m] * a < x)
            r = m;
          else
            l = m;
        }
        ans += n - r;
      }
      if (a * a < x) ans--;
    }
    assert(ans % 2 == 0);
    ans /= 2;
    return (ans < k);
  };

  ll l = -INF;
  ll r = INF;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    if (f(m))
      l = m;
    else
      r = m;
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 3456
N = int(input())
E = [[] for _ in range(N)]
for j in range(N):
	t = input()
	for i in range(N):
		if t[i] == '1':
			E[j].append(i)

ANS = -1
for start in range(N):		
	cnt = [0] * N
	cnt[start] = 1
	q = [start]
	cond = 0
	while q:
		cp = q.pop(0)
		if cp < 0:
			continue
		cnt[cp] *= -1

		for nep in E[cp]:
			if cnt[nep] < 0:
				continue
			elif cnt[nep] > 0:
				if cnt[nep] == cnt[cp] * (-1) + 1:
					continue
				else:
					cond = 1
					break
			else:
				cnt[nep] = cnt[cp] * (-1) + 1
				q.append(nep)
	
	if cond:
		continue

	ans = min(cnt) * (-1)
	ANS = max(ANS, ans)

print(ANS)
		

Measured memory_bytes: 42092
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    ll res = 0;

    for (int d = 60; d >= -1; d--) {
        if (d != -1 && !(K & (1LL << d)))
            continue;

        ll tmp = 0;
        for (int e = 60; e >= 0; e--) {
            ll mask = 1LL << e;
            int num = 0;
            rep(i, N) if (A[i] & mask) num++;

            if (e > d) {
                if (K & mask)
                    tmp += mask * (N - num);
                else
                    tmp += mask * num;
            } else if (e == d) {
                tmp += mask * num;
            } else {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }

    cout << res << endl;
}

Measured memory_bytes: 3972
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
    vector<int> v;
    int a;
    while (scanf("%d", &a) != EOF) {
        if (a != 0) v.push_back(a);
        else {
            printf("%d\n", v.back());
            v.pop_back();
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	float r;
	cin >> r;
	float area = 2.0 * (22.0/7.0) * r;
	cout << area;
}

Measured memory_bytes: 3796
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define endl		'\n'
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k,l,t=0,flag=1,x,m,a[105][105]={0},p,q,visited[105][105]={0},c[10005],col;
ll cnt;
vector<int> v;
void dfs(int i ,int j )
{
    if(visited[i][j]) return;
    visited[i][j]=1;
    if(c[x]==0) x++;
    a[i][j]=x;c[x]--;
    if(i-1>0) dfs(i-1,j);
    if(j-1>0) dfs(i,j-1);
     if(i+1<=p) dfs(i+1,j);
      if(j+1<=q) dfs(i,j+1);
}
int main()
{   ios
    cin>>p>>q;
    cin>>n;
    for(i=1;i<=n;i++) cin>>c[i];
    col=1;x=1;
    dfs(1,1);
    for(i=1;i<=p;i++)
    {
        for(j=1;j<=q;j++)
            cout<<a[i][j]<<" ";cout<<endl;
    }
	return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int ni[100000][26];

int main() {
    string s, t;
    cin >> s >> t;

    REP(i, 26) ni[s.size() - 1][i] = -1;
    ni[s.size() - 1][s[s.size() - 1] - 'a'] = s.size() - 1;
    RREP(i, s.size() - 1) {
        REP(j, 26) {
            if (s[i] == j + 'a') ni[i][j] = i;
            else if (ni[i + 1][j] != -1) ni[i][j] = ni[i + 1][j];
            else ni[i][j] = -1;
        }
    }

    int nii = 0, loop = 0;
    REP(i, t.size()) {
        int n = ni[nii][t[i] - 'a'];
        if (nii == 0 && n == -1) {
            cout << -1 << endl;
            return 0;
        }

        if (n == -1) {
            nii = 0;
            i--;
            loop++;
        }
        else if (n == s.size() - 1) {
            nii = 0;
            loop++;
        }
        else {
            nii = n + 1;
        }
    }

    cout << (ll)loop * s.size() + nii << endl;
    return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  char b; cin >> b;
  if (b == 'A') cout << "T" << endl;
  else if (b == 'T') cout << "A" << endl;
  else if (b == 'C') cout << "G" << endl;
  else cout << "C" << endl;
}


Measured memory_bytes: 256
def main(): 


    card_cnt, gate_cnt = map(int, input().split())

    min_v, max_v = map(int, input().split())
    for _ in range(1, gate_cnt):
        L,R = map(int, input().split())
        min_v = max(min_v, L)
        max_v = min(max_v, R)
        if min_v > max_v:
            print(0)
            break
    else:
        print(len(range(min_v, max_v+1)))

if __name__ == "__main__":
    main() 

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] b = new int[n-1];
    for(int i=0; i<n-1; i++) {
      b[i] = Integer.parseInt(str[i]);
    }
    
    int aSum = b[0]+b[n-2];
    for(int i=0; i<n-2; i++) {
      aSum += Math.min(b[i],b[i+1]);
    }
    
    System.out.println(aSum);
  }
}

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

int a[300];
int main()
{
	int n,k; cin>>n>>k;
	for (int i=1 ; i<=n; i++) a[i]=k+i-1;
	
	int mi=999,sum=0;
	for (int i=1; i<=n; i++)
	{
		if (abs(a[i])<abs(mi)) mi=a[i];
		sum+=a[i];
	}
    
	cout << sum-mi;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int d[] = new int[b];
	int e[] = new int[a];
	int f = 0;
	for(int m=0;m<b;m++ ) {
		d[m] = sc.nextInt();
	}
	for(int n=0;n<a;n++ ) {
		e[n] = 0;
		for(int m=0;m<b;m++ ) {
			e[n] =e[n] +sc.nextInt() *d[m];
		}
		e[n] = e[n] + c;
		if (e[n] > 0)
			f++;
	}
	System.out.println(f);
	sc.close();
}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(long long i=0;i<int(N);++i)
using ll = long long;
// const int INF = 2147483647;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000000LL;
 
 
 int main() {
	 ll a,b,c;
	 cin >> a >> b >> c;
	 if(a%2==0 || b%2==0 ||c%2==0){
		 cout << 0 << endl;
		 return 0;
	 }
	 ll ans = INF;
	 ans = min(ans,a*b);
	 ans = min(ans,c*b);
	 ans = min(ans,a*c);
	 cout << ans << endl;
	 return 0;
 }


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define rept(i,a,b) for(i=a; i<b; ++i)
#define all(a)  a.begin(), a.end()
#define maX(a,b)    ( (a) > (b) ? (a) : (b))
#define miN(a,b)    ( (a) < (b) ? (a) : (b))
#define sz(a) ((int)(a.size()))
#define pb(a) push_back(a)
#define ins(a) insert(a)
#define mkpr make_pair
#define fi first
#define se second
#define newln cout<<"\n"
#define bigPrime 1000000007
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
// continue // break // greater // string // length // while

int main()
{
    fip;
    int n,d,i;
    cin>>n>>d;
    int cnt=0,j=0;
    while(j<n)
    {
        cnt++;
        j=j+(2*d)+1;
    }
    cout<<cnt;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int N, num = 0, buf, prenum = -1;

int main() {
	cin >> N;
	while (N > 0) {
		buf = N % 10;
		if (buf == prenum) {
			num++;
		}
		else {
			num = 0;
		}
		prenum = buf;
		if (num >= 2) {
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}
	cout << "No" << endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m;
    cin >> n >> m;
    vector<int32> a;
    REP(i,n){
        int32 ai;
        cin >> ai;
        a.pb(ai);
    }
    sort(ALL(a));
    if(unique(ALL(a)) != a.end()){
        ANS(0);
        return 0;
    }
    vector<int32> b;
    REP(i,m){
        int32 bi;
        cin >> bi;
        b.pb(bi);
    }
    sort(ALL(b));
    if(unique(ALL(b)) != b.end()){
        ANS(0);
        return 0;
    }
    int64 ans = 1;
    FOR(i,1,n*m+1){
        bool aFound = *lower_bound(ALL(a), i) == i;
        bool bFound = *lower_bound(ALL(b), i) == i;
        if(aFound && bFound){
            ans *= 1;
        }else if(aFound){
            int64 cnt = lower_bound(ALL(b), i) - b.begin();
            cnt = m - cnt;
            ans *= cnt;
        }else if(bFound){
            int64 cnt = lower_bound(ALL(a), i) - a.begin();
            cnt = n - cnt;
            ans *= cnt;
        }else{
            int64 cnt1 = lower_bound(ALL(b), i) - b.begin();
            cnt1 = m - cnt1;
            int64 cnt2 = lower_bound(ALL(a), i) - a.begin();
            cnt2 = n - cnt2;
            ans *= max<int32>(0, cnt1 * cnt2 - (n * m - i));
        }
        ans %= MOD;
    }
    ANS(ans);
    return 0;
}


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

int main(){
  int A , B;
  cin >> A >> B ;
  int a = max(A ,B);

  if(a==A){
    int b = max(a-1, B);
    cout << a + b << endl;
  }
  else {
    int b = max(A,a-1);
    cout << a + b << endl; 
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
#include<bitset>
using namespace std;

bool IsFuzzBuzz(int a)
{
	if (a % 3 == 0 || a % 5 == 0)
	{
		return true;
	}

	return false;
}

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

	unsigned long long total = 0;

	for (int i = 1; i <= N; i++)
	{
		if (!IsFuzzBuzz(i))
		{
			total += i;
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 3620
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
int r;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
    cin >> r;
    int ans = r*r;
    cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll dp[n+1];
  memset(dp,0,sizeof(dp));
  rep(i,n) dp[v[i]]=dp[v[i]-1]+1;
  ll ans=0;
  Rep(i,n+1) chmax(ans,dp[i]); 
  cout<<n-ans<<endl;
}

Measured memory_bytes: 3328
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = [int(input()) for _ in range(n)]
	al.sort()
	l = 1
	r = n-1
	ret = 0
	stl=al[0]
	str=al[0]
	while l <= r:
		g = [abs(stl - al[l]), abs(stl-al[r]), abs(str - al[l]), abs(str - al[r])]
		if max(g) == g[0] or max(g) == g[2]:
			up = al[l]
			l+=1
		else:
			up = al[r]
			r -= 1
			
		if max(g) == g[0]:
			stl = up
		elif max(g)==g[2]:
			str = up
		elif max(g)==g[1]:
			stl=up
		else:
			str = up
		ret +=max(g)
	return ret
		
			
		
		
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main() {
	string s;
	cin>>s;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]==s[i-1])
		{
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  
  for (int i = 0; i < n; i++){
    cin >> w[i];
  }
  
  int ans = 1e9;
  for (int i = 1; i < n; i++){
    int l = 0, r = 0;
    for (int j = 0; j < i; j++){
      l += w[j];
    }
    for (int j = i; j < n; j++){
      r += w[j];
    }
    ans = min(ans, abs(l-r));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
defmodule Main do
  def main do
    [n,k]=IO.gets("") |> String.trim |> String.split(" ") |> Enum.map(&String.to_integer(&1))
    m=IO.stream(:stdio, :line) 
    |> Enum.take(2*k)
    |> Enum.map(&String.trim(&1))
    |> Enum.drop_every(2)
    |> Enum.map(fn x-> String.split(x, " ") end)
    |> Enum.reduce(Enum.map((1..n), fn x-> Integer.to_string(x) end), fn (x,acc)-> acc--x end)
    |> length()
    |> IO.puts()
    
  end
end


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

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

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

  vector<int> A(N);

  rep(i, K){
  int d;
  cin >> d;
  rep(j, d){
    int a;
    cin >> a;
    A.at(a-1)++;
  }
  }

  int count = 0;

  rep(i, N){
    if(A.at(i)==0) count++;
  }

  cout << count;
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

int prime[1001001];
bool is_prime[1001001];

int sieve(int n) {
  int p = 0;
  for (int i = 0; i < n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < n; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j = 2*i; j < n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}

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

  int N;
  cin >> N;

  int ans = 0;
  EACH(n,1,N) {
    if (n % 2 == 0) continue;
    int cnt = 0;
    EACH(i,1,N) {
      if (n % i == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, x; cin >> n >> x;
	int sum = 0, i;
	for(i = 0; i < n && sum <= x; i++){
		int v; cin >> v;
		sum += v;
	}
	cout << i + (sum <= x) << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:55 on 2020-04-26.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    char c;
    cin >> c;
    cout << char(c + 1) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

const int MOD = static_cast<int>(1e9 + 7);

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

    string S;
    cin >> S;
    unsigned long n = S.size();
    long long dp[100001][4] = {};  // { all, A, AB, ABC }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 4; ++j) {
            dp[i + 1][j] += dp[i][j] * (S[i] ==  '?' ? 3LL: 1LL) % MOD;
            if (j < 3 && (S[i] ==  '?' || S[i] == "ABC"[j] )) {
                dp[i + 1][j + 1] += dp[i][j] % MOD;
            }
        }
    }


    cout << dp[n][3] % MOD << '\n';

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 分数の Ceil を求める関数
UInt Ceil(const UInt a, const UInt b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return a / b + 1;
    }
}

int main(void) {
    Int n, k;
    cin >> n >> k;
    if (Ceil(n, 2) >= k) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main() {
  int n;
  while(cin >> n, n) {
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    int ans = 0;
    for(int i = n-1; i >= 0; i--) {
      for(int j = 0; j < i; j++) {
	if(v[j] > v[j+1]) {
	  swap(v[j], v[j+1]);
	  ans++;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1196
#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>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main()
{
    string str;
    cin >> str;

    for (int i=0; i<str.size(); ++i)
    {
        string sub2 = str.substr(i,2);
        if(sub2[0]==sub2[1])
        {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        if(str.size()-i < 3) continue;
        else
        {
            string sub3 = str.substr(i,3);
            if(sub3[0]==sub3[2])
            {
                cout << i+1 << " " << i+3 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define NN 10000
#define NQ 500
int linearSearch(int *,int ,int);
int main(){
  int n, S[NN], q, T[NQ];
  int i=0,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d", &S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d", &T[i]);
  for(i=0;i<q;i++) if(linearSearch(S, T[i], n)) count++;
  printf("%d\n",count);
return 0;
}
int linearSearch(int *A, int key, int n)
{int  i = 0;
 A[n] = key;
 while(A[i]!=key) i++;
 if(i == n) return 0;
 return 1;
}

Measured memory_bytes: 640
class Plan(object):
    def __init__(self, m):
        self.plans = [-1] * (m + 1)
        self.size = m

    def reserve(self, a, b):
        a = self.find_empty(a)
        if a == -1:
            return
        self.plans[a] = [b, a+1]

    def find_empty(self, a):
        if a > self.size:
            return -1
        if self.plans[a] == -1:
            return a
        next_day = self.find_empty(self.plans[a][1])
        if next_day == -1:
            return -1
        self.plans[a][1] = next_day
        return next_day


def main():
    n, m = map(int, input().split())
    w = [list(map(int, input().split())) for _ in range(n)]
    wsorted = sorted(w, key=lambda x: x[1], reverse=True)
    plan = Plan(m)
    for work in wsorted:
        plan.reserve(*work)

    print(sum([p[0] for p in plan.plans if p != -1]))


main()


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
    // clang-format on

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    while (cin >> n >> m, n + m) {
        vector<ll> a(n);
        REP(i, 0, n) {
            cin >> a[i];
        }
        vector<ll> w(m);
        REP(i, 0, m) {
            cin >> w[i];
        }
        vector<vector<ll>> v(n);
        function<void(ll, int, int)> rec = [&](ll sum, int pos, int t) {
            if (pos == m) {
                v[t].push_back(abs(sum));
                return;
            }
            REP(i, -1, 2) {
                rec(sum + i * w[pos], pos + 1, t);
            }
        };
        REP(i, 0, n) {
            rec(a[i], 0, i);
        }

        int cnt = 0;
        vector<ll> ans;
        bool ft = true;

        REP(t, 0, n) {
            sort(v[t].begin(), v[t].end());
            v[t].erase(unique(v[t].begin(), v[t].end()), v[t].end());
            if (v[t][0] == 0) {
                cnt++;
                continue;
            }
            if (ft) {
                ft = false;
                ans = v[t];
            } else {
                vector<ll> tmp;
                set_intersection(ans.begin(), ans.end(), v[t].begin(), v[t].end(), inserter(tmp, tmp.end()));
                ans = tmp;
            }
        }

        if (cnt == n) {
            cout << 0 << endl;
        } else if (ans.size() == 0) {
            cout << -1 << endl;
        } else {
            cout << ans[0] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 44744
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int m;
  cin >> m;
  int n=0,d=1;
  rep(i,m){
    n = (n+7*d)%m;
    if(n==0){
      cout << (i+1) << endl;
      return 0;
    }
    d = (10*d)%m;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    ll ans = 0;
    rep(i,n){
        if (i%2) continue;
        if (a[i]%2) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
int main() {
    ll x, t;
    cin >> x >> t;
    ll ans;
    if(x <= t) ans = 0;
    else ans = x - t;
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n,t=MI()
	A=LI()

	B=[A[0]]
	for i in A[1:]:
		B.append(min(B[-1],i))
	#print(B)

	C=[0]*n

	for i in range(n):
		C[i]=A[i]-B[i]

	c=max(C)
	print(C.count(c))

	
	



	
	
	









if __name__ == "__main__":
	main()


Measured memory_bytes: 92376
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h, n = LI()
if sum(LI()) >= h:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 53232
#include<iostream>
using namespace std;
int main(){
	char s[20];
	int k,q[20];
	while(cin>>s){
		k=9;
		for(int i=0;i<10;i++){
			q[i]=s[i]-'0';
		}
		while(k!=0){
			for(int i=0;i<k;i++)
			q[i]=(q[i]+q[i+1])%10;
			k--;
		}
		cout<<q[0]<<endl;
		
	}
	
	return 0;
}

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

using namespace std;

int main(){
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << char(s1[0] - 'a' + 'A') << char(s2[0] - 'a' + 'A') << char(s3[0] - 'a' + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  ll m = INF;
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    m = min(A.at(i), m);
  }
  ll cnt = 0;
  for (ll i = 0; i < N; ++i) {
    if (A.at(i) == m) {
      cnt += 1;
    }
  }
  ll ans = max(0ll, (N + K - 2 - cnt) / (K - 1));
  cout << ans << "\n";
}


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n;
Int a[212345];
std::vector<Int> e[212345];
bool done[212345];
std::deque<Int> dp;
Int ans[212345];

void dfs(Int node){
	done[node] = true;
	auto it = lower_bound(dp.begin(), dp.end(), a[node]);
	Int x;
	if(it == dp.end()){
		x = -1;
		dp.push_back(a[node]);
	}else{
		x = *it;
		*it = a[node];
	}

	ans[node] = dp.size();

	for(Int i : e[node]){
		if(!done[i]){
			dfs(i);
		}
	}

	if(x == -1){
		dp.pop_back();
	}else{
		*it = x;
	}
}

int main(){
	cin >> n;
	RC(i, n){
		cin >> a[i];
	}
	RC(i, n - 1){
		Int u, v;
		cin >> u >> v;
		--u;
		--v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(0);
	RC(i, n){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 46948
import sys

input = sys.stdin.readline
MOD = 1000000007

N,K = map(int,input().split())


res = 0

if N < K:
    print(1)
    exit()

_min=0
_max=0
for i in range(K):
    _min += i
    _max += (N-i)

res = 0

for i in range(K,N+2):
    if i != K:
       _min+=i-1
       _max+=(N+1 -i)

    #print(_min,_max)
    
    res +=(_max-_min+1)

print(res%MOD)


Measured memory_bytes: 64240