akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

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

  int ans;
  vector<int> copy(N);
  copy = A;
  sort(copy.begin(), copy.end());
  int maximum = copy[N - 1];
  int second = copy[N - 2];

  for (int i = 0; i < N; i++) {
    if (A[i] == maximum) cout << second << endl;
    else cout << maximum << endl;
  }

  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n;
	cin>>n;
	n*=2;
	int sum=0;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	rep(i,n/2){
		int a=in[i*2];
		int b=in[i*2+1];
		sum+=min(a,b);
	}
	cout<<sum<<endl;
}






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

#define FOR(i,m,n) for(int i=(m);i<(n);++i)

const int MOD = 1000000007; // 998244353;
/*----------------------------------------*/
const int MAX = 10000000;
int least_prime_factor[MAX + 1];
void osa_k_init(int num = MAX) {
  memset(least_prime_factor, -1, sizeof(least_prime_factor));
  least_prime_factor[0] = 0;
  least_prime_factor[1] = 1;
  FOR(i, 2, num + 1) if (least_prime_factor[i] == -1) {
    least_prime_factor[i] = i;
    for (int j = i * i; j <= num; j += i) {
      if (least_prime_factor[j] == -1) least_prime_factor[j] = i;
    }
  }
}

vector<pair<int, int> > osa_k(int num) {
  vector<pair<int, int> > res;
  while (num > 1) {
    int prime = least_prime_factor[num], exponent = 0;
    while (least_prime_factor[num] == prime) {
      ++exponent;
      num /= prime;
    }
    res.emplace_back(prime, exponent);
  }
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  osa_k_init(n);
  map<int, int> mp;
  FOR(i, 2, n + 1) {
    auto tmp = osa_k(i);
    for (auto a : tmp) mp[a.first] += a.second;
  }
  long long ans = 1;
  FOR(i, 2, n + 1) if (mp[i] > 0) (ans *= (mp[i] + 1)) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 39424
#include <utility>
#include <vector>
#include <queue>
#include <functional>
#include <cassert>

using namespace std;

class Dijkstra {
#define MAX_V 101
  typedef pair<int, int> P;

private:
  const int INF = 1e9 + 10;
  struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) { }
  };

  int V;
  vector<Edge> G[MAX_V];

public:

  Dijkstra(int V): V(V) { 
    if (V >= MAX_V) {
      assert(false);
    }
  }

  void AddEdge(int from, int to, int cost) {
    G[from].push_back(Edge(to, cost));
  }

  vector<int> Solve(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> d(V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
      P p = que.top(); que.pop();
      int v = p.second;
      if (d[v] < p.first) {
        continue;
      }
      for (int i = 0; i < G[v].size(); i++) {
        Edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }

    return d;
  }
};

#include <iostream>


int main() {
  int n;
  cin >> n;
  Dijkstra dijkstra(n);
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int t, c;
      cin >> t >> c;
      dijkstra.AddEdge(u, t, c);
    }
  }

  vector<int> d = dijkstra.Solve(0);

  for (int i = 0; i < n; i++) {
    cout << i << " " << d[i] << endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	
	vector<int> V;
	while (n--)
	{
		int a;
		cin >> a;
		V.push_back(a);
	}
	
//	vector<int>::iterator it = V.begin();
//	while (it != V.end())
//	{
//		cout << *it << ' ' << endl;
//		it++;
//	}


	int q;
	cin >> q;
	while (q--)
	{
		int cmd, b, e;
		cin >> cmd >> b >> e;
		
		if (cmd)
		{
			cout << *max_element(V.begin()+b, V.begin()+e) << endl;
			
		}
		else
		{
			cout << *min_element(V.begin()+b, V.begin()+e) << endl;
		}
	}
}


Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

const int MAX_N = 131072;
int n;
int dat[MAX_N * 2 - 1];
void init() {
    rep(i, 2 * MAX_N - 1) dat[i] = INT_MAX;
}
void update(int i, int x) {
    //高さ4の木
    //i = 2なら木ではindex 9
    i += n - 1;
    dat[i] = x;
    //cout << i << " " << x << endl;
    while (i > 0) {
        i = (i - 1) / 2; //登る
        dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
}
int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b) return dat[k];
    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 q; cin >> n >> q;
    int tmp = 1; while (tmp < n) tmp *= 2;
    n = tmp;
    init(); //cin >> nのあとじゃないとsize?になるかも
    rep(i, q) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) {
            update(x, y);
        } else {
            cout << query(x, y + 1, 0, 0, n) << endl;
        }
        //cout << endl;
        //rep(j, 2 * n + 1) cout << dat[j] << " "; cout << endl;
    }
}



Measured memory_bytes: 4100
def main()
  n,m = gets.chomp.split(' ').map(&:to_i)
  mod = 10**9 + 7
  if (n-m).abs > 1
    puts 0
  else
      tmp = (1..([n,m].min)).inject(1){|sum,i| sum * i % mod}
      if n == m
        puts 2 * tmp * tmp % (10**9 + 7)
      else
        puts (tmp * tmp * [n,m].max) % mod
    end
  end
end

main()

Measured memory_bytes: 1916
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		int city[][] = new int[m + 1][4]; // id, pref, year, number in pref
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				if ( o1[1] != o2[1] ) {
					return o1[1] - o2[1];	// 1.prefでソート
				} else {
					return o1[2] - o2[2];	// 2.yearでソート
				}
			}
		});

		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		int pref = -1;
		int num = 0;
		for ( int i = 1; i <= m; i++ ) {
			if ( pref == city[i][1] ) {
				num++;
			} else {
				pref = city[i][1];
				num = 1;
			}
			result[city[i][0] - 1] = df.format(pref) + df.format(num);
		}

		StringBuilder sb = new StringBuilder();
		for ( String s : result ) {
			sb.append(s).append("\n");
		}
		System.out.println(sb.toString());
		in.close();
	}
}

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

int main(){
  int N; cin >> N;
  vector<bool> sam(N+1, 0);
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    a--;
    if(i == a) sam[i] = 1;
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(sam[i] == 1){
      ans++;
      sam[i+1] = 0;
    }
  }
  cout << ans;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < N; i++){
		cout << S[i] << T[i];
	}


	return 0;
}

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

bool is_palindrome(string);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int L = s.length();
	if (is_palindrome(s.substr(0, L / 2)) && is_palindrome(s.substr(L / 2 + 1, L / 2)) && is_palindrome(s)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

bool is_palindrome(string s) {
	int k = s.length();
	for (int i = 0; i < k / 2; ++i) {
		if (s.at(i) != s.at(k - 1 - i)) {
			return false;
		}
	}
	return true;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
const int MAX = 1000001;
int main(void){
  bool prime[MAX];
  vector<int> p;
  FOR(i,2,MAX) prime[i]=true;
  FOR(i,2,MAX){
    if(prime[i]){
      p.push_back(i);
      for(int k=2; i*k<=MAX; k++){
        prime[i*k]=false;
      }
    }
  }
  int n;
  while(cin>>n){
    if(n==0) break;
    int count=0;
    for(int i=0; i<p.size()&&2*p[i]<=n; i++){
      if(prime[n-p[i]]) count++;
    }
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a_list = []
b_list = []

for _ in range(n):
    a, b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)

a_list.sort()
b_list.sort()

if n%2==0:
    half = int(n/2)
    first = (a_list[half-1]+a_list[half])/2
    last = (b_list[half-1]+b_list[half])/2
    print(int((last-first)/0.5)+1)
else:
    half = int((n+1)/2)
    print(b_list[half-1]-a_list[half-1]+1)

Measured memory_bytes: 25428
s = input().rstrip()

pre = ""
ans = 0
b, e = 0, 1
while b < len(s) and e < len(s) + 1:
    if pre != s[b:e]:
        pre = s[b:e]
        ans += 1
        b, e = e, e + 1
    else:
        e += 1

print(ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int n, d;
  cin >> n >> d;
  int x[10][10] = {};
  REP(i, n)
  {
    REP(j, d)
    {
      cin >> x[i][j];
    }
  }

  int ans = 0;
  REP(i, n)
  {
    FOR(j, i + 1, n)
    {
      int dis = 0;
      REP(k, d)
      {
        dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      int tmp = 0;
      while (tmp <= dis)
      {
        if (tmp * tmp == dis)
        {
          ans++;
          break;
        }
        tmp++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
//2018年  3月 21日 水曜日 23:11:04 JST
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll WD;
ll dp[110][310][110];
ll W[110], V[110];

void solve() {
	cin >> N >> WD;
	rep(i, 0, N) cin >> W[i] >> V[i];

	ll wc = W[0];
	rep(i, 0, N) {
		rep(j, 0, 3 * N + 1) {
			rep(k, 0, N + 1) {
				dp[i][j][k] = -inf;
			}
		}
	}
	dp[0][0][0] = 0;
	rep(i, 0, N) {
		rep(j, 0, 3 * i + 1) {
			rep(k, 0, i + 1) {
				if(dp[i][j][k] == -inf) continue;
				MAX(dp[i + 1][j + W[i] - wc][k + 1], dp[i][j][k] + V[i]);
				MAX(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	ll res = -inf;
	rep(i, 0, 3 * N + 1) {
		rep(l, 0, N + 1) {
			if(wc * l + i <= WD) {
				MAX(res, dp[N][i][l]);
			}
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define F first 
#define S second 
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
bool sortBy(const pair<int,int> &a,const pair<int,int> &b){
	if(a.F==b.F)
		return a.S<b.S;
	return a.F>b.F;
}

#define MAXN 1000001
int pf[MAXN]; 
void sieve(){
	long long int i,j; 
    pf[1] = 1; 
    for (i=2; i<MAXN; i++) 
    pf[i] = i;   
    for (i=2; i*i<MAXN; i++){ 
        if (pf[i] == i){
            for (j=i*i; j<MAXN; j+=i) 
                if (pf[j]==j) 
                    pf[j] = i; 
        } 
    } 
}
// vector<int> factors(int x){ 
//     vector<int> ret; 
//     while (x != 1){ 
// 		int fact=pf[x];
//         ret.push_back(pf[x]); 
// 		while(fac!=1&&x%fact==0)
//         x/=fact; 
//     } 
//     return ret; 
// } 
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }  
// long long int power(long long int a,int n){
//     if(n==1)
//     return a;
//     if(n%2){
//         return power()
//     }
// }
int main() {		
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
	//cin>>qwe;
	//init();
	sieve();
	while(qwe--){
        int n;
        cin>>n;
        int a[n];
        int gcd;
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(i){
                gcd=__gcd(gcd,a[i]);
            }else{
                gcd=a[i];
            }
        }
        map<int,int> power;
        if(gcd==1){
            int flag=0,div;
            for(int i=0;i<n;i++){
                while(a[i]!=1){
                    div=pf[a[i]];
                    while(a[i]%div==0){
                        a[i]/=div;
                    }
                    power[div]++;
                    if(power[div]>=2){
                        flag=1;
                        break;
                    }    
                }
                //cout<<a[i]<<" "<<pf[a[i]]<<endl;
                if(flag)
                break;
            }
            if(flag){
                cout<<"setwise coprime";
            }else{
                cout<<"pairwise coprime";
            }
        }else{
            cout<<"not coprime";
        }




	}

	return 0;
}


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

if n // 2 == 1:
    print(max(a))
    exit()
if n < 20:
    d = a.copy()
    
    for i in range(1, n // 2):
        b = [0] * n
        c = -10 ** 24
        ans = -10 ** 24
        for j in range(i * 2, n):
            c = max(c, a[j - 2])
            b[j] = c + d[j]
            ans = max(ans, c + d[j])

        a = b.copy()
    print(ans)
    exit()

b = a[:10]
e = [True]*10

for i in range(1, n // 2):
    c = [0] * 10
    f = [False]*10
    d = -10**24
    for j in range(10):
        if 2 * i + j >= n:
            continue
        if not e[j]:
            continue
        d = max(d, b[j])
        c[j] = d + a[2 * i + j]
        f[j] = True
    e = f.copy()
    b = c.copy()
ans = -10 ** 24
for i in range(10):
    if e[i]:
        ans = max(ans, b[i])
print(ans)


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

int main(){
	int data[10]={};
	rep(i,0,5) cin>>data[i];
	sort(data,data+5);
	reverse(data,data+5);
	rep(i,0,4) cout<<data[i]<<" ";
	cout<<data[4]<<endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector <int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    bool a = false;

    sort(A.begin(), A.end());
    for (int i = 0; i < N - 1; i++) {
        if (A.at(i) == A.at(i + 1)) {
            a = true;
        }
    }

    if (a) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin >>S;
  
  set<char> alb;
  rep(i,S.size()) alb.insert(S[i]);
  bool flag=false;
  for(char j='a';j<='z';j++){
    if(*begin(alb)==j&&j!='z') alb.erase(j);
    else if(*begin(alb)==j&&j=='z') puts("None");
    else{
      cout<<j<<endl;
      flag=true;
      break;
    }
    if(flag)break;
  }
  return 0;
}


Measured memory_bytes: 512
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
const int INF = 1000000000;
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
    return 0;
}




Measured memory_bytes: 3672
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int n,a,chk=0,ans=0;
    int INF=(int)1e9;
    scanf("%d",&n);
    int dp[n];
    fill(dp,dp+n, INF);
    vector<int> l(n);
    for(auto&e:l){
        scanf("%d",&e);
    }
    for(int i=0;i<n;i++){
        *lower_bound(dp,dp+n, l[i])=l[i];
    }
    printf("%d\n",lower_bound(dp,dp+n, INF)-dp);
    return 0;
}

Measured memory_bytes: 1784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			sum += Math.min(x, Math.abs(x - k));
		}
		
		System.out.println(sum * 2);
		
		sc.close();
	}
}




Measured memory_bytes: 27208
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string s,t;
	cin>>s;

	if(s[0]=='K')t+='A';
	rep(i,s.size()){
		t+=s[i];
		if(s[i]=='H'&&s[i+1]!='A')t+='A';
		if(s[i]=='B'&&s[i+1]!='A')t+='A';
		if(s[i]=='R'&&s[i+1]!='A')t+='A';
	}
	if(t=="AKIHABARA")cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n;
  cin >> n;
  cout << pow(n, 3) << endl;

	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	n = int(input())
	num = [int(i) for i in input().split()]
	count=0
	for i in range(n):
		mini = i
		for j in range(i,n):
			if num[j] < num[mini]:
				mini = j
		num[i],num[mini] = num[mini],num[i]
		if i != mini:
			count += 1
	for i in range(n):
		if i != n-1:
			print("%d" % (num[i]),end=" ")
		else:
			print("%d" % (num[i]))
	print(count)


Measured memory_bytes: 5612
#include <stdio.h>

int main(void)
{	
	int a,b,add,cnt=0;

	while(scanf("%d%d",&a,&b)!=EOF){
		add=a+b;
		for(cnt=0; add!=0; add/=10)
			cnt++;
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = IOUtils.ReadNums().First();
            var chars = Console.ReadLine();

            var idxDic = chars.Select((c, i) => new { Rgb = c, Idx = i })
                 .GroupBy(a => a.Rgb)
                 .ToDictionary(g => g.Key, g => new HashSet<int>(g.Select(v => v.Idx)));

            if (idxDic.Count != 3)
            {
                Console.WriteLine(0);
                return;
            }

            long count = 0;
            foreach (var rIdx in idxDic['R'])
            {
                foreach (var gIdx in idxDic['G'])
                {
                    var bSet = idxDic['B'];

                    var s = rIdx < gIdx ? rIdx : gIdx;
                    var l = rIdx < gIdx ? gIdx : rIdx;
                    var diff = l - s;
                    
                    var ngCnt = 0;
                    if (bSet.Contains(s - diff)) ngCnt++;
                    if (bSet.Contains(l + diff)) ngCnt++;
                    if (diff % 2 == 0 && bSet.Contains(s + (diff / 2))) ngCnt++;

                    count += (bSet.Count - ngCnt);
                }
            }
            Console.WriteLine(count);
        }

    }

    static class IOUtils
    {
        public static IEnumerable<int> ReadNums()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v));
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 20944
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int[] bells = new int[3];
        for(int i = 0;i < bells.length;i++)
            bells[i] = sc.nextInt();
        Arrays.sort(bells);
        System.out.println(bells[0] + bells[1]);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    ll k, arr[6], mn = 1e17;
    cin >> k;
    for(int i = 0; i < 5; i++){
        cin >> arr[i];
        mn = min(mn, arr[i]);
    }
    cout << (k/mn) + (k % mn != 0) + 4;
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 20min
int main(void){
  int n, t, a;
  int ans = 0;
  double ans_h = 100000;

  scanf("%d%d%d", &n, &t, &a);

  for(int i = 1; i <= n; i++){
    int h = 0;
    scanf("%d", &h);

    //        printf("%f   %f\n", fabs((t - h * 0.006) - a) , ans_h);
    if(fabs((t - h * 0.006) - a) < ans_h){
      ans = i;
      ans_h = fabs((t - h * 0.006) - a);
    }
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    ll n, a, b;
    while(cin >> n) {
        ll ans = 0, flag = 2e9;
        for(int i = 0; i < n; i++) {
            scanf("%lld %lld", &a, &b);
            ans += a;
            if(a > b) flag= min(flag, b);
        }
        if(flag == 2e9) cout << 0 << endl;
        else
            cout << ans - flag<< endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    }
    public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    }

}



Measured memory_bytes: 26164
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

D = ni()
c = na()
s = [na() for _ in range(D)]
out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26

for d in range(D):
    assert(1 <= out[d] and out[d] <= 26)
    j = out[d] - 1
    last[j] = d + 1
    for i in range(26):
        sat -= (d + 1 - last[i]) * c[i]
    sat += s[d][j]
    print(sat)


Measured memory_bytes: 11012
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int k = pow(2, m);
    cout << (1800 * m + 100 * n) * k << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class NumClass{
	public int max;
	public int sum;
}
	

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int i,j,k;
	  	int count;
	  	
	  	NumClass num = new NumClass();
	  	
	  	while(true){
	  		count = 0;
	  		num.max = scanner.nextInt();
	  		num.sum = scanner.nextInt();
		  	
		  	if(num.max == 0 && num.sum == 0)
		  		break;
		  	
		  	for(i = 1; i <= num.max - 2 ; i ++){
		  		for( j = i + 1; j <= num.max - 1; j ++ ){
		  			for(k = j + 1; k <= num.max ; k ++){
		  				if(i + j + k == num.sum) {
		  					count ++;
		  					if(i == k || j == k || i == j)
		  						count --;
		  				}
		  			}
		  		}
		  	}

			System.out.println(count);
	  		
	  	}
        scanner.close();
  }
}


Measured memory_bytes: 27044
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <functional>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

typedef long long LL;
int n,m,k,tot,heap[100100];
LL sum1[100100],sum2[100100],sum,ans;
struct data
{
    int a,b;
    bool operator<(const data &t) const
    {
        return a-b>t.a-t.b;
    }
} a[100100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    repu(i,1,n+m+k)
    {
        int t;
        a[i].a=getint(),a[i].b=getint(),t=getint();
        sum+=t,a[i].a-=t,a[i].b-=t;
    }
    sort(a+1,a+n+m+k+1);
    repu(i,1,n)
        sum1[n]+=heap[++tot]=a[i].a;
    make_heap(heap+1,heap+tot+1,greater<int>());
    repu(i,n+1,n+k)
        if (heap[1]<a[i].a)
        {
            sum1[i]=sum1[i-1]-heap[1]+a[i].a;
            pop_heap(heap+1,heap+tot+1,greater<int>());
            heap[tot]=a[i].a,push_heap(heap+1,heap+tot+1,greater<int>());
        }
        else
            sum1[i]=sum1[i-1];
    tot=0,ans=-1LL<<60;
    repd(i,n+m+k,n+k+1)
        sum2[n+k+1]+=heap[++tot]=a[i].b;
    make_heap(heap+1,heap+tot+1,greater<int>());
    repd(i,n+k,n+1)
        if (heap[1]<a[i].b)
        {
            sum2[i]=sum2[i+1]-heap[1]+a[i].b;
            pop_heap(heap+1,heap+tot+1,greater<int>());
            heap[tot]=a[i].b,push_heap(heap+1,heap+tot+1,greater<int>());
        }
        else
            sum2[i]=sum2[i+1];
    repu(i,n,n+k)
        ans=max(ans,sum1[i]+sum2[i+1]);
    printf("%lld\n",ans+sum);
    return 0;
}

Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	for {
		h := nextInt()
		w := nextInt()
		if h == 0 && w == 0 {
			break
		}
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if (i+j)%2 == 0 {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Println()
		}
		fmt.Println()
	}

}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll gedo=a+b;
    if(gedo>=c){
        cout<<b+c<<endl;
    }
    else{
        ll ans=0;
        ans+=b;
        ans+=b;
        c-=b;
        ans+=a;
        ans++;
        cout<<ans<<endl;


    }


}



Measured memory_bytes: 256
N,M = map(int,input().split())
drink = [list(map(int,input().split())) for n in range(N)]
drink.sort(key=lambda x: x[0])
Cnt = 0
Ttl = 0
x = 0
while Cnt < M:
  while Cnt < M and drink[x][1] > 0:
    Cnt += 1
    Ttl += drink[x][0]
    drink[x][1] -= 1
  x += 1

print(Ttl)

Measured memory_bytes: 64728
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem101c(n, k, a))
}

fun problem101c(n: Int, k: Int, a: List<Int>): Int {
    if (n == k) return 1
    return ((n - 1) / (k - 1) + if ((n - 1) % (k - 1) != 0) 1 else 0)
}

Measured memory_bytes: 49424
// https://atcoder.jp/contests/abc137/tasks/abc137_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        a: i32, b: i32
    };
    println!("{}", max(a-b, max(a+b, a*b)));
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
   if(a == 0){
       cout << 1 << endl;
       return 0;
    }
    if(b == 0){
       cout << 2 << endl;
       return 0;
    }
    if(c == 0){
       cout << 3 << endl;
       return 0;
    }
    if(d == 0){
       cout << 4 << endl;
       return 0;
    }
    if(e == 0){
       cout << 5 << endl;
       return 0;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int N;
int ans;

bool is_753(int n)
{
	bool a,b,c;
	a=b=c=false;
	while (n) {
		int k = n % 10;
		if (k == 3) a = true;
		if (k == 5) b = true;
		if (k == 7) c = true;
		n /= 10;
	}
	return a and b and c;
}

void dfs(int n)
{
	if (n > N) return;

	if (is_753(n)) ans++;

	dfs(n*10+7);
	dfs(n*10+5);
	dfs(n*10+3);
}

signed main()
{
	cin >> N;

	dfs(0);

	cout << ans << endl;
}




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

int main() {
	long long a, b,c;
	cin >> a >> b;
	c = (a - 2)*(b - 2);
	if (a == 1)
		if (b == 1)
			c = 1;
		else if (b == 2) c = 0; else c = b-2;
	else if (b == 1) if (a == 2) c = 0; else c = a-2;


	cout << c << endl;




	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const int mod=99991;
const int maxn=200007;


ll sum=0;
string vis;

int main()
{
    cin>>vis;
    int a=0,b=0;
    for(int i=0;i<vis.size();i++)
    {
        if(vis[i]=='A')
            a++;
        else if(vis[i]=='B')
        {
            if(i+1<vis.size()&&vis[i+1]=='C')
            {
                sum+=a;
                i++;
            }
            else
                a=0;
        }
        else
            a=0;
    }
    printf("%lld\n",sum);
    return 0;

}
/*
ABCABCABCBCAACABC

*/


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_040
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[][] lrs = new int[n][];
            for(int i = 0; i < n; i++)
            {
                lrs[i] = ReadInts();
            }
            int maxRange = 0;
            int lMax = 0;
            int rMin = int.MaxValue / 2;
            for(int i = 0; i < n; i++)
            {
                maxRange = Max(maxRange, lrs[i][1] - lrs[i][0]);
                lMax = Max(lMax, lrs[i][0]);
                rMin = Min(rMin, lrs[i][1]);
            }
            int res = Max(rMin - lMax + 1, 0) + maxRange + 1;

            int[][] abs = new int[n][];
            for(int i = 0; i < n; i++)
            {
                abs[i] = new int[2] { Max(lrs[i][1] - lMax + 1, 0), Max(rMin - lrs[i][0] + 1, 0) };
            }
            abs = abs.OrderBy(p => -p[1]).OrderBy(p => p[0]).ToArray();
            int bMax = abs[0][1];
            for(int i = 1; i < n; i++)
            {
                int tmp = abs[i][0] + bMax;
                res = Max(res, tmp);
                bMax = Min(bMax, abs[i][1]);
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 35132
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



int main()
{
	int n,k; cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	vector<int> dp(n,numeric_limits<int>::max());
	dp[0] = 0; dp[1] = abs(h[1] - h[0]);

	for (int i = 2; i < n; i++)
	{
		for (int j = 1; j < k+1; j++)
		{
			if (i - j < 0) { break; }
			else {dp[i] = min(abs(h[i - j] - h[i]) + dp[i - j], dp[i]); }
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)

    val Array(n, m, q) = sc.readInts(3)
    val LR = Array.fill(m)(sc.nextInt, sc.nextInt)
    val Q = Array.fill(q)(sc.nextInt, sc.nextInt)

    val mutableIntervals: Array[Array[Int]] = Array.fill(n)(Array.fill(n)(0))
    LR.foreach { case (l, r) => mutableIntervals(l - 1)(r - 1) += 1 }
    val summedInterval = mutableIntervals.map(_.scan(0)(_+_)).transpose.map(_.scan(0)(_+_)).transpose

    Q.foreach { case (l, r) =>
      println(summedInterval(r)(r) - summedInterval(l - 1)(r) - summedInterval(r)(l - 1) + summedInterval(l - 1)(l - 1))
    }

  }
}


Measured memory_bytes: 128824
#include <bits/stdc++.h>
  using namespace std;
  using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()


int num(char c) {
  return c - '0';
}


int main() {
  string s;
  cin >> s;
  int a = num(s[0]) * 10 + num(s[1]);
  int b = num(s[2]) * 10 + num(s[3]);
  bool A = (a >= 0) && (b <= 12) && (b > 0);
  swap(a, b);
  bool B = (a >= 0) && (b <= 12) && (b > 0);
  if(A && B) {
    cout << "AMBIGUOUS" << endl;
  }
  else if(A) {
    cout << "YYMM" << endl;
  }
  else if(B) {
    cout << "MMYY" << endl;
  }
  else {
    cout << "NA" << endl;
  }
}


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

int main(){
    int h,w,t,y;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0)break;
        for(t=0; t<h; t++){
            for(y=0; y<w; y++){
                cout << "#";
             }
             cout << "\n";
            }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
bool visited[100005];
const int max_N=1e5+10;
ll N,X;
ll layer[55];
ll paty[55];
ll ans=0;
ll dfs(ll level,ll eat)
{
  if(eat<=1) return 0;
  else if(eat<layer[level-1]+1)
    {
      return dfs(level-1,eat-1);
    }
  else if(eat==layer[level-1]+1)
    {
      return paty[level-1];
    }
  else if(eat==layer[level-1]+2)
    {
      return 1+paty[level-1];
    }
  else if(eat<layer[level-1]*2+2)
    {
      return 1+paty[level-1]+dfs(level-1,eat-layer[level-1]-2);
    }
  else if(eat>=layer[level-1]*2+2)
    {
      return 1+2*paty[level-1];
    } 
}

int main(void)
{
  cin >> N >> X;
  layer[0]=1;
  paty[0]=1;
  for (int i = 1; i <= N; ++i)
    {
      layer[i]=layer[i-1]*2+3;
      paty[i]=paty[i-1]*2+1;
    }
  cout << dfs(N,X) << endl;;
  
  return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
l = {}
for k in range(n):
  l.update({k: input().split()})
x = l.copy()
s = 0
c = 0
num = {
  2: 1,
  3: 3,
  4: 6,
  5: 10,
  6: 15,
  7: 21,
  8: 28
}
p = 0
while len(x) > 1:
  d = x.pop(c)
  for k,v in x.items():
    s = s + math.sqrt(
      pow(
        (int(d[0]) - int(v[0])), 2
      ) + pow(
        (int(d[1]) - int(v[1])), 2
      )
    )
    p = p + 1
  c = c + 1

print(s  * 2 / n)


Measured memory_bytes: 3064
from itertools import product
S = list(input())
S = [int(x) for x in S]
z = [0 for _ in range(3)]
for x in product(range(2), repeat = 3):
    y = S[0]
    for i in range(1,4):
        if x[i-1] == 0:
            y += S[i]
        else:
            y -= S[i]
    if y == 7:
        z = x
        break
ans = str(S[0])
for i in range(1,4):
    if z[i-1] == 0:
        ans += '+'
    else:
        ans += '-'
    ans += str(S[i])
ans += '=7'
print(ans)

Measured memory_bytes: 3064
#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->key != NIL)
    x->key = x->left->key;
  return x;
}

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

}

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

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 to be deleted
  Node x; // child of y



}

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: 20496
#include <iostream>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int x[3], max = 0;
	rep(i,3){
		cin >> x[i];
		if(x[i] > max) max = x[i];
	}
	if(max == x[0]) cout << x[0]*10+x[1]+x[2];
	else if(max == x[1]) cout << x[1]*10+x[0]+x[2];
	else cout << x[2]*10+x[0]+x[1];
	return 0;
}

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

int main() {
	int x;
	cin >> x;
	int ans = 0;
	for (int i = 1, j = 0; j < x; j += i, i++) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
if __name__ == '__main__':
    n, m = [int(i) for i in input().split()]
    A = [[int(i) for i in input().split()] for j in range(n)]
    b = [int(input()) for i in range(m)]
    c = [sum(map(lambda x,y: x*y, A[i], b)) for i in range(n)]
    print('\n'.join([str(i) for i in c]))

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

int main(){
    int K,X;
    cin>>K>>X;
    int a[2*K-2];
    for(int i=0;i<2*K-1;i++)
        a[i]=X-K+1+i;
    if(K!=1){
            cout<<a[0];

    for (int j = 1; j < 2*K-2; j++) {
        cout<<" "<<a[j];
    }
    cout<<" "<<a[2*K-2]<<endl;
    }

    else cout<<a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
ll n,k;

ll low(ll k){
  return k*(k-1)/2;
}

ll high(ll k){
  return k*(n+n-k+1)/2;
}
int main() {
  ll ans=0;
  cin >> n >> k;
  for(int i=k;i<=n+1;i++){
    ans += high(i) - low(i) + 1;
    ans %= (ll)1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max];
ll n,A,B,ans;
void solve(){
	cin>>n>>A;
	rep(i,0,n)cin>>a[i];
	rep(i,0,n){
		if(a[i]>=A)ans++;
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1024