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

#define endl "\n"

#define rks ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){

string s,t;
int sum=0;
cin>>s>>t;
int n = s.length();
int n2 = t.length();
char arr[n+1];
char arr2[n2+1];
strcpy(arr,s.c_str());
strcpy(arr2,t.c_str());



for(int i=0;i<n;i++){
    if(arr[i]==arr2[i]){

    }else{
     sum=sum+1;
    }
}
cout<<sum;
}




Measured memory_bytes: 4160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	ios_base::sync_with_stdio(false);

	int n;
	cin>>n;
	int cnt=0;
	int l=1,r=9;
	while(1)
	{
		if(l<=n)
		{
			int plus=min(n,r)-l;
			plus++;
			cnt=cnt+plus;
		}

		if(l>n) break;

		l=l*10;
		r=r+(l*9);
		l=l*10;
		r=r+(l*9);
	}

	cout<<cnt<<endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int leng = sc.nextInt();boolean[] p = new boolean[leng]; 
			int t = sc.nextInt(), pleng = p.length;
			if(pleng==0 & t==0) break;
			Arrays.fill(p, true);
			int tcount = pleng, count = 0;
			while(tcount!=1){
				for(int i = 0;i < t;){
					count++;
					count = count%pleng;
					if(p[count])i++;
				}       
				p[count] = false;
				tcount--;
			}
			int ans = 0;
			while(p[ans] == false ) ans++;
			if(ans==0) ans = pleng;
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 27088
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
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(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;

int main() {
	
	int n;
	cin >> n;
	vii a(n, vi(3)),dp(n+2,vi(3,0));
	rep(n) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}

	rep(n) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j != k)chmax(dp[i + 1][j], dp[i][k] + a[i][k]);
			}
		}
	}
	int ma = dp[n][0];
	ma = max(dp[n][1], max(ma, dp[n][2]));
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 11136
import numpy as np
N,D=map(int,input().split())
X=[]
dist=[]
Xsumnow=0
Xsumnext=0

for i in range(N):
    X.append([int(j) for j in input().split()])
count=N
for m in range(N):
    for j in range(m+1,N):
        for k in range(D):
            Xsumnow+=abs(X[j][k]-X[m][k])*abs(X[j][k]-X[m][k])
        dist.append(np.sqrt(Xsumnow))
        Xsumnow=0
TrueCounter=0
for l in range(len(dist)):
    if dist[l].is_integer():
        TrueCounter+=1

print(TrueCounter)

Measured memory_bytes: 12440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, a, b, k);
    if(k <= a){
        Cout(a-k, " ", b); return 0;
    }
    if(k <= a+b){
        Cout(0, " ", b-(k-a)); return 0;
    }
    Cout(0, " ", 0);
}


Measured memory_bytes: 256
#include <stdio.h>

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

  int max = 0;
  int sum = 0;
  int L;
  for(int i = 0;i < N;i++){
    scanf("%d",&L);
    if(max < L){
      max = L;
    }
    sum += L;
  }
  
  if(sum-max > max){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

    ll N;
    cin >> N;

    vector<ll> vec(N+1);
    for (ll i = 0; i <= N; i++) {
        if(!(i%3==0)&&!(i%5==0)){
            vec.at(i) = i;
        }
        else{
            vec.at(i) = 0;
        }
        
    }
    ll sum = 0;
    for (ll i = 0; i <= N; i++)
    {
        sum += vec.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 11080
#ABC106

n = int(input())

# (1+p)(1+q)(1+r)
# 2*2*2=8
# (1+p+p^2+p^3)(1+q)
# 4*2=8

# p = [3,5,7,11,13,17,19]

l = [1,3*5*7,3**3*5,3*5*11,3**3*7,3*5*13,201]

for i in range(6):
    if l[i] <= n < l[i+1]:
        print(i)
        break

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char t[10];
	int i=0;
	char a;
	while(cin>>a)
	{
		
		if(a=='1')
		{
			t[i++]='1';
		}
		else if(a=='0')
		{
			t[i++]='0';
		}
		else
		
		{
			if(i>0)
			{
				i--; 
			}
			
		}
	}
	for(int j=0;j<i;j++)
	printf("%c",t[j]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1000000007;
int n;
vector<int> f;
vector<vector<int>> e, dp;
vector<int> operator*(const vector<int> &lhs, const vector<int> &rhs) {
    int n = lhs.size() - 1;
    int m = rhs.size() - 1;
    vector<int> result(n + m + 1);
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j)
            result[i] = (result[i] + 1LL * lhs[i] * rhs[j] % P * f[j]) % P;
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j)
            result[i + j] = (result[i + j] + 1LL * lhs[i] * rhs[j]) % P;
    return result;
}
void dfs(int u, int p) {
    dp[u] = {0, 1};
    for (int v : e[u]) {
        if (v == p)
            continue;
        dfs(v, u);
        dp[u] = dp[u] * dp[v];
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    e.resize(n);
    f.resize(n + 1);
    dp.resize(n);
    f[0] = P - 1;
    for (int i = 1; i <= n; ++i)
        if (i % 2 == 0)
            f[i] = 1LL * f[i - 2] * (i - 1) % P;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs(0, -1);
    int ans = 0;
    for (int i = 0; i <= n; ++i)
        ans = (ans + 1LL * dp[0][i] * (P - f[i])) % P;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35328
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!long, ns = n.nsqrt;

  foreach_reverse (a; 1..ns+1)
    if (n % a == 0) {
      writeln((n/a).digits);
      break;
    }
}

auto digits(long x)
{
  foreach (i; 1..11)
    if (x / 10L ^^ i == 0) return i;
  assert(0);
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = 1 << (n.bsr / 2 + 1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/06  Problem: NU_25 B / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

void solve(int N, int S, int W, int P) {

	int g = S;
	VI a(N);
	FOR(i, 0, N) {
		a[i] = (g / 7) % 10;
		if (g % 2 == 0)g = g / 2;
		else g = (g / 2) ^ W;
	}

	/*cout << "a : ";
	FOR(i, 0, N) {
		cout << a[i] << " ";
	}cout << endl;*/

	int ans = 0;
	VL cumR(N + 1);
	cumR[N] = 0;
	LL ten = 1;
	//a = VI(N, 1); 0じゃない
	FORR(i, N - 1, -1) {
		//debug(a[i]);
		cumR[i] = ((ten)*a[i] % P) % P + cumR[i + 1];
		cumR[i] %= P;
		ten *= 10;
		ten %= P;
	}
	/*cout << "cumR : ";
	FOR(i, 0, N + 1) {
		cout << cumR[i] << " ";
	}cout << endl;*/

	if (P == 2) {
		int x = 0;
		FOR(i, 0, N) {
			if (a[i] != 0)x++;
			if (a[i] % 2 == 0 ) {
				ans += x;
			}
			//debug(x);
		}
	}
	else if (P == 5 ) {
		int x = 0;
		FOR(i, 0, N) {
			if (a[i] != 0)x++;
			if (a[i] % 5 == 0 ) {
				ans += x;
			}
			//debug(x);
		}
	}
	else {
		map<LL, LL>cnt;
		FOR(i, 0, N) {
			if (a[i] != 0) {
				cnt[cumR[i]]++;
			}
			ans += cnt[cumR[i + 1]];
		}
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, S, W, Q;
	while (cin >> N >> S >> W >> Q) {
		if (N == 0)break;
		solve(N, S, W, Q);
	}

	return 0;
}

Measured memory_bytes: 9524
S = list(input())
N = len(S)
c0 = 0
c1 = 0

for i in S:
	if i == "0":
		c0 += 1
	else:
		c1 += 1

if c0 >= c1:
	print(N - c0 + c1)
else:
	print(N - c1 + c0)


Measured memory_bytes: 4012
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 100010;

int n;
int dis[N], cnt[N];
bool vis[N];
vector<int> g[N];

void dfs1(int u) {
  vis[u] = true;
  for (int v : g[u])
    if (!vis[v]) {
      dis[v] = dis[u] + 1;
      dfs1(v);
    }
}

int dfn;
int tmp[N];

void dfs2(int u, int t) {
  vis[u] = true;
  for (int v : g[u])
    if (!vis[v] && (g[v].size() >= 2 || v == t)) {
      int link = (int)g[v].size() - (v != t);
      --dfn;
      tmp[dfn] = dfn - link + 2;
      while (--link) {
        --dfn;
        tmp[dfn] = dfn + 2;
      }
      dfs2(v, t);
      break;
    }
}

vector<int> solve(int s, int t) {
  memset(vis, 0, sizeof(vis));
  dfn = n - 1;
  tmp[dfn] = n;
  dfs2(s, t);
  return vector<int>(tmp, tmp + n);
}

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

  cin >> n;
  if (n == 2) {
    cout << "1 2\n";
    return 0;
  }
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs1(1);
  int rt = 0;
  for (int i = 1; i <= n; ++i)
    if (g[i].size() >= 2 && (rt == 0 || dis[i] > dis[rt]))
      rt = i;
  memset(vis, 0, sizeof(vis));
  dis[rt] = 0;
  dfs1(rt);
  int tr = rt;
  for (int i = 1; i <= n; ++i)
    if (g[i].size() >= 2) {
      if (cnt[dis[i]]++) {
        cout << "-1\n";
        return 0;
      }
      if (dis[i] > dis[tr])
        tr = i;
    }
  int s = 0, t = 0;
  for (int v : g[rt])
    if (g[v].size() < 2) {
      s = v;
      break;
    }
  for (int v : g[tr])
    if (g[v].size() < 2 && v != s) {
      t = v;
      break;
    }
  cout << min(solve(s, t), solve(t, s)) << '\n';

  return 0;
}



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

int main() {
  int a,b;
  
  cin >> a >> b;
  if(a % 3 == 0){
	  cout << "Possible"<<endl;
  }else if(b % 3 == 0){
	  cout << "Possible"<<endl;
  }else if((a+b) % 3 == 0){
	  cout << "Possible";
  }else{
	  cout << "Impossible";
  }
  return 0;
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void insertionSort(int A[], int N) {
		for (int i = 1; i < N+1 ; i++) {
			for (int k = 0; k < N; k++) {
				if (k != N - 1) {
					System.out.print(A[k] + " ");
				} else {
					System.out.println(A[k]);

				}
			}

			int v = A[i];
			int j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				
				j--;

			}A[j + 1] = v;
			

		}
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] A = new int[N+1];
		for (int i = 0; i < N; i++) {
			A[i] = scanner.nextInt();
		}
		insertionSort(A, N);

	}
}



Measured memory_bytes: 31216
using System;
using System.Linq;
using System.Collections.Generic;
class program{
  static void Main(){
    int[] nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    var nest = new List<int>[nm[0]];
    for(int i = 0; i < nm[0]; ++i){
      nest[i] = new List<int>();
    }
    Console.WriteLine("Yes");
    var ans = new int[nm[0]];
    for(int i = 0; i < nm[1]; i++){
      var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
      nest[--ab[1]].Add(--ab[0]);
      nest[ab[0]].Add(ab[1]);
    }
    Queue<int> que = new Queue<int>();
	que.Enqueue(0);
    while(que.Count > 0){
      int p = que.Dequeue();
      foreach(int j in nest[p]){
        que.Enqueue(j);
		if(ans[j] == 0) ans[j] = p+1;
      }
      nest[p].Clear();
    }
    for(int i = 1; i < nm[0]; i++){
      Console.WriteLine(ans[i]);
    }
  }
}

Measured memory_bytes: 58476
#include <iostream>
#include <algorithm>

using namespace std;

int N, C;
int has[30][150000];

int main()
{
    cin >> N >> C;
    for (int i = 0; i < N; i++)
    {
        int s, t, c;
        cin >> s >> t >> c;
        for (int j = s; j <= t; j++)
        {
            has[c-1][j] = 1;
        }
    }

    int ans = 0;
    for (int i = 0; i <= 100000; i++)
    {
        int r = 0;
        for (int j = 0; j < C; j++)
            r += has[j][i];
        ans = max (ans, r);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 16896
use std::io;
use std::io::BufRead;
use std::collections::HashSet;

fn main() {
    let mut set = HashSet::new();
    let stdin = io::stdin();
    for line in stdin.lock().lines().skip(1) {
        set.insert(String::from(line.unwrap().trim()));
    }
    for s in ['S', 'H', 'C', 'D'].iter() {
        for n in 1..14 {
            let s = format!("{} {}", s, n);
            if !set.contains(&s) {
                println!("{}", s);
            }
        }
    }
}



Measured memory_bytes: 5040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		int ans = Math.min(a, b)+Math.min(c, d);
		System.out.println(ans);
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << (a-1) * (b-1) << endl;

  return 0;
}


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

# define ll long long

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

    char c;
    cin>>c;
    if(int(c-'a') >=0  && int(c-'a')<26)
        cout<<'a';
    else
        cout<<'A';
}


Measured memory_bytes: 3560
//ABC 134 C Exception Handling

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a.begin(), a.end());

    for(int i=0; i<n; i++) {
        if(a[n-1].second == i) cout << a[n-2].first << endl;
        else cout << a[n-1].first << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
from operator import itemgetter

N = int(input())
data = []
for i in range(N):
    r = input().split()
    data.append((r[0], int(r[1]), i+1))

data = sorted(sorted(data, key=itemgetter(1), reverse=True), key=itemgetter(0))

for d in data:
    print(d[2])


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin >> n>>k;
	int ans = 0;
	REP(i, n) {
		int h;
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;
}

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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second

typedef long long ll;
typedef double DB;

const DB eps = 1e-10;

struct Point { DB x, y; };
Point operator + (Point a, Point b) { return (Point){a.x + b.x, a.y + b.y}; }
Point operator - (Point a, Point b) { return (Point){a.x - b.x, a.y - b.y}; }
Point operator * (DB k, Point a) { return (Point){k * a.x, k * a.y}; }
DB dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
DB cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
DB disc(Point a) { return sqrt(dot(a, a)); }

int q;
Point P1, P2, P3, P4;

int main() {
	scanf("%d", &q);
	while (q--) {
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &P1.x, &P1.y, &P2.x, &P2.y, &P3.x, &P3.y, &P4.x, &P4.y);
		Point vec1 = P2-P1, vec2 = P4-P3; DB t = cross(vec1, vec2);
		if (fabs(cross(vec1, vec2)) < eps) puts("2");
		else if (fabs(dot(vec1, vec2)) < eps) puts("1");
		else puts("0");
	}
	return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

const int MAXN = 300 + 10;
const int MOD = 1000000000 + 7;

typedef pair<int, int> pii;

int n, m, k;
int c[MAXN][MAXN];
int cnum[MAXN];

int gcd(int x, int y)
{
	return x == 0 ? y : gcd(y % x, x);
}

int fpow(int x, int p)
{
	int ret = 1;
	for(; p; p >>= 1, x = (long long)x * x % MOD)
		if(p & 1)
			ret = (long long)ret * x % MOD;
	return ret;
}

void init()
{
	for(int i = 0; i < MAXN; i++)
	{
		c[i][0] = c[i][i] = 1;
		for(int j = 1; j <= i - 1; j++)
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
	}
	for(int i = 1; i < MAXN; i++)
	{
		cnum[i] = 0;
		for(int s = 0; s <= i - 1; s++)
			cnum[i] = (cnum[i] + fpow(k, gcd(i, s))) % MOD;
		cnum[i] = (long long)cnum[i] * fpow(i, MOD - 2) % MOD;
//		cerr << i << ' ' << fpow(k, i) << ' ' << cnum[i] <<endl;
	}
}

vector<pii> edg[MAXN];
int dfn[MAXN], low[MAXN], totw = 0;
stack<int> sp, se;
bool used[MAXN];
int ans = 1;

void calc(int tp, int te)
{
	// cerr << tp << ' ' << te << endl;
	if(tp == 2 && te == 1)
		ans = (long long)ans * k % MOD;
	else if(tp == te)
		ans = (long long)ans * cnum[tp] % MOD;
	else if(tp < te)
		ans = (long long)ans * c[te + k - 1][k - 1] % MOD;
}

void tarjan(int x, int fa)
{
	dfn[x] = low[x] = ++totw;
	sp.push(x);
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i].first != fa)
		{
			int y = edg[x][i].first, id = edg[x][i].second;
			if(!used[id])
				se.push(id), used[id] = true;
			if(!dfn[y])
			{
				tarjan(y, x);
				low[x] = min(low[x], low[y]);
				if(low[y] >= dfn[x])
				{
					int tp = 1, te = 0, cur = 0;
					do
						cur = sp.top(), sp.pop(), tp++;
					while(cur != y);
					do
						cur = se.top(), se.pop(), te++;
					while(cur != id);
					calc(tp, te);
				}
			}
			else
				low[x] = min(low[x], dfn[y]);
		}
}

int main()
{
	ios::sync_with_stdio();
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);

	cin >> n >> m >> k;
	init();
	for(int i = 1; i <= m; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(make_pair(y, i));
		edg[y].push_back(make_pair(x, i));
	}
	for(int i = 1; i <= n; i++)
		if(!dfn[i])
			tarjan(i, 0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>

#pragma GCC optimize ("-O3", "unroll-loops")

using namespace std;

int main()
{
  size_t n;
  cin >> n;
  vector<int> av(n);
  vector<int> bv(n);
  for ( size_t i = 0; i < n; ++i ) cin >> av[i];
  for ( size_t i = 0; i < n; ++i ) cin >> bv[i];

  for ( size_t i = 0; i + 3 < n; i += 4 ) {
    av[i + 3] -= av[i + 2];
    av[i + 2] -= av[i + 1];
    av[i + 1] -= av[i];
  }

  const int buf_size = 8192;

  int ret = 0;
  for ( size_t i = 0; i < n; i += buf_size ) {
    int i_max = min(n, i + buf_size);
    size_t j = 0;
    for ( ; j + 3 < n; j += 4 ) {
      for ( int ii = i; ii < i_max; ++ii ) {
        int b = bv[ii];
        b += av[j];
        ret ^= b;
        b += av[j + 1];
        ret ^= b;
        b += av[j + 2];
        ret ^= b;
        b += av[j + 3];
        ret ^= b;
      }
    }
    for ( ; j < n; ++j ) {
      for ( int ii = i; ii < i_max; ++ii ) {
        ret ^= av[j] + bv[ii];
      }
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

double prim(int n, vector<edge> G[]) {
	vector<double> w(n, DBL_MAX); w[0] = 0;
	priority_queue< d_i, vector<d_i>, greater<d_i> > q;
	q.push(d_i(0, 0));
	double res = 0;
	while (!q.empty()) {
		d_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > w[u]) continue;
		res += w[u]; w[u] = -DBL_MAX;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (w[e.v] > e.w) {
				w[e.v] = e.w;
				q.push(d_i(e.w, e.v));
			}
		}
	}
	return res;
}

vector<edge> G[100];

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		vector<double> x(n), y(n), z(n), r(n);
		for (int i = 0; i < n; i++)
			cin >> x[i] >> y[i] >> z[i] >> r[i];
		for (int i = 0; i < n; i++)
			G[i].clear();
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++) {
				double dx = x[i] - x[j], dy = y[i] - y[j], dz = z[i] - z[j];
				double l = max(0.0, sqrt(dx * dx + dy * dy + dz * dz) - (r[i] + r[j]));
				edge e = {i, j, l}, _e = {j, i, l};
				G[i].push_back(e); G[j].push_back(_e);
			}
		printf("%.3f\n", prim(n, G));
	}
}

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

const int MOD = 1000000007;
#define p(var)  std::cout<<var<<std::endl
#define pp(var) std::cout<<#var" = "<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for (int i = 0; i <  (n); i++)
#define repeq(i, n) for (int i = 1; i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a;}
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b;}

/*-----8<-----8<-----*/

int main(){
    int N;
    cin >> N;
    vector<int> h(N,0);
    rep(i,N)cin >> h[i];

    int count=0;
    rep(i,N){
        bool cansee=true;
        rep(j,i){
            if(h[i]<h[j]){cansee=false;break;}
        }
        if(cansee)count++;
    }

    p(count);
    
    return 0;
    
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#define llint long long
#define mod 1000000007

using namespace std;

llint N, M;
string s;
llint dp[5005][5005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	cin >> N;
	cin >> s;
	M = s.size();
	
	dp[0][0] = 1;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= N; j++){
			dp[i][j] = 2*dp[i-1][j-1] + dp[i-1][j+1];
			if(j == 0) dp[i][j] += dp[i-1][j];
			dp[i][j] %= mod;
		}
	}
	
	llint ans = dp[N][M];
	ans *= pow(pow(2, M), mod-2);
	ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 195712
N, M = gets.strip.split(/ /).collect{|n| n.to_i}

X = 10 ** 9 + 7


def p(n)
	ret = 1
	(1..n).each{|i|
		ret = (ret * i) % X
	}
	ret
end

if N == M
	puts (p(N) * p(M) * 2) % X
elsif N + 1 == M || N == M + 1
	puts (p(N) * p(M)) % X
else
	puts "0"
end




Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

const ll MX=26;

int main(){
  string s,t;
  cin>>s>>t;
  ll N=s.size();
  s+=s;
  vector<int> dp(MX,-1);
  vector<vector<int>> nx(s.size(),dp);
  for(ll i=(int)s.size()-1;i>=0;i--){
    nx[i]=dp;
    dp[s[i]-'a']=i;
  }
  for(auto &I:t){
    I-='a';
    if(dp[I]==-1){cout<<-1<<endl; return 0;}
  }
  int idx=1;
  ll w=dp[t[0]];
  ll ans=0;
  while(idx<(int)t.size()){
    w=nx[w][t[idx]];
    ans+=w/N;
    w%=N;
    idx++;
  }
  cout<<ans*N+w+1<<endl;
  
  return 0;
}


Measured memory_bytes: 27136
program prob3
    implicit none
    integer(8) :: N
    integer(8), allocatable :: a(:)
    integer(8) :: i, ans
    read(*,*) N
    allocate(a(3*N))
    read(*,*) a

    call msort(a)

    ans = 0
    do i = 3*N-1, N+1, -2
        ans = ans + a(i)
    end do
    write(*,*) ans

    deallocate(a)


    stop
contains

  !
  ! swap two arguments
  !
subroutine swap(a, b)
    implicit none
    integer(8), intent(inout) :: a, b

    integer(8) :: c

    c = a
    a = b
    b = c

  end subroutine swap

  !
  ! merge sort
  !
  recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)

    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if

    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))

    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x

    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do

    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n

    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program prob3

Measured memory_bytes: 8952
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int n;
double sum, a;
int main(void) {
    int i;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> a;
        sum += 1.0/a;
    }
    sum = 1.0/sum;
    //    cout << sum << endl;
    printf("%.13lf\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return;
	}
	ll ans=0;
	while(n){
		n>>=1;
		ans++;
	}
	cout<<ans<<endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
  	cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio> 
using namespace std;
string s;
int vis=0;
int main()
{
	cin>>s;
	int l=s.size();
	for(register int i=0;i<l;i++)
	{
		if(s[i]=='C') 
		{
			vis=1;
		}
		if(s[i]=='F'&&vis==1) 
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
def flip(c):
    return '#' if c == '.' else '.'

while True:
    H, W = [int(x) for x in input().strip().split(' ')]
    if H == 0 and W == 0:
        break
    for i in range(H):
        start = '#' if i % 2 == 0 else '.'
        l = ''
        for j in range(W):
            p = start if j % 2 == 0 else flip(start)
            l += p
        print(l)
    print('')

Measured memory_bytes: 7688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        SetOut(sw);
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void solve()
    {
        int K = cin.nextint;
        int S = cin.nextint;
        long ans = 0;
        for (int i = 0; i <= K; i++)
        {
            for (int j = 0; j <= K ; j++)
            {
                if (0 <= S - i - j && S - i - j <= K)
                {
                    ans++;
                }
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std; 
int main()
 {
     long long a,b,k; 
    cin>>a>>b>>k;
     long long aa,bb,cc; 
    if(k>=a) 
        { 
        aa=0;
         cc=(k-a);
        if(cc>=b)
        {
        bb=0;
    }
        else
        {
    bb=b-cc;
}
        }
     else {
         aa=a-k; bb=b; 
        }
     cout<<aa<<" "<<bb<<endl; 
 }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct P {
  int y,x,l,r,o,cost;
  P(int y,int x,int l, int r, int o, int cost) :
    y(y),x(x),l(l),r(r),o(o),cost(cost) {}
  bool operator<(const P &b) const {
    return cost > b.cost;
  }
};

int dist[11][10][10][10][51];

int ba[11][11];

int main() {
  int w,h;
  while(cin>>w>>h,w||h) {
    int f, m, o;
    cin >> f >> m >> o;
    memset(ba,0,sizeof(ba));
    REP(i,h) {
      REP(j,w) {
        cin >> ba[i][j];
      }
    }
    REP(i,h+1)REP(j,w)REP(l,w)REP(r,w)REP(k,m+1)dist[i][j][l][r][k]=INF;
    priority_queue<P> Q;
    if (o>=2) {
      REP(i,w) {
        int oo = o-1;
        int cc = 0;
        int t = ba[0][i];
        if (t > 0) oo = min(oo+t,m);
        else cc += -t;
        dist[0][i][i][i][oo] = cc;
        Q.push(P(0,i,i,i,oo,cc));
      }
    }
    int ans = -1;
    while(!Q.empty()) {
      P p = Q.top(); Q.pop();

      // printf("(%d,%d) [%d,%d], %d %d\n", p.y,p.x,p.l,p.r,p.o,p.cost);
      if (p.y == h-1) {
        ans = p.cost;
        break;
      }
      
      if (p.o == 1) continue;
      // left, right
      REP(i,2) {
        int xx = p.x + (i?-1:1);
        if (xx<0||xx>=w) continue;
        int l = p.l;
        int r = p.r;
        bool f = 0;
        if (xx < l) l--,f=1;
        if (xx > r) r++,f=1;
        int oo = p.o-1;
        int cc = p.cost;
        if (f) {                // dig
          int t = ba[p.y][xx];
          if (t > 0) {
            oo = min(oo+t,m);
          } else {
            cc += -t;
          }
        }
        if (dist[p.y][xx][l][r][oo] > cc) {
          dist[p.y][xx][l][r][oo] = cc;
          Q.push(P(p.y,xx,l,r,oo,cc));
        }
      }
      // down
      int yy = p.y+1;
      int oo = p.o-1;
      int cc = p.cost;
      int t = ba[yy][p.x];
      if (t > 0) oo = min(oo+t,m);
      else cc += -t;
      if (dist[yy][p.x][p.x][p.x][oo] > cc) {
        dist[yy][p.x][p.x][p.x][oo] = cc;
        Q.push(P(yy,p.x,p.x,p.x,oo,cc));
      }
    }
    if (ans == -1 || ans>f) puts("NA");
    else cout << ans << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0;i < N; i++) {
    cin >> vec.at(i);
  }
  
  int ans = 0;
  
  for (int i = 0; i<N;i++) {
    for (int j = 0;j<N;j++) {
      if (vec.at(i) - vec.at(j) < 0) {
        ans = max(ans,vec.at(j) - vec.at(i));
      }
      else ans = max(ans,vec.at(i) - vec.at(j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = list(input())
a = len(s)-1
for i in range(2 ** a):
    b = ["-"] * a
    for j in range(a):
        if i>>j & 1:
            b[j] = "+"
    S = s[0]
    for x in range(a):
        S += b[x]
        S += s[x+1]
    if eval(S) == 7:
        print(S+"=7")
        exit()

Measured memory_bytes: 3060
#解説を見て実装
from collections import Counter

def main():
    N = int(input())
    A = tuple(int(c) for c in input().split(' '))
    L = [i+a for i, a in enumerate(A)]
    R = [i-a for i, a in enumerate(A)]
    #print(L)
    #print(R)

    #はじめL_t = defaultdict(list)としてiの候補を追加していったが、iとjは重複しないのでチェックが不要
    L_t = Counter(L)
    R_t = Counter(R)
    cnt = 0
    x_candidate = set(L) & set(R)
    for x in x_candidate:
        l_candidate = L_t[x]
        r_candidate = R_t[x]
        cnt += l_candidate * r_candidate

    print(cnt)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second
string dir = "NSEW";

int main(){
    std::ios_base::sync_with_stdio(false);
    string str; cin >> str;
    vi d(4, 0);
    for (char c : str){
        d[dir.find(c)] = 1;
    }
    bool b1 = d[0] ^ d[1];
    bool b2 = d[2] ^ d[3];
    if (b1 || b2) cout << "No" << endl;
    else cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public long MOD = 1000000007;
        public long[] X;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }
            X = Input.ReadLongArray();
            Array.Sort(X);
            List<long> XX = new List<long>();
            for (int i = 0; i < M - 1; i++)
            {
                XX.Add(X[i+1] - X[i]);
            }

            long ret = 0;
            XX.Sort();
            for (int i = 0; i < XX.Count - (N - 1); i++)
            {
                ret += XX[i];
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 22368
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if(s[s.length()-1]=='s'){
		cout<<s<<"es"<<"\n";
	}else{
		cout<<s<<"s"<<"\n";
	}
	return 0;
	}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var start = items[0] * 60 + items[1];
            var end = items[2] * 60 + items[3];
            end -= items[4];
            Console.WriteLine(end - start);
        }
    }
}


Measured memory_bytes: 28244
//kid_kb//

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;

int main()
{
    kb
    //                                            Let's Fight !!!!!!!
    ll t;
//    cin>>t;
    t=1;
    while(t--){
        ll n,d;
        cin>>n>>d;
        int ans=0;
        ll a,b;
        
        rep(i,0,n){
            cin>>a>>b;
            ll t2=a*a + b*b;
            double temp=sqrt(t2);
            if(temp<=d)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3696
#include<iostream>

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    std::cin >> n;
    std::cout << n << ":";
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0){
            std::cout << " " <<  i;
            n /= i;
        }
        if(i != 2)
            i++;
        if(n == 1)
            break;
    }
    if(n != 1) {
        std::cout << " " << n;
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3208
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
const int MAX_N = 1<<17;
const int INF = (1 << 31) - 1;
//const int INF = 100001;

int sz, dat[2 * MAX_N - 1];

void init(int n_){
	sz = 1;
	while (sz < n_)sz *= 2;
	for (int i = 0; i < 2 * sz - 1; ++i)dat[i] = INF;
}

void update(int k, int a){
	k += sz - 1;
	dat[k] = a;
	while (k>0) {
		k = (k - 1) / 2;
		dat[k] = std::min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r){
	if (r <= a || b <= l)return INF;
	if (a <= l && r <= b)return dat[k];
	else {
		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 std::min(vl,vr);
	}
}

int main(){
	int n,q;
	scanf("%d %d", &n, &q);
	init(n);
	for (int i = 0; i < q; ++i){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (a == 0){
			update(b, c);
		}
		else {
			//int query(b, c, 0, 0, n);
			printf("%d\n", query(b,c+1,0,0,sz));
		}
	}
	return 0;
}

Measured memory_bytes: 2052
const val mod = 1000000007L

fun main() {
    val N = readLine()!!.toLong()
    var ans = remainder(10, N) - remainder(9, N) - remainder(9, N) + remainder(8, N)
    ans %= mod
    if (ans < 0) {ans = (ans + mod) % mod}
    println(ans)
}

fun remainder(x: Long, n: Long): Long {
    var rem = 1L
    for (i in 1..n) {
        rem = rem * x % mod
    }
    return rem
}

Measured memory_bytes: 34592