akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * AOj id=0068
 * Enclose Pins with a Rubber Band
 * @author scache
 *
 */
public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(",|\\s");
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			
			ArrayList<double[]> l = new ArrayList<double[]>(n);
			for(int i=0;i<n;i++){
				l.add(new double[]{sc.nextDouble(), sc.nextDouble()});
			}
			solve(n, l);	
		}
	}

	public void solve(int n, ArrayList<double[]> l) {
		Collections.sort(l, new DoubleArrayComparator());
		
		LinkedList<double[]> resu = new LinkedList<double[]>();
		resu.add(l.get(0));
		resu.add(l.get(1));
		
		for(int i=2;i<l.size();i++){
			resu.add(l.get(i));
			while(resu.size()>=3){
				int len = resu.size();
				double[] p1 = resu.get(len-3);
				double[] p2 = resu.get(len-2);
				double[] p3 = resu.get(len-1);
				
				double vx1 = p2[0]-p1[0];
				double vy1 = p2[1]-p1[1];
				double vx2 = p3[0]-p1[0];
				double vy2 = p3[1]-p1[1];
				
				if(vx1*vy2-vx2*vy1 < 0 )
					break;
				
				resu.remove(len-2);	
			}
		}
		
		LinkedList<double[]> resd = new LinkedList<double[]>();
		resd.add(l.get(l.size()-1));
		resd.add(l.get(l.size()-2));
		for(int i=l.size()-2;i>=0;i--){
			resd.add(l.get(i));
			while(resd.size()>=3){
				int len = resd.size();
				double[] p1 = resd.get(len-3);
				double[] p2 = resd.get(len-2);
				double[] p3 = resd.get(len-1);
				
				double vx1 = p2[0]-p1[0];
				double vy1 = p2[1]-p1[1];
				double vx2 = p3[0]-p1[0];
				double vy2 = p3[1]-p1[1];
				
				if(vx1*vy2-vx2*vy1 < 0 )
					break;
				
				resd.remove(len-2);	
			}
		}
		System.out.println(n-resu.size()-resd.size()+2);
		
		
	}

	public class DoubleArrayComparator implements Comparator<double[]>{
		@Override
		public int compare(double[] o1, double[] o2) {
			if(o1[0]==o2[0])
				return Double.compare(o1[1], o2[1]);
			else
				return Double.compare(o1[0], o2[0]);
		}
	}
	
}

Measured memory_bytes: 21048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int vector_finder(vector<char> vec, char number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<char> ng(k);
    rep(i, k) cin >> ng[i];

    bool f = false;
    while(!f){
        f = true;
        string s = to_string(n);
        rep(i, s.size()){
            char c = s[i];
            if(vector_finder(ng, c)){
                f = false;
                break;
            } 
        }
        if(!f) n++;
    }
    cout << n << ln;
}
    


Measured memory_bytes: 256
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		HashSet<Integer> set = new HashSet<Integer>();
		int n, m;
		while(true){
			n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[][] edge = new int[n][n];
			m = scan.nextInt();
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					edge[i][j] = -1;
				}
			}
			scan.nextLine();
			for(int i = 0;i < m;i++){
				String str = scan.nextLine();
				int a, b, d;
				a = Integer.parseInt(str.substring(0,str.indexOf(",")));
				str = str.substring(str.indexOf(",") + 1,str.length());
				b = Integer.parseInt(str.substring(0,str.indexOf(",")));
				str = str.substring(str.indexOf(",") + 1,str.length());
				d = Integer.parseInt(str);
				edge[a][b] = d;
				edge[b][a] = d;
			}
			set.clear();
			int[] mindis = new int[n];
			for(int i = 0;i < n;i++){
				mindis[i] = edge[0][i];
			}
			set.add(0);
			int ans = 0;
			while(set.size() < n){
				int id = -1;
				for(int i = 0;i < n;i++){
					if(!set.contains(i) && mindis[i] != -1 && (id == -1 || mindis[i] < mindis[id])){
						id = i;
					}
				}
				set.add(id);
				ans += mindis[id] / 100 - 1;
				for(int i = 0;i < n;i++){
					if(mindis[i] == -1 || edge[id][i] == -1){
						mindis[i] = Math.max(edge[id][i],mindis[i]);
					}else if(edge[id][i] != -1){
						mindis[i] = Math.min(edge[id][i],mindis[i]);
					}
				}
			}
			System.out.println("" + ans);
		}
	}

}

Measured memory_bytes: 36496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t powermod(int64_t x, int64_t y, int64_t p){
  if(y < 0 || x <= 0)
    return 0;
  else{
    int64_t n = 1;
    x %= p;
    for(int64_t i = 0; i < y; i++){
      n = n*x%p;
    }
    return n;
  }
}
int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i,n) cin >> w[i];
    vector<int> wsum(n,0);
    rep(i,n){
        for(int j = i; j < n; j++){
            wsum[j] += w[i];
        }
    }
    int wall = wsum[n-1];
    int ans = wall;
    rep(i,n) ans = min(ans,abs(wall-2*wsum[i]));
    cout << ans << endl;
}

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


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
		vector<pair<long long,long long>> input;
		for(int i = 0;i < N;++i) input.push_back(make_pair(A[i],B[i]));
		sort(input.begin(),input.end());
		long long ans = 0;
		for(int i = 0;i < input.size();++i){
			if(M <= input[i].second){
				cout << M * input[i].first + ans << endl;
				return;
			}
			M -= input[i].second;
			ans += input[i].second * input[i].first;
		}
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 3956
import java.util.Scanner
import Math.max

object Main extends App {
  val sc = new Scanner(System.in)

  val fene = "Fennec"
  val snuke = "Snuke"

  val N = sc.nextInt()
  val edges = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to N-1) {
    val a, b = sc.nextInt()
    edges(a) = b :: edges(a)
    edges(b) = a :: edges(b)
  }


  //
  sealed trait Color
  case object B extends Color
  case object W extends Color

  val q = new scala.collection.mutable.Queue[(Int, Color)]
  val dp = new Array[Boolean](N+1)

  dp(1) = true; dp(N) = true

  for(e <- edges(1)) {
    q.enqueue((e, B))
  }
  for(e <- edges(N)) {
    q.enqueue((e, W))
  }

  var fenScore = 0; var snuScore = 0
  while(!q.isEmpty) {
    val (node, color) = q.dequeue
    if (!dp(node)) {
      dp(node) = true
      color match {
        case B => fenScore += 1
        case W => snuScore += 1
      }

      for(e <- edges(node)) {
        q.enqueue((e, color))
      }
    }
  }

  if(fenScore > snuScore)
    println(fene)
  else
    println(snuke)

}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

ll fact[210000];
ll invfact[210000];
ll inv(ll a) {

	ll res = 1;
	int p = MOD - 2;
	while (p > 0) {
		if ((p & 1) == 1) { res *= a; res %= MOD; }
		a = a * a % MOD;
		p >>= 1;
	}
	return res;
}

ll inv2(ll a, ll p) {

	ll res = 1;
	while (p > 0) {
		if ((p & 1) == 1) { res *= a; res %= MOD; }
		a = a * a % MOD;
		p >>= 1;
	}
	return res;
}

ll combo(int n, int k) {
	ll res = fact[n];
	res *= invfact[k];
	res %= MOD;
	res *= invfact[n - k];
	return res % MOD;
}

void factpre(int N) {
	fact[0] = 1;
	fx(N) {
		fact[x + 1] = fact[x] * (x + 1);
		fact[x + 1] %= MOD;
	}
	invfact[N] = inv(fact[N]);
	for (int x = N - 1; x >= 0; x--) {
		invfact[x] = invfact[x + 1] * (x + 1);
		invfact[x] %= MOD;
	}
}

int main(){

	ll n, k;
	cin >> n >> k;
	ll ans = 1;
	factpre(200001);
	fx(min(n-1,k)) {
		ll sum = ((combo(n-1,x+1))*combo(n,x+1))%MOD;
		ans += sum;
		ans %= MOD;
		//ce(ans)
	}
	ce(ans)
    return 0;
}



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

D = int(input())
cost = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

last_held = [-1 for i in range(26)]
ans = []
for date, line in enumerate(S):
    max_score = line[0] - cost[0]*last_held[0]
    max_index = 0
    for i, score in enumerate(line):
        tmp = score - cost[i]*last_held[i]
        if max_score < tmp:
            max_index = i
            max_score = tmp
    last_held[max_index] = date
    ans.append(max_index+1)
print("\n".join(map(str, ans)))


Measured memory_bytes: 68448
#include<iostream>
#include<string>
using namespace std;
int main(){
long i,j,k;
string s[9];
for(i=0;i<9;i++)cin>>s[i];
i=j=k=0;
cout<<"R";j++;
for(;;){
     if(k==0&&i>0&&s[i-1][j]=='1'){cout<<"U";i-=2;k=3;}
else if(k==0&&     s[i][j]  =='1'){cout<<"R";j++; k=0;}
else if(k==0&&i<8&&s[i+1][j]=='1'){cout<<"D";i+=2;k=1;}
else if(k==0)                     {cout<<"L";j--; k=2;}
else if(k==1&&     s[i][j]  =='1'){cout<<"R";j++; k=0;}
else if(k==1&&i<8&&s[i+1][j]=='1'){cout<<"D";i+=2;k=1;}
else if(k==1&&j>0&&s[i][j-1]=='1'){cout<<"L";j--; k=2;}
else if(k==1)                     {cout<<"U";i-=2;k=3;}
else if(k==2&&i<8&&s[i+1][j]=='1'){cout<<"D";i+=2;k=1;}
else if(k==2&&j>0&&s[i][j-1]=='1'){cout<<"L";j--; k=2;}
else if(k==2&&i>0&&s[i-1][j]=='1'){cout<<"U";i-=2;k=3;}
else if(k==2)                     {cout<<"R";j++; k=0;}
else if(k==3&&j>0&&s[i][j-1]=='1'){cout<<"L";j--; k=2;}
else if(k==3&&i>0&&s[i-1][j]=='1'){cout<<"U";i-=2;k=3;}
else if(k==3&&     s[i][j]  =='1'){cout<<"R";j++; k=0;}
else if(k==3)                     {cout<<"D";i+=2;k=1;}
if(i==0&&j==0)break;
}
cout<<endl;
return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

void dfs(Graph &g, vi &depth, int pos, int dep)
{
    depth[pos] = dep;
    for (auto i : g[pos]) {
        if (depth[i.d] == -1) {
            dfs(g, depth, i.d, dep+1);
        }
    }
}

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

    int2(n, k);
    Graph g(n);
    for (int i = 0; i < n-1; i++) {
        int2(x, y);
        x--; y--;
        addEdge(g, x, y);
    }

    int ans = INF;
    if (k % 2) {
        for (auto i : g) {
            for (auto j : i) {
                vi depth(n, -1);
                depth[j.s] = 0; depth[j.d] = 0;
                dfs(g, depth, j.s, 0); dfs(g, depth, j.d, 0);
                int cnt = 0;
                rep(l, depth.size()) {
                    cnt += (depth[l] > k/2) ? 1 : 0;
                }
                ans = min(cnt, ans);
            }
        }
    } else {
        rep(i, n) {
            //cout << "call : " << i << endl;
            vi depth(n, -1);
            dfs(g, depth, i, 0);
            int cnt = 0;
            //rep(j, depth.size()) cout << depth[j] << " ";cout << endl;
            rep(j, depth.size()) {
                cnt += (depth[j] > k/2) ? 1 : 0;
            }
            ans = min(cnt, ans);
            //cout << cnt << endl;
        }
    }
    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;

int64_t divceil(int64_t a, int64_t b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}
int main() {
    int N, D;
    cin >> N >> D;
    cout << divceil(N, (2 * D + 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class Program {
    static void Main(string[] args){
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int p = int.Parse(input[1]);
        int pie = (int)((a * 3 + p) / 2);
        Console.WriteLine(pie);
    }
}

Measured memory_bytes: 11092
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
char B[9];
#define I(s)strtol(s.c_str(),NULL,10)
string S(int i,int L){sprintf(B,"%0*d",L,i);return B;}
int main(){
	int a,i;
	for(;scanf("%d",&a),a;printf(a?"%d\n":"NA\n",i)){
		for(i=0;a&&a!=6174;i++){
			string t=S(a,4),s;
			sort(t.begin(),t.end());
			s=t;
			reverse(s.begin(),s.end());
			a=I(s)-I(t);			
		}
	}
}

Measured memory_bytes: 1108
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	string S;
	cin >> S;
	if (S == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	int n = S.size();
	vector<int>key(26, 0);
	for (int i = 0; i < n; ++i) {
		key[S[i] - 'a']++;
	}
	if (n != 26) {
		char x;
		for (int i = 0; i < 26; ++i) {
			if (key[i] == 0) {
				x = 'a' + i;
				break;
			}
		}
		cout << S << x  << endl;
	}
	else {
		char x = 'z';
		int y;
		for (int i = 25; i >= 1; --i) {
			if (S[i] > S[i - 1]) {
				for (int j = i; j < 26; ++j) {
					if (S[i - 1] < S[j]) {
						x = min(x, S[j]);
					}
				}
				y = i - 1;
				break;
			}
		}
		cout << S.substr(0, y) << x << endl;
	}
	
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

int main(){
	
	int n;cin >> n;
	vector<int> v(n);
	
	REP(i,n)cin >> v[i];
	int ans = 0;
	REP(i,n-1){
		if(v[i] == v[i+1]){
			ans++;
			v[i+1] = 10000 + i;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    if (n==1){
        cout<<"1\n";
        return 0;
    }
    int N = 1000000;
    vector<mint> dp(N+10);
    dp[0]=1;
    dp[3]+=dp[0];
    FOR(i,1,N){
        dp[i+1]+=dp[i];
        dp[i]+=dp[i-1];
        dp[i+3]+=dp[i];
    }
    rep(i,N) dp[i+1]+=dp[i];
    mint t = (ll)(n-1)*(n-1);
    mint ans = t*dp[n-2] + mint(n-1)*dp[n-1] + 1;
    cout<<ans<<"\n";
    return 0;
}


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


vector<ll> arr(100010);
void Eratosthenes(ll n) {
	for (int i = 0; i < n; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i*i < n+10; i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < n; j++) {//jはｊ回目のiの倍数
				arr[i *(j + 2)] = 0;
			}
		}
	}
}

int main() {
	ll x;
	cin >> x;
	ll ans = 0;
	ll n = 100010;
	Eratosthenes(n);
	for (ll i = x; i < 100010; i++) {
		if (arr[i] == 1) {
			ans = i;
			break;
		}
	}
    cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    ll K, A, B;
    cin >> K >> A >> B;

    ll ans;
    // 交換は損なので叩き続ける
    if(B - A <= 2){
        ans = 1 + K;
    }else{
        // 最初A枚にするまでA-1回叩く
        ll c = A-1;
        // 何回交換できるか
        ll change = (K-c)/2;
        ll crash = K - c - change*2;
        ans = change*B - (change-1)*A + crash;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define M 100

int main()
{
  int limit,i=0,A[M];
  int v,h,j;
  scanf("%d",&limit);
  for(i=0;i<limit;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<limit;i++){
    v = A[i];
    j = i - 1;
    while(j >=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(h=0;h<limit-1;h++)printf("%d ",A[h]);
      printf("%d\n",A[limit-1]);
  }
  return 0;
}



Measured memory_bytes: 2144
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
const int x=2e5+3;
int arr[x];
vi vr;
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

	int n=RD(),k=RD(),a,cont=0;
	  fr{
	    cin>>a;
		++arr[a];}
     fr{
		if(arr[i])
			vr.push_back(arr[i]);
			}


	sort(vr.rbegin(),vr.rend());

	for(int i=0;i<k && i<vr.size();++i)
		cont+=vr[i];

	int ans=n-cont;
	cout<<ans;

}


Measured memory_bytes: 2168
n = int(input())
a = [int(i) for i in input().split()]

a2 = len(list(filter(lambda x:x%2==0, a)))
a4 = len(list(filter(lambda x:x%4==0, a)))

if n == a2:
    print("Yes")
    exit()

a2_ = a2 - a4
n = n if a2_==0 else (n-a2_+1)
if n//2 <= a4:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
N, M = map(int, input().split())
a = []
stair = [1 for i in range(N+1)]
for i in range(M):
    stair[int(input())] = 0

dp = [0 for i in range(N+2)]

dp[1] = 1

MOD = 1000000007

for i in range(2, N+2):
    if stair[i-1] == 1:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD

print(dp[N+1])


Measured memory_bytes: 51180
#include<iostream>
using namespace std;
int main()
{
    string s[10]={"","SAT","FRI","THU","WED","TUE","MON","SUN"};
    string a;
    cin>>a;
    for(int i=1;i<=7;i++)
        if(s[i]==a) cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
num_list = list(map(str,input().split()))
for i in range(n, 100005):
    j = str(i)
    flag = True
    for k in range(len(j)):
        if j[k] in num_list:
            flag = False
    if flag:
        print(i)
        exit()



Measured memory_bytes: 40812
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DLINKMAXSIZE (2000000)
#define OPELANDLEN (100)

typedef struct _dlink{
  struct _dlink *prev;
  struct _dlink *next;
  int data;
} dlink;

dlink linkbuf[DLINKMAXSIZE];

dlink *dlfst = NULL;
dlink *dllst = NULL;
unsigned int dl_next_alloc =0;


dlink *dlink_new_link_element(void)
{
  dlink *newelement = &linkbuf[dl_next_alloc];
  dl_next_alloc ++;
  return (newelement);
}


void dlink_insert(int x)
{
  dlink *data;

  data = dlink_new_link_element();
  data->data = x;
  if(dlfst != NULL)
  {
    data->next = dlfst;
    data->next->prev = data;
  }else{
    dllst = data;
    dllst->next = NULL;
  }
  dlfst = data;
  dlfst->prev = NULL;
}

void dlink_delete(int x)
{
  dlink *nowp = dlfst;

  do{
    if (nowp->data ==x)
      break;

    nowp = nowp->next;
  }while(nowp != NULL);

  if (nowp == NULL)
    return;
  if (nowp->prev == NULL)
    dlfst = nowp->next;
  else
    nowp->prev->next = nowp->next;

  if (nowp->next == NULL)
    dllst = nowp->prev;
  else
    nowp->next->prev = nowp->prev;
}

void dlink_deleteFirst(void)
{
  dlfst = dlfst->next;
  if(dlfst != NULL)
    dlfst->prev = NULL;
  else
    dllst = NULL;
}

void dlink_deleteLast(void)
{
  dllst = dllst->prev;
  if (dllst != NULL)
    dllst ->next = NULL;
  else
    dlfst =NULL;
}


int dlink_opecheck(char *ope)
{
  char *elem[2];
  int data;
  char opecpy[100];
  strcpy(opecpy, ope);

  elem[0] = strtok(opecpy, " \n");
  elem[1] = strtok(NULL, " ");

  if (strcmp(elem[0], "insert") == 0)
  {
    data = atoi(elem[1]);
    dlink_insert(data);
  }

  if (strcmp(elem[0], "delete") == 0)
  {
    data = atoi(elem[1]);
    dlink_delete(data);
  }
  if (strcmp(elem[0], "deleteFirst") == 0)
    dlink_deleteFirst();

  if (strcmp(elem[0], "deleteLast") == 0)
    dlink_deleteLast();
}

void printdata(void)
{
  dlink *nowp = dlfst;
  while (nowp != NULL){
    printf("%d%c",nowp->data, (nowp->next)?' ':'\n');
    nowp = nowp->next;
  }
}
int main(void)
{
  char ope[OPELANDLEN];
  int count, i, j;

  fgets(ope, OPELANDLEN, stdin);

  count = atoi(ope);
  for ( i = 0; i <count; i++)
  {
    fgets(ope, OPELANDLEN, stdin);
    dlink_opecheck(ope);
//    printf("%s\t\t:", strtok(ope, "\n");
//    printdata();
  }
  printdata();
}


Measured memory_bytes: 27436
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
# 条件満たせるパターンは以下の3パターンある
# 全ての数字が0, 数字が2種類あって片方が0かつ0の個数がN//3, 数字が3種類あってx^y^z==0かつN//3個ずつ存在する
if len([a for a in A if a == 0]) == N:
    print("Yes")
    exit()

if N % 3 != 0:
    print("No")
    exit()

# Nが3の倍数であることが保証された
count = Counter(A)

if len(count.keys()) > 3:
    print("No")
    exit()
elif len(count.keys()) == 3:
    numbers = list(count.keys())
    amounts = list(count.values())
    if numbers[0] ^ numbers[1] ^ numbers[2] == 0 and amounts[0] == N//3 and amounts[1] == N//3 and amounts[2] == N//3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
elif len(count.keys()) == 2:
    numbers = list(count.keys())
    numbers.sort()
    amounts = list(count.values())
    if numbers[0] == 0 and count[0] == N//3:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
print("No")

Measured memory_bytes: 14468
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, n;
  cin >> h >> n;
  
  int sum = 0;
  vector<int> a(n);
  rep (i, 0, n) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  cout << (sum >= h ?"Yes" : "No" ) << "\n";
  
}


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

const int maxn = 2002;

int n;
long long a[maxn], f[maxn][maxn][2];
long long ans;

int L(int id) {
    return (id - 1 + n) % n;
}
int R(int id) {
    return (id + 1) % n;
}

long long F(int l, int r, int x) {
    if(l == r) return x * a[r];
    long long &res = f[l][r][x];
    if(res != -1) return res;
    if(x == 0) {
        if(a[l] > a[r]) res = F(L(l), r, 1);
        else res = F(l, R(r), 1);
    }
    else {
        res = max(res, F(L(l), r, x ^ 1) + x * a[l]);
        res = max(res, F(l, R(r), x ^ 1) + x * a[r]);
    }
    return res;
}

int main() {
    ///freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i ++) cin >> a[i];
    /**
    for (int mask = 0; mask < (1 << n); mask ++) {
        long long tmp = 0;
        for (int i = 0; i < n; i ++) {
            int x = (mask >> i) & 1;
            tmp += x * a[i];
        }
        if(tmp == 3600242976) {
            for (int i = 0; i < n; i ++) {
                cout << ((mask >> i) & 1) << endl;
            }
        }
    }
    return 0;*/
    for (int i = 0; i < maxn; i ++) {
        for (int j = 0; j < maxn; j ++) {
            f[i][j][0] = f[i][j][1] = -1;
        }
    }
    ///cout << F(4, 2, 1) << endl;
    for (int i = 0; i < n; i ++) {
        ans = max(ans, a[i] + F(L(i), R(i), 0));
        ///cout << L(i) << ' ' << R(i) << ' ' << F(L(i), R(i), 0) << endl;;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 63992
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - I miss you...
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  for (int i = 0; i < n; i++) putchar('x');
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[[0]*(k+1) for _ in range(n+1)]
    dp[0][0]=1
    cum=[0]*(k+2)
    mod=10**9+7
    for i in  range(1,n+1):
        cum[0]=0 #dp[i-1]のj未満の和
        for j in range(k+1):
            cum[j+1]=cum[j]+dp[i-1][j]
        for j in range(k+1):
            dp[i][j]=(cum[j+1]-cum[max(0,j-A[i-1])])%mod
    print(dp[n][k])
if __name__=='__main__':
    main()

Measured memory_bytes: 118128
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


int main(void){
  int N,A,B,C,D;
	string S;

	cin >> N>>A>>B>>C>>D>>S;

	bool swapable = false;
  
  S = "." + S + ".";
    for (int i = B; i <= D;i++) {
      if (S[i] == '#') {
        if (S[i+1] == '#') {
          cout << "No" << endl;
          return 0;
        }
      }
      else {
        if (S[i-1] == '.' && S[i+1] == '.')
          swapable = true;
      }
    }
  
    for (int i = A; i <= C;i++) {
      if (S[i] == '#') {
        if (S[i+1] == '#') {
          cout << "No" << endl;
          return 0;
        }
      }
      else {
      }
    }
 if (C > D && !swapable)
     cout << "No" << endl;
  else
     cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 772
(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var a = p.shift().split(' ').map(Number);
    a = sortInsertion(a);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function sortInsertion(a) {
    console.log(a.join(' '));
    for (var i = 1; i < a.length; i++) {
        var v = a[i];
        var j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        console.log(a.join(' '));
    }
}

Measured memory_bytes: 7904
N, X = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

if A[0] > X:
    ans += A[0] - X
    A[0] = X
    
for i in range(N-1):
    if A[i] + A[i+1] > X:
        ans -= X - (A[i] + A[i + 1])
        A[i+1] += X - (A[i] + A[i+1])

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  string S;
  IN(S);

  vll dp(13,0);
  dp[0] = 1;

  REP(k,S.size()){
    char tmp = S[k];
    vll dp_copy = dp;
    REP(i,13) dp[i] = 0;
    if(tmp=='?'){
      REP(i,13){
        REP(shift,10){
          dp[(i*10+shift)%13] += dp_copy[i];
          dp[(i*10+shift)%13] %= MOD;
        }
      }
    }else{
      ll shift = S[k]-'0';
      REP(i,13){
        dp[(i*10+shift)%13] = dp_copy[i];
        dp[(i*10+shift)%13] %= MOD;
      }
    }
  }

  OUT(dp[5]%MOD);

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  DVector c(3,Vector(3));
  rep(i,3)rep(j,3)cin >> c[i][j];
  bool jd = false;
  rep(a1,101)rep(a2,101)rep(a3,101){
    Vector a{a1,a2,a3};
    Vector b{c[0][0]-a1,c[0][1] - a1, c[0][2] - a1};
    jd = true;
    rep(i,3)rep(j,3)if(c[i][j] != a[i] + b[j])jd = false;
    if(jd){
      cout << "Yes" << endl;
      return 0;
    }
  }
      cout << "No" << endl;
}


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

signed main(void)
{
	string s;
	long long n, ans, sum;
	cin >> s;
	n = s.size();
	ans = 0;
	rep(i, n) ans = ans * 10 + (s[i] - '0');
	for (int bit = 1; bit < (1 << n - 1); bit++)
	{
		vector<char> v;
		rep(i, n)
		{
			v.push_back(s[i]);
			if (1 << i & bit)
				v.push_back('+');
		}
		sum = 0;
		rep(i, v.size())
		{
			if (v[i] != '+')
				sum = sum * 10 + (v[i] - '0');
			else
			{
				ans += sum;
				sum = 0;
			}
		}
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define int long long
using namespace std;
using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
// ordered_set x;
// x.insert(a)
// *(x.find_by_order(k)) -> k th largest element in the set
// x.order_of_key(k) -> number of elements < k

const ll N = 3e5+100;
const ll MOD = 1e9+7;
const ll INF = 1e18;


long long binpow(long long a, long long b, long long m=MOD) {
     a %= m;
     long long res = 1;
     while (b > 0) {
         if (b & 1)
             res = res * a % m;
         a = a * a % m;
         b >>= 1;
     }
     return res;
 }


signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
    char c;
    cin>>c;
    int id = c-'a';
    string alph = "abcdefghijklmonpqrstuvwxyz";
    cout<<alph[id+1]<<endl;
}    

Measured memory_bytes: 384
#include<stdio.h>

int main(void){

    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    // printf("%d %d %d %d\n",a,b,c,d);

    int i=1;
    while (i<=100){
        c=c-b;
        if (c<=0){
            printf("Yes");
            return 0;
        }
        a=a-d;
        if (a<=0){
            printf("No");
            return 0;
        }
        i=i+1;
    }
    

    return 0;
}

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

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int h[n];
    int count=0;
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    for(int i=0;i<n;i++){
        if(h[i]>=k) count++;
    }
    printf("%d\n",count);
}

Measured memory_bytes: 640
import fractions

n = int(input())
a = list(map(int, input().split()))

l = [a[0]]
for i in range(1, n - 1):
  l.append(fractions.gcd(l[-1], a[i]))
r = [a[-1]]
for i in range(1, n - 1):
  r.append(fractions.gcd(r[-1], a[-i-1]))
for i in range(n):
  if i == 0:
    res = r[-1]
  elif i == n - 1:
    res = max(res, l[-1])
  else:
    res = max(res, fractions.gcd(l[i-1], r[-i-1]))
print(res)

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

using namespace std;

vector<int> ans;

int main(){
	int n;
	cin >> n;
	for(int dum = 0;dum < n; dum++){
		map<string,bool> mp;
		string train;
		cin >> train;
		for(int i = 1;i < train.size();i++){
			string front;
			string rfront;
			string back;
			string rback;
			
			front = train.substr(0,i);
			rfront = front;
			reverse(rfront.begin(),rfront.end());
			
			back = train.substr(i);
			rback = back;
			reverse(rback.begin(),rback.end());
			
			mp[front+back] = true;
			mp[back+front] = true;
			
			mp[rfront+back] = true;
			mp[back+rfront] = true;
			
			mp[front+rback] = true;
			mp[rback+front] = true;
			
			mp[rfront+rback] = true;
			mp[rback+rfront] = true;
		}
		
		ans.push_back(mp.size());
	}
	for(int i = 0;i < ans.size();i++)cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 3236
#include <stdio.h>

int main(){
        char n;
        int flag=0;
        for(int i=0;scanf("%c",&n)!=EOF;i++){
                switch(n){
                        case 'R':
                                if(!((i+1)%2)){
                                        puts("No");
                                        flag++;
                                }
                                break;
                        case 'L':
                                if(((i+1)%2)){
                                        puts("No");
                                        flag++;
                                }
                }
                if(flag)break;
        }
        if(!flag)puts("Yes");
        return 0;
}

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

int main(){
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    int maxa = 0;
    rep(i, n-1){
        int tmp = a.at(i+1) - a.at(i);
        if(tmp>maxa) maxa = tmp;
    }
    if(a.at(0)+k-a.at(n-1) > maxa) maxa = a.at(0)+k-a.at(n-1);
    cout << k-maxa << endl;
    return 0;
}

Measured memory_bytes: 4036
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a,b,ans=65,n;
long long Read() {
	long long x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return x*f;
}
int ar[10000000];
int main() {
	ar[0]=1;
	int n=Read(),k=Read();
	for(int i=1; i<=n; i++)
		ar[i]=min(ar[i-1]+k,ar[i-1]*2);
	cout<<ar[n];
	return 0;
}

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

using namespace std;
 
int main(){
    int n;
    cin >> n;
    for(int i = 0;7*i <= n;i++){
        for(int j = 0;7*i + 4*j <= n;j++){
                if(7*i + 4*j == n){
                    cout << "Yes" << endl;
                    return 0;
                }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int a=0, b=0;
    for(int i=0; i<3; ++i)
        s[i]=='A'?a++:b++;
    if(a==3||b==3)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int t, x, y;

int magic(int x)
{
	return ceil(2*sqrt(x+1))-2;
}

signed main()
{
	init_ios();
	cin >> t;
	while (t--) {
		cin >> x >> y;
		if (x > y)
			swap(x, y);
		int tmp = 0;
		int c = x*y-1;
		if (c/x != y) {
			int x1 = 1, x2 = x, x3;
			while (x2-x1 > 1) {
				x3 = (x1+x2)/2;
				if (c/x3 < y)
					x2 = x3;
				else
					x1 = x3;
			}
			if (c/x1 == y || c/x2 == y)
				tmp = 1;
		}
		int res = magic(c) - 1;
		if ((x+1)*(c/x) <= c)
			++res;
		cout<<res-tmp<<"\n";
	}
}

Measured memory_bytes: 256
def make_key(x, y):
    return str(x) + "k" + str(y)


inp = input()
n = int(inp)
balls = []
for i in range(n):
    inp = input()
    split_input = inp.split()
    x = int(split_input[0])
    y = int(split_input[1])
    balls.append([x, y])
possible_pq = {}
max_key = None
max_number = 0
for base_ball in balls:
    for target_ball in balls:
        diff_x = target_ball[0] - base_ball[0]
        diff_y = target_ball[1] - base_ball[1]
        if diff_x < 0:
            diff_x = diff_x * -1
            diff_y = diff_y * -1
        elif diff_x == 0 and diff_y < 0:
            diff_y = diff_y * -1
        if diff_y == 0 and diff_x == 0:
            continue
        diff = make_key(diff_x, diff_y)
        if diff in possible_pq:
            possible_pq[diff] = possible_pq[diff] + 1
        else:
            possible_pq[diff] = 1
        if max_number < possible_pq[diff]:
            max_number = possible_pq[diff]
            max_key = diff
print(n - max_number // 2)


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
    while(x->left!=NIL)x=x->left;
    return x;
}

Node treeMaximum(Node x){
    while(x->right!=NIL)x=x->right;
    return x;
}

Node treeSearch(Node u,int k){
     while(u!=NIL && k!=u->key){
         if(k<u->key)u=u->left;
         else u=u->right;
     }
     return u;
}

Node treeSuccessor(Node x){
    Node y;
    if(x->right!=NIL)return treeMinimum(x->right);
    y=x->parent;
    while(y!=NIL && x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

void treeDelete(Node z){
    Node y;
    Node x;
    if(z->left==NIL || z->right==NIL)y=z;
    else y=treeSuccessor(z);
    if(y->left!=NIL)x=y->left;
    else x=y->right;
    if(x!=NIL)x->parent=y->parent;
    if(y->parent==NIL)root=x;
    else if(y==y->parent->left)y->parent->left=x;
    else y->parent->right=x;
    
    if(y!=z)z->key=y->key;
}
        
void insert(int k){
    Node y=NIL;
    Node x=root;
    Node z;
    
    z=malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key)x=x->left;
        else x=x->right;
    }
    z->parent=y;
    
    if(y==NIL)root=z;
    else if(z->key<y->key)y->left=z;
    else y->right=z;
}

void inorder(Node u){
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node u){
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'f' ){
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        } else if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if ( com[0] == 'd' ){
            scanf("%d", &x);
            treeDelete(treeSearch(root, x));
        }
    }
    
    return 0;
}



Measured memory_bytes: 20456
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		for (int i = 0; i < M; i++) {
			N -= Integer.parseInt(sc.next());
		}
		if (N < 0) {
			System.out.println(-1);
		} else {
			System.out.println(N);
		}
	}
}


Measured memory_bytes: 34892
N,M = map(int,input().split())
A = [0] * N
B = [0] * M

ans = "No"

for i in range(N):
    A[i] = list(input())

for j in range(M):
    B[j] = list(input())

for k in range(N-M+1):
    for l in range(N-M+1):
        det = 0
        for x in range(M):
            for y in range(M):
                if A[k+x][l+y] != B[x][y]:
                    det = -1
        if det == 0:
            ans = "Yes"

print(ans)



Measured memory_bytes: 3064