akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Node{
	Integer parent = null;
	public Node(int v) {
		this.value = v;
	}
	int value = 0;
	Node left = null;
	Node right = null;
} 

public class Main {
	
	private static Scanner src;
	public static Node root;
	public static void main(String[] args) {
		src = new Scanner(System.in);
		int n = src.nextInt();
		for(int i = 0; i < n; i++) {
			String next = src.next();
			if(next.equals("insert")) {
				insert(root, src.nextInt());
			}
			else if(next.equals("print")) {
				inorder(root); System.out.println();
				preorder(root); System.out.println();
			}
		}

	}
	private static void insert(Node n, int v) {
		if(n == null) {n = new Node(v); if(root == null) {root = n;} return;}
		if(v > n.value) { if(n.right == null ) { n.right = new Node(v);} else {insert(n.right, v);} }
		else { if(n.left == null ) { n.left = new Node(v);} else {insert(n.left, v);} }
		return;
	}

	private static void postorder(Node n) {
		if(n.left != null) postorder(n.left);
		if(n.right != null) postorder(n.right);
		System.out.print(" " + n.value);
	}
	private static void inorder(Node n) {
		if(n.left != null) inorder(n.left);
		System.out.print(" " + n.value);
		if(n.right != null) inorder(n.right);
	}
	private static void preorder(Node n) {
		System.out.print(" " + n.value);
		if(n.left != null) preorder(n.left);
		if(n.right != null) preorder(n.right);
	}
}



Measured memory_bytes: 216820
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        string s[1001];
        for(int i = 0; i < n; i++){
            cin >> s[i];
        }
        stack<pair<string, int> > st;
        st.push(make_pair(s[0], 0));
        for(int i = 1; i < n; i++){
            int dotnum = 0;
            int hukasa = (st.top()).second;
            while(s[i][dotnum] == '.'){
                s[i][dotnum] = ' ';
                dotnum++;
            }
            if(dotnum >= hukasa){
                s[i][dotnum - 1] = '+';
                st.push(make_pair(s[i], dotnum));
            } else {
                vector<pair<string, int> > popstr;
                while((st.top()).second > dotnum){
                    popstr.push_back(st.top());
                    st.pop();
                }
                for(int i = popstr.size() - 1; i >= 0; i--){
                    (popstr[i].first)[dotnum - 1] = '|';
                    st.push(popstr[i]);
                }
                s[i][dotnum - 1] = '+';
                st.push(make_pair(s[i], dotnum));
            }
        }
        vector<string> ans;
        while(!st.empty()){
            ans.push_back((st.top()).first);
            st.pop();
        }
        reverse(ans.begin(), ans.end());
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2588
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 105,K = 2e5+5,MOD = 1e9+7;
int dp[N][K];
int a[N];

signed main(){
	IOS
	int n,k;	cin >> n >> k;
	rep(i,n)	cin >> a[i];
	dp[0][k] = 1;
	rep(i,n+1){
		for(int j = k;i != 0 && j >= 0;j--){
			dp[i][j] = (dp[i-1][j] - dp[i-1][j + a[i-1]+ 1] + MOD) % MOD;
			if(j != k)	dp[i][j] = (dp[i][j] + dp[i][j+1]) % MOD;
		}
	}
	/*
	rep(i,n+1){
		rep(j,k+1)	cout << dp[i][j] << ' ';
		cout << endl;
	}
	*/
	cout << dp[n][0] << endl;
}


Measured memory_bytes: 156416
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        int Bills = scn.nextInt();
        int Sum = scn.nextInt();

        if(Check(Sum, Bills) == 1){
            System.out.println("-1 -1 -1");
        }
    }

    public static int Check(int Y, int N){

        for(int x=0; x<=N; x++){
            for(int y=0; y<=N-x; y++){
                int z = N-x-y;
                if(x*10000 + y*5000 + z*1000 == Y){
                    System.out.println(x + " " + " " + y + " " +z);
                    return 0;
                }
            }
        }
        return 1;
    }
}

Measured memory_bytes: 21844
A,B=[int(x) for x in input().split()]

if A==B:
	print(A)
	exit()

if A%2==1 and B%2==1:
	even=(B-A)//2
else:
	even=(B-A)//2+1

if even%2==0:	
	if A%2==1 and B%2==0:
		print(A^B^1)
	elif A%2==1 and B%2==1:
		print(A)
	elif A%2==0 and B%2==1:
		print(0)
	elif A%2==0 and B%2==0:
		print(B^1)
else:
	if A%2==1 and B%2==0:
		print(A^B)
	elif A%2==1 and B%2==1:
		print(A^1)
	elif A%2==0 and B%2==1:
		print(1)
	elif A%2==0 and B%2==0:
		print(B)

Measured memory_bytes: 62028
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main() {
 
    int a,b,c,d,e,f;
    
    cin >> a >> b ;
    c = a*b%2;
    
    if(c == 0){
    cout << "Even" << endl;
    }else{
    cout << "Odd" << endl;
    }
	return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    printf("%c%c%c\n", toupper(a[0]), toupper(b[0]), 
                        toupper(c[0]) );

    return 0;
}

Measured memory_bytes: 256
#写経
#https://atcoder.jp/contests/aising2020/submissions/15190580
import math
MOD = 10**9+7

def resolve():
    T = int(input())
    for _ in range(T):
        N = int(input())
        r = 0
        for i in range((N-5)%2, 12, 2):
            r += math.comb(11,i) % MOD * math.comb((N-i+25)//2, 15) % MOD
        print(r%MOD)
    return
resolve()

Measured memory_bytes: 9116
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int a = N % 10, b = N / 10;
        if (a == 9 || b == 9) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23508
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, d[100] , a = 0, x=0;
	int i=0,j = 0;

	cin >> n;
	for(i = 0; i < n; ++i) {
		cin >> d[i];
	}
	//x = n * (n - 1) / 2;
	for(j = 0; j < n-1; ++j) {
		for(i = j+1;i<n; ++i) {
			a += d[j] * d[i];
		}
	}
	cout << a<<endl;
	return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) a/__gcd(a,b)*b
typedef long long ll;
typedef pair<int,int> Pii;

bool prime(ll n){
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0) return false;
    }
    return true;
}

int main(){
    double n;cin>>n;
    int k=(n+1)/2;
    cout<<setprecision(7)<<k/n;
    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << H * W - h * W - w * H + h * w << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<queue>
#include<string>
using namespace std;

int main(){
  int i,count=1,n,q,time_input,minus=0;
  struct data{
    string name;
    int time;
  };
  string s;
  queue<data> process;
  data temp;
  cin >> n >> q;
  for(i=0;i<n;i++){
    cin >> s;
    cin >> time_input;
    process.push({s,time_input});
  }

  while(process.size()!=0){
    temp=process.front();
    process.pop();
    temp.time-=q;
    if(temp.time > 0){
      process.push(temp);
    }else{
      minus += temp.time;
      cout << temp.name <<" "<< (q*count)+minus << endl;
    }
    count++;
  }
    
  //output=process.back();
  //cout << output.name << output.time << endl;
  return 0;
}



Measured memory_bytes: 6248
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

ll dp[9][9];

vector<int> num2digs(int n) {
    vector<int> digs;
    while (n) {
        digs.push_back(n%10);
        n = n / 10;
    }
    return digs;
}

int main()
{
    int N;
    cin >> N;
    rep(i, 9) rep(j, 9) {
        dp[i][j] = 0;
    }
    repSE(i,1,N+1) {
        if (i % 10 == 0) continue;
        vector<int> digs = num2digs(i);
        dp[digs.back()-1][digs[0]-1] ++;
    }
    ll ans = 0;
    rep(i,9) rep(j,9) {
        ans += dp[i][j] * dp[j][i];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
int n;
int arr[mxN];
int ww = 0;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    string s;
    cin>>s;
    owo(i, 0, n) {
        arr[i] = s[i]=='W';
        ww+=arr[i];
    }
    int ans = 0;
    uwu(i, n, 0) {
        if(ww==0)break;
        if(arr[i]==0)ans++;
        ww--;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int left = 0, right = 1e9+1;
    while(right-left > 1){
        int tk = k;
        int mid = (right+left)/2;
        for(int i = 0; i < n; i++){
            if(a[i] > mid) tk -= a[i]/mid;
        }
        //cout << mid << " " << tk << endl;
        if(tk >= 0) right = mid;
        else left = mid;
    }

    cout << right << endl;

    return 0;
}

Measured memory_bytes: 3992
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) range(i,0,b)

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, int cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<int> Array;
typedef vector<Array> Matrix;

int const inf = 1e9;

template<class Capacity = int> struct FordFulkerson {
    typedef vector<vector<Capacity>> Matrix;
    size_t n; int t;
    Matrix cap, flow;
    vector<bool> vis;
    Capacity res;
    vector<vector<int>> g;
    FordFulkerson(const int s, const int t, const Graph &graph) :
        n(graph.size()), t(t), cap(n, Array(n)), flow(n, Array(n)), res(0), g(n) {
        rep(i,n)rep(j,graph[i].size()){
            int u = graph[i][j].src, v = graph[i][j].dst;
            cap[u][v] = flow[u][v] = graph[i][j].cap;
        }
        rep(i,n)rep(j,n) if(cap[i][j]) g[i].emplace_back(j), g[j].emplace_back(i);
        Capacity f = -1;
        while(f) vis.assign(n, false), res += (f = augment(s,inf));
        rep(i,n)rep(j,n) flow[i][j] -= cap[i][j];
    }
    Capacity augment(const int u, const Capacity lim){
        vis[u] = true;
        if(u == t) return lim;
        Capacity f;
        for(const int &v : g[u]){
            if(vis[v] || cap[u][v] == 0) continue;
            f = augment(v, min(lim, cap[u][v])), cap[u][v] -= f, cap[v][u] += f;
            if(f) return f;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    cout << FordFulkerson<int>(0,N-1,g).res << endl;
}

Measured memory_bytes: 1352
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
      	int _max = b / a;
      	int max = _max;
      	if(max > c){
        	max = c; 
        }
		// 出力
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
        int n,k,i;
        cin>>n>>k;
        ll *h=(ll*)malloc(sizeof(ll)*n);
        rep(i,n){
            cin>>h[i];
        }
    if(n>k){
        std::sort(h,h+n,std::greater<ll>());
        ll sum=(ll)std::accumulate(h+k,h+n,0LL);
        cout<<sum;
        return 0;
    }else{
        cout<<0;
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n;
map <int, vector <int>> mp;


int main() {
    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i) {
        int x, y;
        scanf("%d %d", &x, &y);
        mp[y].emplace_back(x);
    }

    int ans = 0;


    int left_x = -1, left_y = -1;
    int last = -1;

    for (auto &it : mp) {
      //  cout << it.first << ans << '\n';
        vector <int> &v = it.second;
        sort(v.begin(), v.end());
        for (int i = 0 ; i + 1 < int(v.size()) ; ++ i) {
            ans = max(ans, v[i + 1] - v[i]);
        }

        if (left_x == -1 && left_y == -1) {
            left_x = v[0], left_y = v.back();
            last = it.first;
        } else {
            int dif = it.first - last;
            last = it.first;
            left_x -= dif, left_y += dif;

            for (int i = 0 ; i < v.size() ; ++ i) {
                ans = max(ans, v[i] - left_x);
                ans = max(ans, left_y - v[i]);
            }
            left_x = min(left_x, v[0]);
            left_y = max(left_y, v.back());
        }
    }
    cout << ans << '\n';
}


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

const int maxn=2e5+10;

int n,m,cnt;
int F[maxn];
int cost[maxn];
std::vector<int> right[maxn];

int minv[maxn<<2];
int get(int r,int L,int R,int Lu,int Ru){
	if (L>Ru||R<Lu)return 0x3F3F3F3F;
	if (L>=Lu&&R<=Ru)return minv[r];
	int Mid=(L+R)>>1;
	return std::min(get(r<<1,L,Mid,Lu,Ru),get(r<<1|1,Mid+1,R,Lu,Ru));
}

void insert(int r,int L,int R,int p,int v){
	if (L==R)return minv[r]=v,void();
	int Mid=(L+R)>>1;
	if (p<=Mid)insert(r<<1,L,Mid,p,v);
	else insert(r<<1|1,Mid+1,R,p,v);
	minv[r]=std::min(minv[r<<1],minv[r<<1|1]);
}

int main (){
#ifdef LOCAL
	freopen("input","r",stdin);
#endif
	std::cin >> n;
	for (int i=1,x;i<=n;i++){
		std::cin >> x;
		cnt+=(x==0);
		cost[i]=x>0?1:-1;
	}
	std::cin >> m;
	for (int i=1,L,R;i<=m;i++){
		std::cin >> L >> R;
		right[L].push_back(R);
	}
	memset(F,0x3F,sizeof(F));
	memset(minv,0x3F,sizeof(minv));
	F[0]=0;
	for (int i=1,tmp;i<=n;i++){
		for (int R:right[i]){
			tmp=std::min(F[i-1],get(1,1,n,std::max(i-1,1),R));
			if (tmp<F[R])
				insert(1,1,n,R,F[R]=tmp);
		}
		F[i]=std::min(F[i],F[i-1]+cost[i]);
	}
	std::cout << F[n]+cnt << '\n';
	return 0;
}



Measured memory_bytes: 13568
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
r=any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if r else 'No')

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int ans = k;
    for(int i=1; i<n; ++i)
        ans *= k - 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }
  public void run() {
    List<Color> initialStones = new ProblemReader().read();
    int minOperationCount = new Solver().getMinOperationCount(initialStones);
    System.out.println(minOperationCount);
  }
}
class ProblemReader {
  public List<Color> read() {
    Scanner stdinScanner = new Scanner(System.in);
    int stoneCount = stdinScanner.nextInt();
    String stoneMarks = stdinScanner.next();
    List<Color> stones = new ArrayList<>();
    for (int idx = 0; idx < stoneCount; idx++) {
      char stoneMark = stoneMarks.charAt(idx);
      if (stoneMark == 'R') {
        stones.add(Color.RED);
      } else {
        stones.add(Color.WHITE);
      }
    }
    return stones;
  }
}
class Solver {
  public int getMinOperationCount(List<Color> initialStones) {
    int whiteOnLeft = 0;
    int redOnRight = 0;
    // count red stone in initialStones
    for (Color stone : initialStones) {
      if (stone == Color.RED) {
        redOnRight++;
      }
    }
    
    int minOperationCount = initialStones.size();
    for (int separator = 0; separator <= initialStones.size(); separator++) {
      int operationCount = Math.max(whiteOnLeft, redOnRight);
      if (minOperationCount > operationCount) {
        minOperationCount = operationCount;
      }
      if (separator < initialStones.size()) {
        if (initialStones.get(separator) == Color.RED) {
          redOnRight--;
        } else {
          whiteOnLeft++;
        }
      } else {
        // already we have minimum value.
        // nothing to do.
      }
    }
    return minOperationCount;
  }
}
enum Color {
  RED,
  WHITE,
  ;
}


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

class sum_class{
	vector<ll> v;
public:
	sum_class(const vector<ll>& vv){
		v.resize(vv.size() + 1, 0ll);
		partial_sum(begin(vv), end(vv), begin(v) + 1); }
	ll operator()(const ll x, const ll y){
		return v[y+1] - v[x]; } };

int main(){
	ll n, k;
	cin >> n >> k;

	vector<ll> v(n);
	for(auto& x : v) cin >> x;

	vector<ll> pv(n);
	transform(begin(v), end(v), begin(pv), [](const ll x){ return max(x, 0ll); });

	sum_class sv(v), spv(pv);

	ll rez = accumulate(begin(v), end(v), 0ll);

	for(ll i = 0ll, j = k-1; j < n; ++i, ++j){
		rez = max(rez, spv(0ll, i-1) + max(sv(i, j), 0ll) + spv(j+1, n-1)); }
	
	cout << rez << endl;

	return 0; }


Measured memory_bytes: 3456
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll N;
	scanf("%lld",&N);

	ll ans = HUGE_NUM;

	for(ll i = 1; i*i <= N; i++){
		if(N%i == 0){

			ans = min(ans,i+N/i-2);
		}
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
M1,D1 = gets.chomp.split.map(&:to_i)
M2,D2 = gets.chomp.split.map(&:to_i)

ret = 0

if M1 == 12
  if D1 == 31
    ret = 1
  end
end

if M1 + 1 == M2 
  ret = 1
end

puts ret

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

int main(){
    string s;
    cin>>s;
    long long k;
    cin>>k;
    long long n=s.size();
    if(n==1){
        cout<<k/2<<endl;
        return 0;
    }
    for (int i = 0; i < n-1; ++i) {
        if(s[i]!=s[i+1])break;
        if(i==n-2){
            cout<<(n*k)/2<<endl;
            return 0;
        }
    }
    long long uni=0;
    int cl=0,ind=0;
    while(ind+1<n){
        cl=1;
        while(s[ind]==s[ind+1]){
            ++cl;++ind;
        }
        ++ind;
        uni+=cl/2;
    }
    int fcl=1;
    ind=0;
    while(ind+1<n&&s[ind]==s[ind+1]){
        ++fcl;++ind;
    }
    long long ans=0;
    if(s.front()==s.back()&&(cl%2==1&&fcl%2==1))ans+=k-1;
    ans+=uni*k;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*input
176527 15
1 81279
2 22308
2 133061
1 80744
2 44603
1 170938
2 139754
2 15220
1 172794
1 159290
2 156968
1 56426
2 77429
1 97459
2 71282
*/

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

// AntBook p155
// Segment Tree
const int INF = 1001001001;
struct SegmentTree {
  int n;
  vector<int> dat;
  // n_: num of elements
  SegmentTree(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2*n-1, INF);
  }
  // Sets k-th element at a
  void set(int k, int a) {
    k += n-1;
    dat[k] = a;
    while (k > 0) {
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }
  // Returns k-th element
  int get(int k) {
    return dat[k+n-1];
  }
  // Returns min[a, b)
  // Use like query(a, b)
  int query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if  (r < 0) r = n;
    // When intersection of [a, b) and [l, r) is empty
    if (r <= a || b <= l) return INF;
    // When [a, b) includes [l, r)
    if (a <= l && r <= b) return dat[k];
    // Return min of 2 children
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    return min(vl, vr);
  } 
};

int main() {
  int n, q;
  cin >> n >> q;

  SegmentTree tx(n+1), ty(n+1);
  tx.set(n, n);
  ty.set(n, n);

  ll ans = ll(n-2)*(n-2);
  rep(qi, q) {
    int typ, i;
    cin >> typ >> i;
    if (typ == 1) {
      int r = tx.query(i, n+1);
      ans -= r-2;
      ty.set(r, min(ty.get(r), i));
    }
    else {
      int r = ty.query(i, n+1);
      ans -= r-2;
      tx.set(r, min(tx.get(r), i));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7472
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        PowerfulDiscountTickets solver = new PowerfulDiscountTickets();
        solver.solve(1, in, out);
        out.close();
    }

    static class PowerfulDiscountTickets {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            PriorityQueue<Integer> pq = new PriorityQueue<>(n, (o1, o2) -> Integer.compare(o2, o1));
            for (int i = 0; i < n; i++) {
                pq.add(in.nextInt());
            }
            while (m > 0) {
                Integer max = pq.poll();
                max /= 2;
                m--;
                pq.add(max);
            }
            long result = 0;
            Iterator<Integer> it = pq.iterator();
            while (it.hasNext()) {
                result += it.next();
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 61312
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cstring>
#include <functional>
#include <iostream>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <array>
#include <complex>

#define endl '\n'

using namespace std;

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

    int a, b;
    cin >> a >> b;

    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3200
# 2019/12/29

from bisect import bisect_left

x=int(input())

def sieve(n):
    end=int(pow(n,0.5))+1
    is_prime=[True]*(n+1)
    is_prime[0]=False
    is_prime[1]=False

    for i in range(2,end+1):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
        #for j in range(i*(i|0),n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]

primes=sieve(10**5+10)
ans=bisect_left(primes,x)
print(primes[ans])

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

ll a,b,k,x;

int main()
{
	cin>>a>>b>>k;
	x=min(a,k);
	a-=x;
	k-=x;
	x=min(b,k);
	b-=x;
	k-=x;
	cout<<a<<" "<<b<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    vi C(N);
    rep(i, N) cin >> C[i];
    GSORT(C);

    int res = C[0];
    int cnt = 1;
    int seq = 1;
    while(cnt<N-1) {
        res += C[seq];
        cnt++;
        if(cnt==N-1) break;
        res += C[seq];
        seq++;
        cnt++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4828
fn main() {
    let s = read::<String>();
    let mut nums: Vec<i32> = Vec::new();
    for c in s.chars() {
        nums.push(c as i32 - 48);
    }
    let n = nums.len();

    for bit in 0..(1 << n - 1) {
        let mut ret = nums[0];
        let mut ops: Vec<&str> = Vec::new();
        for i in 0..n-1 {
            if (bit & (1 << i)) != 0 {
                ret += nums[i + 1];
                ops.push("+");
            } else {
                ret -= nums[i + 1];
                ops.push("-");
            }
        }

        if ret == 7 {
            println!("{}{}{}{}{}{}{}=7", nums[0], ops[0], nums[1], ops[1], nums[2], ops[2], nums[3]);
            return
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= n; j += i) {
      sum ^= b[j]; //奇偶判定
    }
    b[i] = sum^a[i];//ballの合計とa[i]が異なれば1
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define maxn 100010
using namespace std;
int deg[maxn], size[maxn], head[maxn], nxt[maxn * 2], a[maxn * 2], edge, t1, t2;
int flag, visit[maxn];
void create(int u, int v)
{
	edge++; a[edge] = v; nxt[edge] = head[u]; head[u] = edge;
}
void dfs(int u, int fa)
{
	visit[u] = 1;
	for (int i = head[u]; i; i = nxt[i])
	{
		int v = a[i];
		if (v == fa || v == t1) continue;
		if (v == t2) {flag = 1; return;}
		if (visit[v] == 0)
		{
			dfs(v, u);
			if (flag) return;
		}
	}
}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		deg[u]++; deg[v]++;
		create(u, v); create(v, u);
	}
	for (int i = 1; i <= n; i++)
		if (deg[i] % 2) {puts("No"); return 0;}
	for (int i = 1; i <= n; i++)
		if (deg[i] >= 6) {puts("Yes"); return 0;}
	for (int i = 1; i <= n; i++)
		if (deg[i] == 4)
		{
			if (t1 == 0) t1 = i;
			else t2 = i;
		}
	if (t2 == 0) {puts("No"); return 0;}
	dfs(t2, 0);
	if (flag) puts("Yes");
	else puts("No");
	return 0;
}

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

int main() {
    ll A, B, N; cin >> A >> B >> N;
    ll ans = 0;
    for (ll i = 1; i <= A; i++) {
        ll x = (i * B) / A;
        if (x >= B) continue;
        if ((x <= N && (A * x) / B == i) || ((x + 1) <= N && (A * (x + 1)) / B == i)) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
N = int(input())
A = [int(i) for i in input().split(" ")]
B = [int(i) for i in input().split(" ")]
C = [int(i) for i in input().split(" ")]
satisfaction = 0
for i in range(N):
    a = A[i] - 1
    satisfaction += B[a]
    if ((i > 0) and (A[i - 1] == a)):
        satisfaction += C[a - 1]
print(satisfaction)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 int main(){
 ll n,k ; cin>>n>>k ;
 vector<ll> A(n) ;
 rep(i,n){
   cin>>A[i] ;
   A[i]-- ;
   A[i]= A[i]%k ;
 }
 vector<ll> sum(n+1) ;
 sum[0]=0 ;
 rep(i,n){
   sum[i+1]= (sum[i]+ A[i])%k ;
 }
 map<ll,vector<ll>> mp ;
 rep(i,n+1){
  mp[sum[i]].pb(i) ;
 }
 ll bns=0 ;
 for(auto u : mp){
   auto v= u.se ;
   ll si = v.size() ;
   if(si==1) continue ;
   ll ans=0 ;
   ll a=0 ;ll b =1 ;
   while(a<=si-2&&b<=si-1){
     if(a==b) b++ ;
     
     if(v[b]-v[a]<=k-1){
       if(b==si-1){
         ans++ ;
         ans += (b-a)*(b-a-1)/2 ;
         break ;
       }
       else{
         ans++ ;
         b++ ;
       }
     
     }
    
    else{
      ans += max(b-a-2,0ll) ;
      a++ ;
    }
   //cout<<ans<<endl ;
   }
 
  bns+= ans ;
 }
 cout<<bns<<endl ;
   return 0 ;
 }



Measured memory_bytes: 28292
def nyu():
    S =  list(map(str,input()))
    return S


def kansu(LS):
    ans = []
    ans_str =""

    for ls in range(len(LS)):
        
        if LS[ls] == "0":
            ans.append("0")
        elif LS[ls] == "1":
            ans.append("1")
        else:
            if len(ans) > 0 :
                ans.pop(len(ans)-1)
    
    for i in range(len(ans)):
        ans_str += ans[i]
    


    print(ans_str)




S = nyu()
kansu(S)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<pair<int, int>>>;

void dfs(int v, int prev, const graph& G, vector<int>& c) {
	for (auto e : G[v]) if (e.first != prev) {
		c[e.first] = c[v] ^ e.second;
		dfs(e.first, v, G, c);
	}
}

int main()
{
	int N;
	cin >> N;
	graph G(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w; --u, --v;
		G[u].emplace_back(v, w & 1);
		G[v].emplace_back(u, w & 1);
	}
	vector<int> c(N);
	dfs(0, -1, G, c);
	for (int i = 0; i < N; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int A, B;
    cin >> A >> B;
    if (B % A == 0)
        cout << B + A;
    else
        cout << B - A;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
l=[]
r=[]
for i in range(M):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
a=max(l)
b=min(r)
x=list(range(a,b+1))
print(len(x))

Measured memory_bytes: 86232
//file_name:ABC48_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    int flag = 0;
    flag += s.size()%2;
    if(s[0]!=s[s.size()-1]){
        flag++;
    }

    if(flag%2==0){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

    return 0;
}



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

int main(){
	long long int sum = 0;
	int n;
	cin >> n;
	for(int i = 1;i<=n;i++){
		if(i%3==0 || i%5 == 0) continue;
		else sum += i;
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 3764
// #pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 150010;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int n;

int a[maxN];
char b[maxN];

int main()
{
    //scanf("%d", &n);
 	scanf("%s",b+1);
 	if(b[6]=='1' || b[7]>'4')
 	{
 		puts("TBD");	
	}
	else
	{
		puts("Heisei");
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

ll C[51][51];

void comb(int n) {
    REP(i, n+1) REP(j, i+1) if(!j || j==i) {
        C[i][j] = 1L;
    } else {
        C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
}

signed main(){ INIT;
    VAR(int, n, a, b);
    VEC(ll, v, n);

    comb(n);
    sort(ALL(v), greater<ll>());

    double maxAve = 0;
    REP(i, a){
        maxAve += v[i];
    }
    maxAve /= a;

    int l = 0, r = 0;
    REP(i, n) {
        if(v[i] == v[a-1]){ 
            l++;
            if(i < a) r++;
        }
    }
    ll cnt = 0L;
    if(r == a) {
        FOR(i, a, b+1) cnt += C[l][i];
    } else {
        cnt += C[l][r];
    }

    cout << fixed << maxAve << endl;
    OUTL(cnt);
RET;}


Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;cin>>n>>k;
    string s;cin>>s;
    for(int i=0;i<n;i++)
    {
        if(i==k-1)
        {
            char c=s[i];
            char d=tolower(c);
            s[i]=d;
        }
    }
    cout<<s<<"\n";

    return 0;
}



Measured memory_bytes: 256
import Data.List
import Data.Char

arrow i n =
  replicate i ' ' ++ replicate (n-i) '^'

f a b s =
  let i = (a*10) `div` b
      o = (a*10) `mod` b
  in
    if o == 0
    then (i,o):s
    else if elem (i,o) s
         then (i,o):s
         else f o b ((i,o):s)

ans (a:b:_) =
  let l@(h:t) = f a b []
  in
    if (snd h) == 0
    then
      map (intToDigit . fst) $ reverse l
    else
      let r = reverse t
          Just i = elemIndex h r
          n = length r
      in
        map (intToDigit . fst) r ++ "\n" ++ (arrow i n)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c
      o = map ans i
  mapM_ putStrLn o

Measured memory_bytes: 4120
from functools import reduce
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
if n == 2:
  print(max(a))
else:
  p = gcd_list(a[:3])
  q = max([gcd(a[0], a[1]), gcd(a[0], a[2]), gcd(a[1], a[2])])
  for i in range(3, n):
    q = max([p, gcd(q, a[i])])
    p = gcd(p, a[i])
    
  print(q)
  


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

void bubbleSort(vector<int>& vec, int array_size) {
  int temp;

  for (int i = 0; i < (array_size - 1); i++) {
    for (int j = (array_size - 1); j > i; j--) {
      if (vec[j-1] > vec[j]) {
        temp = vec[j-1];
        vec[j-1] = vec[j];
        vec[j] = temp;
      }
    }
  }
}


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

  vector<int> vec(N);
  for (int i=0; i<N;i++) {
    cin >> vec.at(i);
  }
  
  bubbleSort(vec, N);

  sum = vec.at(0);
  for (int j=1; j < N; j++) {
    sum += vec.at(j);
    sum /= 2.0;
  }
  
  
  cout << sum << endl;
}


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

const double pi = acos(-1);
#define INF 999999999
int main ()
{
    long long all=0,cnt=0,n,max=-INF,min=INF;
    vector<int>h(10000);
    vector<int>w(10000);

    for(int i=0;i<10000;i++){
        cin >> h.at(i) >> w.at(i);
        
        if(h.at(i)==0 && w.at(i)==0) break;
        cnt++;
    }

    for(int i=0;i<cnt;i++){
        for(int j=0;j<h.at(i);j++){
            for(int k=0;k<w.at(i);k++){
                if(j==0 || j==h.at(i)-1) cout << '#';
                else if(k==0 || k==w.at(i)-1) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }

        cout << endl;
    }

    

    
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    int n;
    cin >> n;
    string s;
    string t;
    cin >> s >> t;
    int idx = n;
    rep(i,0,n) {
        if(s.substr(i) == t.substr(0,n-i)) {
            idx = i;
            break;
        }
    }
    int ret = n + idx;
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
ln = len(s)
alph = [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M",
    "N",
    "O",
    "P",
    "Q",
    "R",
    "S",
    "T",
    "U",
    "V",
    "W",
    "X",
    "Y",
    "Z",
]
 
ans = []
for i in range(ln):
    ind = alph.index(s[i])
    newind = ind + n
    if newind > 25:
        newind = newind - 26
    ans.append(alph[newind])
 
print("".join(ans))

Measured memory_bytes: 3188
#!/usr/bin/env python3

INF = 10 ** 10


def solve(x, n, ps):
    qs = sorted(set(range(0, 103)) - set(ps))
    delta = INF
    val = INF
    for q in qs:
        new_delta = abs(q - x)
        if new_delta < delta:
            delta = new_delta
            val = q
    return val


def main():
    x, n = (int(z) for z in input().split())
    ps = [int(p) for p in input().split()]
    res = solve(x, n, ps)
    print(res)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define INF 1099511627776
#define LL long long
#define WY()(putchar('Y'),putchar('e'),putchar('s'),putchar('\n'))
#define WN()(putchar('N'),putchar('o'),putchar('\n'))
#define Max(x,y)(x>y? x:y)
#define Min(x,y)(x<y? x:y)
#define ek()(putchar('\n'))
#define sk()(putchar(' '))
#define MAX 200005
using namespace std;
inline int Read(){
	int X=0,flag=1;char ch=0;
	while (ch<'0'||ch>'9'){
		if (ch=='-') flag=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9')
	  X=(X<<1)+(X<<3)+ch-48,ch=getchar();
	return X*flag;
}
inline void Write(LL x){
	if (x<0) x=-x,putchar('-');
	if (x>9) Write(x/10);
	putchar(x%10+48);
}
int n,q,a,b; 
int x[MAX];
LL sum[MAX];
LL DP[MAX];
struct Node{
	LL Seg[MAX<<2];
	inline void build(int l,int r,int p){
		Seg[p]=INF;
		if (l==r) return;
		int mid=(l+r)>>1;
		build(l,mid,p<<1);build(mid+1,r,p<<1|1);
	}
	inline void update(int l,int r,int p,int pos,LL num){
		if (l==r){
			Seg[p]=min(Seg[p],num);
			return;
		}
		int mid=(l+r)>>1;
		if (pos<=mid) update(l,mid,p<<1,pos,num);
		else update(mid+1,r,p<<1|1,pos,num);
		Seg[p]=min(Seg[p<<1],Seg[p<<1|1]);
	}
	inline LL query(int l,int r,int p,int Aiml,int Aimr){
		if (Aiml<=l&&r<=Aimr) return Seg[p];
		int mid=(l+r)>>1;
		LL ans=INF;
		if (Aiml<=mid) ans=min(ans,query(l,mid,p<<1,Aiml,Aimr));
		if (Aimr>mid) ans=min(ans,query(mid+1,r,p<<1|1,Aiml,Aimr));
		return ans;
	}
} to,tw;
inline void do_DP(){
	to.update(1,n,1,x[0],DP[1]-x[0]-sum[1]);
	tw.update(1,n,1,x[0],DP[1]+x[0]-sum[1]);
	for (int i=2;i<=q;i++){
		DP[i]=min(to.query(1,n,1,1,x[i])+x[i],tw.query(1,n,1,x[i],n)-x[i])+sum[i-1];
		to.update(1,n,1,x[i-1],DP[i]-x[i-1]-sum[i]);
		tw.update(1,n,1,x[i-1],DP[i]+x[i-1]-sum[i]);
	}
}
int main(){
	n=Read(),q=Read(),a=Read(),b=Read();
	for (int i=1;i<=q;i++) x[i]=Read();
	for (int i=2;i<=q;i++) sum[i]=sum[i-1]+abs(x[i]-x[i-1]);
	DP[1]=abs(a-x[1]);x[0]=b;
	to.build(1,n,1);tw.build(1,n,1);
	do_DP();
	LL ans=INF;
	for (int i=1;i<=q;i++) ans=min(ans,DP[i]+sum[q]-sum[i]);
	//ans=min(ans,sum[q]+DP[1]);
	//ans=min(ans,DP[q]);
	DP[1]=abs(b-x[1]);x[0]=a;
	to.build(1,n,1);tw.build(1,n,1);
	do_DP();
	for (int i=1;i<=q;i++) ans=min(ans,DP[i]+sum[q]-sum[i]);
	//ans=min(ans,sum[q]+DP[1]);
	//ans=min(ans,DP[q]);
	Write(ans);ek();
    return 0;
}

Measured memory_bytes: 16640