akhauriyash/Code-Regression huggingface dataset:
n1 = n2 = input()
while 1:
	if n1 > -1 and n1 == int(str(n1)[::-1]):
		print n1
		break
	elif n2 == int(str(n2)[::-1]):
		print n2
		break
	n1 -= 1
	n2 += 1

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,k;
	double ans = 0;
	cin >> n >> k;
	for(int i = 1;i <= n;i++){
		int point = i;
		double p = 1;
		while(point < k){
			point *= 2;
			p /= 2;
		}
		ans += p;
	}
	printf("%.20lf\n",ans / n);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=2222222;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    if(n<0|k<0||k>n)return 0;
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*inv[n-k]%mod;
}

int N,M,K;

int dp[4444][4444];

signed main(){
    cin>>N>>M>>K;

    int T=(N+M-1)/(K-1);

    dp[0][0]=1;
    for(int i=0;i<T;i++){
        for(int j=0;j<=i*(K-1);j++){
            for(int k=0;k<K;k++){
                add(dp[i+1][j+k],dp[i][j]);
            }
        }
    }

    int ans=0;
    for(int i=0;i<T;i++){
        for(int j=0;j<=i*(K-1);j++){
            int k=i*(K-1)-j;
            for(int x=1;x<K;x++){
                int y=K-x;
                if(j+x>M||k+y>N)continue;
                if((M-j-x)%(K-1)||(N-k-y)%(K-1))continue;
                add(ans,dp[i][j]);
            }
        }
    }
    cout<<ans<<endl;
}


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

int main(){
    int A, B, K;
    cin >> A >> B >> K;

    vector <int> ans;
    if (B - A >= 2 * K){
        for (int i = A; i < A + K; i++){
            ans.push_back(i);
        }
        for (int i = B - K + 1; i <= B; i++){
            ans.push_back(i);
        }
    }else{
        for (int i = A; i <= B; i++){
            ans.push_back(i);
        }
    }
    
    for (int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
    

    return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int N,M;
map<LL,LL> mp;

int main()
{
    scanf("%d %d",&N,&M);
    _for(i,0,N){
        LL num;
        scanf("%lld",&num);
        mp[num]++;
    }

    _for(i,0,M){
        LL card,num;
        scanf("%lld %lld",&card,&num);
         LL rest = card;
        vector<LL> dele;
        for(auto &a:mp){
            if(a.first >= num) break;
            if(a.second <= rest){
                dele.push_back(a.first);
                rest -= a.second;
            }
            else{
                a.second -= rest;
                rest = 0;
                break;
            }
        }

        _for(j,0,dele.size()){
            mp.erase(dele[j]);
        }

        //cout << card - rest << endl;

        mp[num] = mp[num] + card-rest;
    }

    LL ans = 0;
    for(auto a:mp){
        //cout << a.first <<" "<<a.second <<endl;
        ans += a.first*a.second;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7676
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		sc.close();
		String S1 = S.substring(0, 2);
		String S2 = S.substring(2, 4);

		if(isMM(S1)){
			if(isMM(S2)) {
				System.out.println("AMBIGUOUS");
			} else {
				System.out.println("MMYY");
			}
		} else {
			if(isMM(S2)) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
		}


	}
	public static boolean isMM(String S) {
		int month = Integer.parseInt(S);
		if (month>=1&&month<=12) {
			return true;
		} else {
			return false;
		}
	}
}

Measured memory_bytes: 22608
import sys
input = sys.stdin.readline

n=int(input())
s=list(input().strip())
from collections import deque
que=deque(s)
cnts=0
cntf=0
for i in range(n):
    if s[i]=="(" :
        cnts+=1
    if s[i]==")":
        if cnts==0:
            que.appendleft("(")
        else:
            cnts-=1
for i in range(cnts):
    que.append(")")
print("".join(que))


Measured memory_bytes: 38384
#include <iostream>
#include<cstdio>
#include<algorithm>
#define ll 100005
using namespace std;
struct st
{
    int x,y,w;
} a[ll],b[ll];
bool cmp(st p,st q)
{
    if(p.x==q.x)
        return p.y<q.y;
    return p.x<q.x;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        a[i].w=i;
        cin>>a[i].x>>a[i].y;
        b[i].x=a[i].x;
    }
    sort(a,a+m,cmp);
    int t=a[0].x,k=1;
    for(int i=0; i<m; i++)
    {
        if(a[i].x!=t)
        {
            k=1;
            t=a[i].x;
        }
        b[a[i].w].y=k++;
    }
    for(int i=0; i<m; i++)
        printf("%06d%06d\n",b[i].x,b[i].y);
    return 0;
}


Measured memory_bytes: 3840
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N;
long M;
long[] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      M = readLong();
      A = new long[2 * N];
      foreach (i; 0 .. 2 * N) {
        A[i] = readLong();
      }
      A.sort();
      
      int lo = -1, hi = N;
      for (; lo + 1 < hi; ) {
        const mid = (lo + hi) / 2;
        bool ok = true;
        foreach (i; 0 .. N - mid) {
          ok = ok && (A[2 * mid + i] + A[2 * N - 1 - i] >= M);
        }
        (ok ? hi : lo) = mid;
      }
      
      long ans = -1;
      foreach (i; 0 .. hi) {
        chmax(ans, (A[i] + A[2 * hi - 1 - i]) % M);
      }
      foreach (i; 0 .. N - hi) {
        chmax(ans, (A[2 * hi + i] + A[2 * N - 1 - i]) % M);
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 9716
words = lambda t : list(map(t, input().split()))
n,m,p = words(int)

w_edges = []
f_edges = [[] for _ in range(n)]
b_edges = [[] for _ in range(n)]

for i in range(m):
    a,b,c = words(int)
    w_edges.append((a-1,b-1,c))
    f_edges[a-1].append((b-1))
    b_edges[b-1].append((a-1))

from queue import Queue
def bfs(edges,stt):
    visited = [False] * n
    q = Queue()
    q.put(stt)
    visited[stt] = True
    while not q.empty():
        v = q.get()
        for c in edges[v]:
            if not visited[c]:
                visited[c] = True
                q.put(c)
    return visited

f_visited = bfs(f_edges, 0)
b_visited = bfs(b_edges, n-1)

edges = []
for a,b,c in w_edges:
    if f_visited[a] and b_visited[a] and f_visited[b] and b_visited[b]:
        edges.append((a,b,p-c))

def bellman_ford(edges, num_v, stt):
    inf = float('inf')
    dist = [inf]*num_v
    dist[stt] = 0
    for i in range(num_v+1):
        for a,b,c in edges:
            prev = dist[b]
            dist[b] = min(dist[b], dist[a]+c)
            if i == num_v and prev != dist[b]:
                return -1
    return dist

d = bellman_ford(edges, n, 0)
if d == -1:
    print(-1)
else:
    print(max(0,-d[n-1]))


Measured memory_bytes: 61796
import collections
n=int(input())

def calc(n):
  ans=[]
  while n%2==0:
    ans.append(2)
    n//=2
  f=3
  while f*f<=n:
    if n%f==0:
      ans.append(f)
      n//=f
    else:
      f+=2
  if n!=1:
    ans.append(n)
  return ans

ans=1
if n>2:
  for i in range(2,n):
    c=collections.Counter(calc(i))
    wk=1
    for value in c.values():
      wk*=(value+1)
    ans+=wk
print(ans)
  

Measured memory_bytes: 69732
#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> >;

struct Coord {
    Int x;
    Int y;
};
double CalcDist(Coord first, Coord second);
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId);
Int Factorial(Int n);


void PermutationLoop(Int n, vector<Coord>& coords) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }

    //double (*const calcDistSum[])(vector<Coord>&, vector<Int>&) = {CalcDistSum}; // 関数ポインタ
    auto calcDistSum = [&coords, &v]() {
        return CalcDistSum(coords, v);
    };

    double sum = 0;
    do {
        sum += calcDistSum();
    } while (std::next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
    return;
}


int main(void) {
    Int n;
    cin >> n;
    vector<Coord> coords(n);
    for (Int i = 0; i < n; ++i) {
        cin >> coords[i].x >> coords[i].y;
    }
    PermutationLoop(n, coords);
    return 0;
}

double CalcDist(Coord first, Coord second) {
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId) {
    Int size = (Int)coordId.size();
    double ret = 0;
    for (Int i = 0; i < size - 1; ++i) {
        ret += CalcDist(coords[coordId[i]], coords[coordId[i + 1]]);
    }
    return ret;
}
Int Factorial(Int n) {
    if (n == 1) {
        return 1;
    } else {
        return n * Factorial(n - 1);
    }
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


//-----------///////////////////////////////
vii dp;
struct edge {
    int to;
    int dist;
    edge(int to, int dist): to(to), dist(dist){};
};

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int v, e; cin >> v >> e;
    vii dp_init(1<<v, vi(v, inf));
    vec<vec<edge>> graph(v);
    vec<set<int>> G(v);
    rep(i,e) {
        int s, t, d;
        cin >> s >> t >> d;
        graph[s].push_back(edge(t, d));
        G[s].insert(t);
    }

    // 各頂点から
    vi ans(v, inf);
    for(int StartNode = 0; StartNode < v; ++StartNode) {
        dp = dp_init;
        dp[1<<StartNode][StartNode] = 0;

        for(int Set = (1<<StartNode); Set < (1<<v); ++Set) {
            for(int node = 0; node < v; ++node) if((Set>>node) & 1) {
                for(auto NextNode : graph[node]) if(!(Set>>NextNode.to & 1)) {
                    chmin(dp[Set | (1<<NextNode.to)][NextNode.to], dp[Set][node] + NextNode.dist);

                    // スタート点に戻れるか。戻れたら答えを記録
                    if((Set|(1<<NextNode.to)) == (1<<v)-1) {
                        if(G[NextNode.to].find(StartNode) != G[NextNode.to].end()) {
                            int p;
                            for(auto u : graph[NextNode.to]) {
                                if(u.to == StartNode) {p = u.dist; break;}
                            }
                            chmin(ans[StartNode], dp[Set | (1<<NextNode.to)][NextNode.to] + p);
                        }
                    }
                }
            }
        }
    }

    int answer = inf;
    for(auto i : ans) chmin(answer, i);
    if(answer == inf) cout << -1 << '\n';
    else cout << answer << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}



Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

vector< vector<int> > Graph;
vector< int > value;









int main(int argc, const char * argv[]) {
    
    
    
    string s; cin >> s;
    
    bool isAns = true;
    for (int i = 0; i < (int)s.size(); i++) {
        if(i%2==0 && !(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) isAns = false;
        if(i%2==1 && !(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) isAns = false;
    }
    
    if(isAns) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int A[2000100];
int size = 0;

void insert(int x)
{
	int i;
	for (i = ++size; i / 2 > 0; i /= 2)
	{
		if (x > A[i / 2])
			A[i] = A[i / 2];
		else
			break;
	}
	A[i] = x;
}

int delete()
{
	int parent, child;
	int x = A[size--], max = A[1];
	for (parent = 1; parent * 2 <= size; parent = child)
	{
		child = 2 * parent;
		if (child != size && A[child + 1] > A[child])
			child++;
		if (x > A[child])
			break;
		A[parent] = A[child];
	}
	A[parent] = x;
	return max;
}

int main()
{
	char s[20];
	int x;
	
	scanf("%s", s);
	while (s[2] != 'd')
	{
		if (s[2] == 's')
		{
			scanf("%d", &x);
			insert(x);
		}
		if (s[2] == 't')
			printf("%d\n", delete());
		scanf("%s", s);
	}
}


Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		sc.close();

		for (int i = 0; i < s.length(); i++) {
			if ((s.substring(i) + s.substring(0, i)).equals(t)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define readl(_s) getline(cin, (_s));
#define boost() cin.tie(0); cin.sync_with_stdio(0)

const int MN = 2000005, MOD = 1e9 + 7;

int fpow(int b, int p) {
    if (!p) return 1;
    int ret = fpow(b, p / 2);
    if (p % 2) return ret * ret % MOD * b % MOD;
    return ret * ret % MOD;
}

int n, m, fact[MN], inv[MN];

int ch(int n, int k) {
    return fact[n] * inv[n - k] % MOD * inv[k] % MOD;
}

int pe(int n, int k) {
    return fact[n] * inv[n - k] % MOD;
}

int32_t main() {
    boost();

    cin >> n >> m;
    fact[0] = inv[0] = 1;
    for (int i = 1; i < MN; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = fpow(fact[i], MOD - 2);
    }
    int tot = 0;
    for (int i = 0; i <= n; i++) {
        if (i % 2) tot -= ch(n, i) * pe(m, i) % MOD * pe(m - i, n - i) % MOD * pe(m - i, n - i) % MOD, tot %= MOD;
        else tot += ch(n, i) * pe(m, i) % MOD * pe(m - i, n - i) % MOD * pe(m - i, n - i) % MOD, tot %= MOD;
    }
    tot %= MOD; tot += MOD; tot %= MOD;
    printf("%lld\n", tot);

    return 0;
}

Measured memory_bytes: 35016
/*
[abc134] C - Exception Handling
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 200000;

int N;
int A[MAX_N];
int ml[MAX_N + 1], mr[MAX_N + 1];

void solve() {
    for (int i = 0; i < N; i++) {
        ml[i + 1] = max(ml[i], A[i]);
    }
    for (int i = N; i > 0; i--) {
        mr[i - 1] = max(mr[i], A[i - 1]);
    }

    for (int i = 0; i < N; i++) {
        cout << max(ml[i], mr[i + 1]) << endl;
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
int main(void)
{
	int a,b,c,d;

	scanf("%d %d %d",&a, &b, &c);

	for(a; a<b+1; a++) {
	   if(c%a==0)d++;
	 } 
	printf("%d\n",d);

	return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;
  cin >> n;

  vector<long> h(n);
  fillLong(h, n);

  int now = 0;
  int mx = 0;

  rep(i, n-1) {
    if (h[i+1] <= h[i]) {
      now++;
    } else {
      mx = max(now, mx);
      now = 0;
    }
  }
  mx = max(now, mx);
  cout << mx << endl;
}


Measured memory_bytes: 1024
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define 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 = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string s;
unordered_map<char, int> mp;

void solve() {
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return;
    }
    rep(i, s.length()) mp[s[i]] = int(i + 1);
    for (int i = 'a'; i <= 'z'; i++) {
        if (mp[char(i)] == 0) {
            cout << s + char(i) << endl;
            return;
        }
    }
    string min_s;
    rep(i, s.length()) {
        string cs(s);
        string temp1 = cs.substr(0, i + 1), temp2 = cs.substr(0, i + 1);
        unordered_map<char, int> mp1, mp2;
        rep(i, temp1.length()) mp1[temp1[i]]++;
        rep(i, temp2.length()) mp2[temp2[i]]++;
        for (char j = temp1[i]; j <= 'z'; j++) {
            if (mp1[j] == 0) {
                temp1[i] = j;
                min_s = min_s.empty() ? temp1 : min(min_s, temp1);
                break;
            }
        }
        if (i != 0)
            for (char j = temp2[i - 1]; j <= 'z'; j++) {
                if (mp2[j] == 0) {
                    temp2[i - 1] = j;
                    min_s = min_s.empty() ? temp2 : min(min_s, temp2);
                    break;
                }
            }
    }
    cout << min_s << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 256
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

double dUnitVec(double v1, double v2) {
	return v2 - v1;
}
// ?????¨??§??????????????§????????????????????°???????????°???????????????
int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;

	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
	{
		// 1???????????????????±???????
		// 1-2
		double UnitX1 = x2 - x1;
		double UnitY1 = y2 - y1;

		double UnitX1P = xp - x1;
		double UnitY1P = yp - y1;


		// 2-3
		double UnitX2 = x3 - x2;
		double UnitY2 = y3 - y2;

		double UnitX2P = xp - x2;
		double UnitY2P = yp - y2;

		// 3-1
		double UnitX3 = x1 - x3;
		double UnitY3 = y1 - y3;

		double UnitX3P = xp - x3;
		double UnitY3P = yp - y3;

		// ??????
		double CP1 = UnitX1 * UnitY1P - UnitY1 * UnitX1P;
		double CP2 = UnitX2 * UnitY2P - UnitY2 * UnitX2P;
		double CP3 = UnitX3 * UnitY3P - UnitY3 * UnitX3P;

		// ?????????????????????????¬????????????´???????????????????¢??????????
		if ((CP1 > 0 && CP2 > 0 && CP3 > 0) || (CP1 < 0 && CP2 < 0 && CP3 < 0))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3052
package main

import "fmt"

func main() {
	var n, m int

	fmt.Scan(&n, &m)

	route := make([][]int, n)

	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		a -= 1
		b -= 1
		route[a] = append(route[a], b)
		route[b] = append(route[b], a)
	}

	queue := []int{0}
	//count := make([]int, n)
	ans := make([]int, n)
	ans[0] = -1

	for {
		for _, v := range route[queue[0]] {
			//if ans[v] == 0 && v != 0 {
			if ans[v] == 0 {
				queue = append(queue, v)
				//count[v] = count[queue[0]] + 1
				//count[v] = 1
				ans[v] = queue[0] + 1
			}
		}
		if len(queue) == 1 {
			break
		}
		queue = queue[1:]
	}

	ok := true
	for _, v := range ans {
		if v == 0 {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
		for i := 1; i < n; i++ {
			fmt.Println(ans[i])
		}
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 19080
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
#define V_MAX 100005
#define E_MAX 100005

struct edge {
	int s,t;
};

// Union-Find tree
ll par[V_MAX];
ll ran[V_MAX];
ll siz[V_MAX];

// Init
void init(ll V) {
	for (ll i = 0; i<V; i++) {
		par[i] = i;
		ran[i] = 0;
		siz[i]  = 1;
	}
}

// Find root
ll find(ll x) {
	if (par[x]==x) {
		return x;
	}
	return par[x] = find(par[x]);
}

// Unite
void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x==y) {
		return;
	}

	if (ran[x] < ran[y]) {
		par[x] = y;
		// リーダーはyになりました。
		siz[y] += siz[x];
	} else {
		par[y] = x;
		if (ran[x]==ran[y]) ran[x]++;
		// リーダーはxになりました。
		siz[x] += siz[y];
	}

}

// In Same group? // Connected?
bool same(ll x, ll y) {
	return find(x) == find(y);
}

ll cnt(ll x) {
	// 島xが属する郡のrootまでたどって、その部族の人数を返す
	// rootしか、その部族の人数は知らん
	return siz[find(x)];
}


int main() {
	ll V,E;
	cin >> V >> E;
	vector<edge> es;
	for (ll i = 0; i<E; i++) {
		int s,t;
		cin >> s>>t;
		s--; t--;
		es.push_back({s,t});
	}
	init(V_MAX);
	vector<ll> ans(E_MAX,0);
	// ans[i] : i個の橋がつながっている時の不便さ
	ans[0] = V*(V-1)/2;

	for (ll i = 0; i<E; i++) {
			ll dif;	//便利さ増加分
			edge e = es[E-i-1];
			if (same(e.s,e.t)){
				ans[i+1] = ans[i];
				continue;
			}
			dif = cnt(e.s)*cnt(e.t);
			// cout << cnt(e.s) << " " << cnt(e.t) << endl;
			unite(e.s, e.t);
			ans[i+1] = ans[i] - dif;
	}

	for (ll i = E -1; i>=0; i--) {
		cout << ans[i] <<endl;
	}
	return 0;
}

Measured memory_bytes: 5492
import sys,math
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
S = list(input())

ANS = 0
dp = [None]*N
r,g,b = 0,0,0
for i in range(N):
    elm = S[i]
    if elm=='R':
        r += 1
    elif elm=='G':
        g += 1
    else:
        b += 1
    dp[i] = [r,g,b]

TTL = dp[-1]
for i in range(N):
    f = S[i]
    for j in ['R','G','B']:
        if j==f:
            continue

        for k in range(i+1,N):
            elm = S[k]
            if elm!=j:
                continue
            for l in ['R','G','B']:
                if l==f or l==elm:
                    continue

                if l=='R':
                    d = 0
                elif l=='G':
                    d = 1
                else:
                    d = 2
                ANS += TTL[d] - dp[k][d]

                if k+k-i<N and S[k+k-i]==l:
                    ANS -= 1
print(ANS)

Measured memory_bytes: 69844
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int a[55],n;
int k,cnt;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)
  	cin>>a[i];
  for(int i=0;i<n;i++){
  	if(a[i]!=i+1){
  	  if(k==0){
	    if(cnt==0)
  	      k=i+1;
  	    else{
  	      cout<<"NO";
  	      return 0;
		}
  	  }
  	  else{
  	  	if(a[i]==k)
  	  	  cnt++;
  	  	else{
  	  	  cout<<"NO";
  	  	  return 0;
		}
	  }
	}
  }
  cout<<"YES";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

bool f[1000000];

int main(){
    int k;
    scanf("%d", &k);
    int t = 7;
    int i;
    for(i = 1; ; ++i){
        if(t % k == 0){
            printf("%d\n", i);
            return 0;
        }
        if(!f[t % k])
            f[t % k] = true;
        else
            break;
        t = (t * 10 + 7) % k;
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 2712
n = gets.to_i
l = gets.split.map(&:to_i)

l_max = l.max
idx = l.find_index(l.max)
l.delete_at(idx)
others = l.inject(0){|sum, i| sum + i}

if l_max < others
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  int a[n+1],b[n+1];
  long long ans=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b[i]=a[i]+i;
  }
  map<int,int>m;
  for(int i=1;i<=n;i++){
    m[b[i]]++;
    ans+=m[i-a[i]];
  }
  cout<<ans;
}

Measured memory_bytes: 22088
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

alias Tuple!(int, "n", int, "d") Query;
int[] color;
int[] mem;
int[][] adj;

void bfs(int n, int d, int c) {
    DList!Query queue;
    queue.insert(Query(n, d));
    while(!queue.empty) {
        auto t = queue.front;
        queue.removeFront;
        if (t.d <= mem[t.n]) continue;
        if (color[t.n] == 0) color[t.n] = c;
        mem[t.n] = t.d;
        if (t.d == 0) continue;
        foreach (m; adj[t.n]) {
            if (t.d - 1 <= mem[m]) continue;
            queue.insert(Query(m, t.d-1));
        }
    }
}



void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    color = new int[](N);
    mem = new int[](N);
    fill(mem, -1);
    adj = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        adj[s[0]-1] ~= s[1]-1;
        adj[s[1]-1] ~= s[0]-1;
    }

    auto Q = readln.chomp.to!int;
    auto queries = new int[][](Q);
    foreach (i; 0..Q) {
        queries[i] = readln.split.map!(to!int).array;
    }


    foreach (i; iota(Q-1, -1, -1)) {
        auto v = queries[i][0] - 1;
        auto d = queries[i][1];
        auto c = queries[i][2];
        bfs(v, d, c);
    }

    color.each!writeln;
}


Measured memory_bytes: 27388
youbi = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

num=0
Nnew = input()

for i in range(len(youbi)):
    if Nnew == youbi[i]:
        break

while 1:
    num = num + 1
    i = i+1
    if i>6:
        i=0
    if youbi[i] == "SUN":
        break
print (num)



Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>


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

	string a;
	a = p.substr(0, p.size() - 8);
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,sum;
    scanf("%d %d",&A,&B);
    sum=B+B;
    if(A>sum)
    {
        printf("%d",A-sum);
    }
    else if(sum==A)
    {
        printf("0");
    }
    else
    {
        printf("0");
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var list = new List<int> { 105, 135, 165, 189, 195 };
        int ans = 0;
        for (int i = 0; i <= n; i++)
        {
            if (list.Contains(i)) ans++;
        }
        Console.WriteLine(ans);
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> X(N+2);
    for (int i = 1; i <= N; ++i) cin >> X[i];
    X[N+1] = 2020;
    int M; cin >> M;

    int i = 0; 
    bool flag = true;

    for (int i = 0; i < M; ++i) {
        int key;
        cin >> key;
         // keyの駒を動かす
        if (X[key] + 1 == X[key+1] || X[key] == 2019) 
            continue;
        X[key]++;
    }

    for (int i = 1; i <= N; ++i) {
        cout << X[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7

def main():
    K = input()
    D = int(input())

    dp = [[[0]*2 for _ in range(D)] for _ in range(len(K) + 1)] 
    dp[0][0][0] = 1
    for i in range(len(K)):
        M = int(K[i])
        for j in range(D):
            for k in range(10):
                if k < M:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1] + dp[i][j][0]
                elif k == M:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1]
                    dp[i + 1][(j + k)%D][0] += dp[i][j][0]
                else:
                    dp[i + 1][(j + k)%D][1] += dp[i][j][1]
                dp[i + 1][(j + k)%D][0] %= MOD
                dp[i + 1][(j + k)%D][1] %= MOD
    ans = sum(dp[-1][0])
    print((ans - 1)%MOD)       
if __name__ == '__main__':
    main()
    

Measured memory_bytes: 129372
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num, gen;
	scanf("%d%d", &num, &gen);
	if (num % 2 == 0)
	{
		printf("%d", num / 2);
		for (int i = 1; i < gen; i++)printf(" %d", num);
		printf("\n");
	}
	else
	{
		vector<int>ans;
		for (int i = 0; i < gen; i++)ans.push_back(num / 2 + 1);
		for (int p = 0; p < gen / 2; p++)
		{
			if (ans[ans.size() - 1] == 1)ans.pop_back();
			else
			{
				ans[ans.size() - 1]--;
				for (int i = ans.size(); i < gen; i++)ans.push_back(num);
			}
		}
		for (int i = 0; i < ans.size(); i++)printf("%d ", ans[i]);
		printf("\n");
	}
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 400010;
inline ll read()
{
  ll p=0; ll f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}

int n,h; int a[N]; int b[N];
bool cmp(const int &x,const int &y){return x>y;}
int main()
{
  
  n=read(); h=read(); int mx = 0;
  for(int i=1;i<=n;i++) a[i]=read(),b[i]=read(),mx=max(mx,a[i]);
  sort(b+1,b+n+1,cmp);
  int s=0; for(int i=1;i<=n;i++)
  {
    if(b[i] >= mx) s++,h-=b[i];
    if(h<=0){printf("%d\n",s); return 0;}
  }
  if(h%mx == 0) s+=h/mx;
  else s+=h/mx+1;

  return printf("%d\n",s),0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

struct Point {
  ll x, y;
};

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

  ll n;
  cin >> n;
  ll d;
  cin >> d;
  ll D = d*d;
  std::vector<Point> A(n);
  int ans {};
  rep(i, n) {
    cin >> A[i].x >> A[i].y;
    long long tmp = A[i].x*A[i].x + A[i].y*A[i].y;
    //cout << tmp << '\n';
    if (tmp <= D) ++ans;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w,x;
ll T;


vector<ll> deg;
vector<vector<ll> > C(5000 , vector<ll>());

vector<ll> A;
vector<ll> B;

ll mark[5000] = {0};

ll dfs(ll a, ll par, ll d){

    //cout << a << " " << par << "\n";

    ll svar = (d < 0);

    for(ll c1 = 0; c1 < deg[a]; c1++){
        ll b = C[a][c1];
        if(b != par){
            svar += dfs(b,a,d-1);
        }
    }
return svar;
}


int main()
{
   ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,e,g;
    ll y,z;
    //freopen("stupd.txt","r",stdin);
    //freopen("output.txt","w",stdout);

  cin >> n >> k;

    for(c1 = 0; c1 < n; c1++){
        deg.push_back(0);
    }

  for(c1 = 0; c1 < n-1; c1++){
    cin >> a >> b;
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    C[a].push_back(b);
    C[b].push_back(a);
    A.push_back(a);
    B.push_back(b);
  }

  ll ans = n;



    for(c1 = 0; c1 < n; c1++){
        if(k % 2 == 0){
            ans = min(ans , dfs(c1 , -1 , k/2));
        }
        else{
            if(c1 != n-1){
                ans = min(ans , dfs(A[c1],B[c1],k/2) + dfs(B[c1],A[c1],k/2));
            }
        }

    }
    
    

  cout << ans << "\n";




	return 0;

}

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

int count(int n, int x){
    int cnt = 0;
    for(int i = 1; i <= n-2; i++){
        for (int j = i + 1; j <= n-1; j++){
            for(int k = j + 1; k <= n; k++){
                if(i + j + k == x){
                    cnt++;
                }
            }
        }
    }
    return cnt;
}

int main(){
    int n, x;

    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        cout << count(n, x) << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
ipt = [int(input()) for i in range(5)]

def ceilOnesPlace(i:int):
    return int((i + 9) / 10) * 10

S = sum([ceilOnesPlace(con) for con in ipt])

S -= max([(10 - (con%10))%10 for con in ipt])

print(S)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int n, ans;
bool pre;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int a;
		scanf("%d", &a);
		if (a == i)
		{
			if (pre) pre = false;
			else
			{
				pre = true;
				ans++;
			}
		}
		else pre = false;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

const int MAX = 1000000001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    // set<int> s;
    // rep(i, n) s.insert(a.at(i));
    // string ans = "YES";
    // if (s.size() != n) ans = "NO";
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    string ans = "YES";
    if (a.size() != n) ans = "NO";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
import java.util.*;
import java.util.Map.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),m=s.nextInt();

		TreeMap<Integer,Long>map=new TreeMap<>(Comparator.reverseOrder());
		for(int i=0;i<n;++i)
			map.merge(s.nextInt(),1L,Long::sum);
		for(int i=0;i<m;++i) {
			long a=s.nextInt();
			int b=s.nextInt();
			map.merge(b,a,Long::sum);
		}


		int c=0;
		long r=0;
		for(Entry<Integer,Long>e:map.entrySet()) {
			long d=Math.min(n-c,e.getValue());
			r+=d*e.getKey();
			c+=d;
			if(c==n)
				break;
		}
		//System.err.println(map);
		System.out.println(r);
	}
}

Measured memory_bytes: 107560
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;
///-------------------------------------------


int gcd(int a,int b) { return b?gcd(b,a%b):a; }

int main(){
    int N;
    cin>>N;
    int cnt=0;
    while(N--){
        int l,r;
        scanf("%d %d",&l,&r);
        cnt+=r-l+1;
    }
    cout<<cnt<<endl;
}





















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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 2e5+10;
const lint LNF = 2e18;

int n, A[MAX];
lint F[MAX], I[MAX];
int P[MAX], a, c;

lint pw(lint a, int e){
	if(e==0) return 1;
	lint t = pw(a, e/2); t = t*t%MOD;
	return (e%2) ? t*a%MOD : t;
}

lint C(int n, int r){
	if(n<0 || n<r) return 0;
	return F[n] * I[r] % MOD * I[n-r] % MOD;
}

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

	cin>>n;
	for(int i=1; i<=n+1; i++) cin>>A[i];
	for(int i=1; i<=n+1; i++){
		if(P[A[i]]!=0){
			a = P[A[i]]-1, c = n+1-i;
		} else {
			P[A[i]] = i;
		}
	}
	F[0] = 1, I[0] = pw(F[0], MOD-2);
	for(int i=1; i<=2*n; i++)
		F[i] = F[i-1] * i % MOD, I[i] = pw(F[i], MOD-2);

	for(int k=1; k<=n+1; k++){
		lint ans = C(n+1, k) + MOD - C(a+c, k-1);
		ans %= MOD;
		cout<<ans<<'\n';
	}


	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cmath>

using namespace std;
typedef unsigned long long ll;
ll n,a;
ll solve(int m){
	long double x = pow(n,(double)(1/(double)m));
	ll b = x,res = 1,i;
	for(i=0;i<m;i++) res *= b;
	ll ret = b*m + a*(m-1);
	while(res<n){
		ret++;
		res /= b;
		res *= (b + 1);
	}
	return ret;
}

int main(){
	ll i,ans = 100000000000000;;
	cin >> n >> a;
	for(i=1;i<50;i++){
		ans = min(ans,solve(i));
		if(solve(i)>ans) break;
	}
	cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<typename T>
vector<vector<vector<T>>> Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(d1, vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

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

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

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

  constexpr int BASE = 12800;
  int h, w;
  cin >> h >> w;

  auto v1_table = Make2DVector(h, w, 0);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> v1_table[y][x];
    }
  }
  auto v2_table = Make2DVector(h, w, 0);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> v2_table[y][x];
    }
  }

  auto dp = Make3DVector(h, w, 2 * BASE + 1, 0);
  dp[0][0][BASE + v1_table[0][0] - v2_table[0][0]] = 1;
  dp[0][0][BASE - v1_table[0][0] + v2_table[0][0]] = 1;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (y - 1 >= 0) {
        for (int k = 0; k <= 2 * BASE; k++) {
          if (dp[y - 1][x][k]) {
            dp[y][x][k + v1_table[y][x] - v2_table[y][x]] = 1;
            dp[y][x][k - v1_table[y][x] + v2_table[y][x]] = 1;
          }
        }
      }

      if (x - 1 >= 0) {
        for (int k = 0; k <= 2 * BASE; k++) {
          if (dp[y][x - 1][k]) {
            dp[y][x][k + v1_table[y][x] - v2_table[y][x]] = 1;
            dp[y][x][k - v1_table[y][x] + v2_table[y][x]] = 1;
          }
        }
      }
    }
  }

  int ans = INT32_MAX;
  for (int k = 0; k <= 2 * BASE; k++) {
    if (dp[h - 1][w - 1][k]) {
      UpdateMin(ans, abs(BASE - k));
    }
  }
  cout << ans << endl;
}


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

#define ll long long

using namespace std;

const int maxn = (int)2e5 + 7;
const int INF = (int)1e9;

ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],t,cost[maxn],tout[maxn],mn = INF,p[maxn];

vector < pair < ll, ll> > g[maxn];

vector <ll> ans;

int main()
{
    //freopen("island2.in" , "r" , stdin);
    //freopen("island2.out" , "w" , stdout);
    cin >> b[1] >> b[2] >> b[3];
    sort(b + 1, b + 1 + 3);
    cout << (b[2] - b[1]) + (b[3] - b[2]);
    return 0;
}


Measured memory_bytes: 8448
n=int(input())
v=list(map(int,input().split()))
cnt1=[0 for i in range(100001)]
cnt2=[0 for i in range(100001)]
for i in range(n):
    if i%2==0:
        cnt1[v[i]]+=1
    else:
        cnt2[v[i]]+=1
k1=0
k1m=0
k2=0
k2m=0
for i in range(100001):
    if cnt1[i]>=cnt1[k1]:
        k1,k1m=i,k1
    elif cnt1[i]>cnt1[k1m]:
        k1m=i
for i in range(100001):
    if cnt2[i]>=cnt2[k2]:
        k2,k2m=i,k2
    elif cnt2[i]>cnt2[k2m]:
        k2m=i
if k1!=k2:
    print(n-cnt1[k1]-cnt2[k2])
else:
    print(n-(cnt1[k1]+max(cnt1[k1m],cnt2[k2m])))


Measured memory_bytes: 20672