akhauriyash/Code-Regression huggingface dataset:
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const ll inf = 5e15;

int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    V<PLL> XH(N);
    V<ll> coors(N);
    for (ll i = 0; i < N; i++) {
        ll x, h;
        cin >> x >> h;
        XH[i] = PLL(x, h);
        coors[i] = x;
    }

    sort(ALL(XH));
    coors.push_back(inf);
    sort(ALL(coors));
    auto get_right = [&](ll x) {
        return distance(coors.begin(),
                        upper_bound(ALL(coors), x));
    };

    V<ll> imos(coors.size() + 1);
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (0 < i) imos[i] += imos[i - 1];
        ll x, h;
        tie(x, h) = XH[i];
        if (h <= imos[i] * A) continue;
        ll rest = h - imos[i] * A;
        ll todo = rest / A + !!(rest % A);
        ll right = x + 2 * D;
        ll j = get_right(right);
        imos[i] += todo;
        imos[j] -= todo;
        ans += todo;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
char s[20],t[20];
int main()
{
	cin>>s;
	cin>>t;
	bool flag=true;
	for(int i=0;i<strlen(s);i++)
	  if(s[i]!=t[i]){ flag=false;break;}
	if(flag)cout<<"Yes"<<endl;
	  else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

int main()
{
  for (int a, b; cin >> a >> b; ) {
    stringstream ss;
    ss << a + b;
    cout << ss.str().length() << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	c := make([]int, N-1)
	s := make([]int, N-1)
	f := make([]int, N-1)
	for i := 0; i < N-1; i++ {
		c[i], s[i], f[i] = getInt(), getInt(), getInt()
	}
	// out(c, s, f)
	for i := 0; i < N-1; i++ {
		t := 0
		for j := i; j < N-1; j++ {
			// out(":", t)
			if t < s[j] {
				t = (s[j]) + c[j]
			} else if t%f[j] == 0 {
				t += c[j]
			} else {
				t += (f[j] - t%f[j]) + c[j]
			}
		}
		out(t)
	}
	out(0)

}


Measured memory_bytes: 640
N = int(input())
S = list(input())

E_left = 0
W_left = 0
E_right = 0
W_right = 0

count_list = []

for i in range(N):
    if i == 0:
        E_right = S[i+1:].count('E')
        W_right = S[i+1:].count('W')
        count = E_right
        count_list.append(count)
    elif 1 <= i <= N-1:
        if S[i] == 'E':
            E_right -= 1
        if S[i] == 'W':
            W_right -= 1
        if S[i-1] == 'E':
            E_left += 1
        if S[i-1] == 'W':
            W_left += 1
        count = E_right + W_left
        count_list.append(count)


ans = min(count_list)
print(ans)
#print(count_list)
#print(E_right, E_left)
#print(W_right, W_left)


Measured memory_bytes: 21072
from collections import defaultdict
S = input()
dict = defaultdict(int)
for s in S:
    dict[s] += 1

if len(dict.keys()) == 1:
    print(0)
    exit()

ans = 101
for c in dict.keys():
    T = S[:]
    TN = []
    flag = True
    check = True
    cnt = 0
    while check:
        for i in range(len(T)-1):
            if c == T[i] or c == T[i+1]:
                TN.append(c)
            else:
                TN.append(T[i])
                flag = False
        cnt += 1
        if flag:
            break

        T = TN[:]
        TN = []
        flag = True
    if cnt < ans:
        ans = cnt
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 500005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";


ll dp[300005];

const ll N = 600005;  // limit for array size
ll n = 600005;  // array size
ll t[2 * N];

void build() {  // build the tree
  for (ll i = n - 1; i > 0; --i) t[i] = max(t[i<<1] , t[i<<1|1]);
}

void modify(ll p, ll value) {  // set value at position p
  for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = max(t[p] , t[p^1]);
}

ll query(ll l, ll r) {  // sum on llerval [l, r)
  ll res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = max(res, t[l++]);
    if (r&1) res = max(res, t[--r]);
  }
  return res;
}

int main() {
    #ifndef ONLINE_JUDGE  
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    ll n,k;
    cin>>n>>k;
    build();
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<n;i++) a[i]++;

    for(ll i=0;i<n;i++) {
        dp[i] = query(max(0LL, a[i]-k), a[i]+k+1) + 1;
        modify(a[i], dp[i]);
    }
    cout<<*max_element(dp, dp+300003)<<endl;
}

Measured memory_bytes: 14944
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, c, d, x, y;
  cin >> a >> b >> c >> d;
  
  long long mx = a*c;
  mx = max(mx, a*d);
  mx = max(mx, b*c);
  mx = max(mx, b*d);
  
  if (mx < 0){
    if ( b >= 0 && d>= 0) mx = 0;
  }
  
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
int main() {
  long long ans=0;
  int n,m,a;
  cin >> n >> m;
  priority_queue<int> q;
  for(int i=0; i<n; i++) {
    cin >> a;
    q.push(a);
  }
  for(int i=0; i<m; i++) {
    q.push(q.top()/2);
    q.pop();
  }
  while(q.size()) {
    ans+=q.top();
    q.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(){
  string a;
  string b;
  cin>>a>>b;
  string ans="";
  
  if(a[0]==b[2] && a[2]==b[0] && a[1]==b[1]){
    ans="YES";
  }else{
    ans="NO";
  }
  cout<<ans<<endl;
}

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


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a=0,b=0, f=0;
    ll sum=0;
    FOR(i,0,n){
      string s;
      cin>>s;
      FOR(i,1,s.size()){
        if(s[i-1] == 'A' && s[i] == 'B') sum++;
      }
      if(s[0] == 'B') b++;
      if(s[s.size()-1] == 'A') a++;
      if(s[0] == 'B' && s[s.size()-1] == 'A')f++;
    }
    if(f == b && f == a && f!=0) sum--;
    cout<<min(a,b) + sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int n;
    cin >> n;
    vector<ll> pvec;
    vector<ll> nvec;
    for (int i = 1; i <= n; i++) {
        ll x, y;
        cin >> x >> y;
        pvec.push_back(x + y);
        nvec.push_back(y - x);
    }
    sort(pvec.begin(), pvec.end());
    sort(nvec.begin(), nvec.end());
    cout << max(pvec[n - 1] - pvec[0], nvec[n - 1] - nvec[0]) << endl;
    return 0;
}

Measured memory_bytes: 6640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
  int H, W;
  string str;
  
  cin >> H >> W;
  
  vector<vector<char>> data(H, vector<char>(W));
  vector<vector<int>> cnt(H + 2, vector<int>(W + 2));  
  
  for(int i = 0; i < H; i++){
    cin >> str;
    for(int j = 0; j < W; j++){
      data.at(i).at(j) = str.at(j);
      if(data.at(i).at(j) == '#') {
        for(int k = 0; k < 3; k++) {
          for(int l = 0; l < 3; l++) {
            cnt.at(i + k).at(j + l)++;
          }
        }
      }
    }
  }
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(data.at(i).at(j) == '.') cout << cnt.at(i + 1).at(j + 1);
      else cout << '#';
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int INF = INT_MAX/10;

struct state {
	int s, c;
	state(int s, int c) : s(s), c(c) {};
	bool operator<(const state other)const {
		return c>other.c;
	}
};

int main() {
	int n, m;
	while(cin >> n >> m, n) {
		int a, b, c, t;
		vector<vvi> data(2, vvi(m, vi(m, INF)));
		REP(i, n) {
			cin >> a >> b >> c >> t;
			data[0][a-1][b-1] = c;
			data[0][b-1][a-1] = c;
			data[1][a-1][b-1] = t;
			data[1][b-1][a-1] = t;
		}
		
		int k;
		cin >> k;
		REP(i, k) {
			int p, q, r;
			cin >> p >> q >> r;

			priority_queue<state> Q;
			Q.push(state(p-1, 0));
			vi cost(n, INF);
			cost[p-1] = 0;
			while(!Q.empty()) {
				state st = Q.top();
				Q.pop();
				if(st.s == q-1) {
					cost[q-1] = min(cost[q-1], st.c);
					continue;
				}
				REP(j, m) {
					if(st.s != j && data[r][st.s][j] != INF) {
						int ncost = st.c + data[r][st.s][j];
						if(ncost < cost[j]) {
							cost[j] = ncost;
							Q.push(state(j, ncost));
						}
					}
				}
			}
			cout << cost[q-1] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1348
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 200010
using namespace std;
char str[N];
int f[N],p[N][26];
int main()
{
	scanf("%s",str);
	int n=strlen(str);
	for(int i=0;i<26;i++) p[n][i]=n;
	f[n]=1;
	for(int i=n-1;i>=0;i--)
	{
		for(int j=0;j<26;j++) p[i][j]=p[i+1][j];
		p[i][str[i]-'a']=i;
		f[i]=n+1;
		for(int j=0;j<26;j++) f[i]=min(f[i],f[p[i][j]+1]+1);
	}
	int m=f[0],u=0;
	while(m--)
	{
		for(int j=0;j<26;j++)if(f[p[u][j]+1]+1==f[u])
		{
			putchar('a'+j);
			u=p[u][j]+1;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 21632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int c = in.nextInt();
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
        }
        int[][] a = new int[n][m];
        int count = 0;
        int point = 0;
        for (int i = 0; i < n; i++) {
            point = 0;
            for (int j = 0; j < m; j++) {
                point += in.nextInt() * b[j];
            }
            point += c;
            if (point > 0) count++;
        }
        in.close();
        System.out.println(count);
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ios();
    int h, w;
    cin >> h >> w;

    vector<vector<char>> grid(h, vector<char>(w));
    for(auto& i : grid){
        for(auto& j : i) cin >> j;
    }

    vector<vector<bool>> flag(h, vector<bool>(w, false));
    vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

    int ans = 0;
    typedef tuple<int,int,int> tp;
    queue<tp> que;
    REP(i, h){
        REP(j, w){
            if(grid[i][j] == '#'){
                flag[i][j] = true;
                REP(k, 4){
                    int xx = i+dx[k], yy = j+dy[k];
                    if(xx < 0 || xx >= h || yy < 0 || yy >= w){
                        continue;
                    }
                    if(grid[xx][yy] == '#' || flag[xx][yy]) continue;
                    que.push(make_tuple(xx, yy, 1));
                    flag[xx][yy] = true;
                }
            }
        }
    }
    while(!que.empty()){
        tp t = que.front();
        que.pop();
        int x = get<0>(t), y = get<1>(t), l = get<2>(t);
        chmax(ans, l);
        REP(i, 4){
            int xx = x + dx[i], yy = y + dy[i];
            if(xx < 0 || xx >= h || yy < 0 || yy >= w){
                continue;
            }
            if(flag[xx][yy]) continue;
            que.push(make_tuple(xx, yy, l+1));
            flag[xx][yy] = true;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7552
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 99999999

using namespace std;


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




ll m = 1000000007;

long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans *= i;
	}
	for (int i = 1; i <= r; i++) {
		ans /= i;
	}
	return ans;
}

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll sum[100010];
int main()
{
	map<ll, int>mp;
	int N, M;
	cin >> N >> M;
	sum[0] = 0;
	mp[0]++;
	REP(i, N) {
		ll a;
		cin >> a;
		sum[i + 1] = sum[i] + a % M;
		sum[i + 1] = sum[i + 1] % M;
		mp[sum[i + 1]]++;
	}
	ll ans = 0;
	for (auto a : mp) {
		int p = a.second;
		if (p >= 2) {
			ans += nCr(p, 2);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
n,m = (int(i) for i in input().split())
e = sorted([[int(i)-1 for i in input().split()] for i in range(m)])

g = [[0 for i in range(n)] for j in range(n)]
for x in e:
    g[x[0]][x[1]] = 1
    g[x[1]][x[0]] = 1

import copy
count = 0
def f(idx, arr):
    used = copy.copy(arr)
    global count
    used[idx] = 1
    if used.count(0) == 0:
        count += 1

    for i, x in enumerate(g[idx]):
        if x==1 and used[i]==0:
            f(i, used)

used = [0]*n
f(0, used)

print(count)


Measured memory_bytes: 3568
$Base = gets.chomp
 
$table = ["A","C","G","T"]
$ans = 0

def include_ATCG?(c)
	flag = false
  
  	$table.each do |b|
      if b == c
        flag = true
      end
    end
      
    return flag
end

def get_length_of_ATCG(str)
  cnt = 0
	str.chars do |c|
		if include_ATCG?(c)
			cnt += 1
		else
 			break
    	end
  	end
	return cnt
end

$Base.length.times do |i|
  $ans = [get_length_of_ATCG($Base[i..$Base.length-1]), $ans].max
end

puts $ans

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

using namespace std;

typedef pair<double, double> P;

vector<P> rec(vector<double> w){
    if(w.size() == 0) return vector<P>(); 
    if(w.size() == 1) return vector<P>(1, P(0, 0));
    int n = w.size();
    vector<P> res;
    for(int s = 0; s < (1 << n); s++){
        vector<double> w1, w2;
        double s1 = 0, s2 = 0;
        for(int i = 0; i < n; i++){
            if(s >> i & 1){
                s1 += w[i];
                w1.push_back(w[i]);
            }else{
                s2 += w[i];
                w2.push_back(w[i]);
            }
        }
        if(s1 == 0 || s2 == 0) continue;
        vector<P> pv1 = rec(w1);
        vector<P> pv2 = rec(w2);
        double lx = -s2 / (s1 + s2);
        double rx = s1 / (s1 + s2);
        for(int i = 0; i < pv1.size(); i++)
        for(int j = 0; j < pv2.size(); j++){
            res.push_back( make_pair( min(pv1[i].first + lx, pv2[j].first + rx), max(pv1[i].second + lx, pv2[j].second + rx) ));
        }
    }
    return res;
}

int main(){
    int T;
    cin >> T;
    while(T--){
        double r;
        cin >> r;
        int n;
        cin >> n;
        vector<double> w(n);
        REP(i, n) cin >> w[i];
        vector<P> pv = rec(w);
        vector<double> cand;
        for(int i = 0; i < pv.size(); i++){
            cand.push_back(pv[i].second - pv[i].first);
        }
        sort(cand.begin(), cand.end());

        int k = upper_bound(cand.begin(), cand.end(), r) - cand.begin();
        if(k == 0 || cand.empty()){
            cout << -1 << endl;
        }else{
            printf("%.16f\n", cand[k - 1]);
        }
    }
    return 0;
}

Measured memory_bytes: 2224
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, k;
	cin >> n >> k;
	vector <ll> A(n + 1);
	for (int i = 1; i <= n; i++) {
		A[0] += (n / i);
		A[i] -= (n / i);
		if(n % i != 0) {
			A[1] += 1;
			A[n % i + 1] -= 1;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		if(i > 0)
			A[i] += A[i - 1];
		if(i >= k) {
			ans += A[i];
		}
	}
	cout << ans;
}


Measured memory_bytes: 1024
n = int(input())
import math
primes = [2]
for i in range(3, math.ceil(math.sqrt(2*n+1))):
  for prime in primes:
    if i % prime == 0:
      break
  else:
    primes.append(i)
    if i >= n:
      break
for i in range(n, 2*n+1):
  if i in primes:
    print(i)
    break
  else:
    for prime in primes:
      if i % prime == 0:
        break
    else:
      print(i)
      break

Measured memory_bytes: 3064
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

void solve() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("input.txt", "r", stdin);
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


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

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());

		String[] temp = scanner.nextLine().split(" ");
		int[] list = new int[n];
		double ans = 0;
		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(temp[i]);
		}

		Arrays.sort(list);


		ans = (list[0] + list[1]) / 2.0;


		for(int i = 2; i < n; i++) {

			ans = (ans + list[i]) / 2;

		}



		System.out.println(ans);







	}



}

Measured memory_bytes: 23636
n,*t=map(int,open(0).read().split())
*z,=zip(t[::2],t[1::2])
m=1e18
for ax,ay in z:
  for bx,by in z:
    p,q=bx-ax,by-ay
    if not p+q:continue
    t=0
    for cx,cy in z:
      for dx,dy in z:
        if dx+p==cx and dy+q==cy:break
      else:t+=1
    if t<m:m=t
print(+(m>1e17)or m)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[100001];
		for(int i=0;i<n;i++){
			a[sc.nextInt()]++; 
		}
		int max = 0;
		for(int i=0;i<99999;i++){
			max = (int)Math.max(max, a[i] + a[i+1] + a[i+2]);
		}

		System.out.println(max);
	}
}


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

using namespace std;

#define ll long long




void solve() {

	int a, b;
	cin >> a >> b;
	int ans = a - 2 * b;
	if(ans <= 0) {
		cout << 0;
	}
	else {
		cout << ans;
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3616
while True:
    a, op, b = input().split()
    if op == '?':
        break
    a, b = int(a), int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(int(a // b))


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>

int main(){
//	int tc=3;
	char angka[1000];
	int counter=0;
	
//	for(int i=1;i<=tc;i++){
		counter=0;
		scanf("%s",&angka);
		for(int j=0;j<=strlen(angka)/2-1;j++){
			if(angka[j]==angka[strlen(angka)-j-1]){
				counter++;	
			}
		}
		if(counter==strlen(angka)/2){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
//	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string a,b;std::cin>>a>>b;
    std::cout<<(a.length()!=b.length()
        ?(a.length()>b.length()?"GREATER":a.length()==b.length()?"EQUAL":"LESS")
        :a>b?"GREATER":a==b?"EQUAL":"LESS")<<'\n';
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		String op;
		int a,b;
		while(true){
			a=scan.nextInt();
			op=scan.next();
			b=scan.nextInt();
			if(op.equals("?")) break;
			else if(op.equals("+")) System.out.println(a+b);
			else if(op.equals("-")) System.out.println(a-b);
			else if(op.equals("*")) System.out.println(a*b);
			else System.out.println(a/b);
		}
		scan.close();
	}
}

Measured memory_bytes: 18008
#ifdef debug
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define vec vector
#define ALL(x) (x).begin(), (x).end()

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

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    int n;

    cin >> n;

    vec< int > a(n + 2);

    int tot = 0;

    for(int i = 1;i <= n;i++) {
        cin >> a[i];
    }

    for(int i = 1;i < (int)a.size();i++) {
        tot += abs(a[i] - a[i - 1]);
    }

    for(int i = 1;i <= n;i++) {
        int tmp = tot;
        tmp -= abs(a[i] - a[i - 1]);
        tmp -= abs(a[i] - a[i + 1]);
        tmp += abs(a[i - 1] - a[i + 1]);
        cout << tmp << "\n";
    }

    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

#define SENTINEL 1000000000
#define MAX 500000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int L[MAX/2+1];
int R[MAX/2+1];
int count=0;

int main()
{
    int i,n;
    int S[MAX];

    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&S[i]);
    }
    mergeSort(S,0,n);

    for(i=0;i<n;i++)
    {
        if(i>0)printf(" ");
        printf("%d",S[i]);
    }
    printf("\n");
    printf("%d\n",count);
    return 0;
}

void mergeSort(int*S,int left,int right)
{
    if(left+1<right)
    {
        int mid;
        mid = (left + right)/2;
        mergeSort(S,left,mid);
        mergeSort(S,mid,right);
        merge(S,left,mid,right);
    }
}

void merge(int*S,int left,int mid,int right)
{
    int i,j,k;
    int n1=mid-left;
    int n2=right-mid;
    for(i=0;i<n1;i++)
    {
        L[i]=S[left+i];
    }
    for(i=0;i<n2;i++)
    {
        R[i]=S[mid+i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    i=0;
    j=0;

    for(k=left; k<right; k++)
    {
        count++;
        if(L[i]<=R[j])
        {
            S[k] = L[i];
            i=i+1;
        }
        else {
            S[k] = R[j];
            j=j+1;
        }
    }
}


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

using namespace std;
int a[55];
long long int dp[55][2];
int main()
{
    int N,p;
    scanf("%d%d",&N,&p);

    for(int i=1;i<=N;i++)
        scanf("%d",&a[i]);

    dp[0][0]=1;

    for(int i=1;i<=N;i++){
        if(a[i]%2==0){
            dp[i][0]=dp[i-1][0]+dp[i-1][0];
            dp[i][1]=dp[i-1][1]+dp[i-1][1];
        }
        if(a[i]%2==1){
            dp[i][0]=dp[i-1][0]+dp[i-1][1];
            dp[i][1]=dp[i-1][1]+dp[i-1][0];
        }
    }

    printf("%lld",dp[N][p]);
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (n, k) = readLine()!!.split(" ").map { it.toInt() }
  val board = Array(2 * k, { IntArray(2 * k) })

  repeat(n) {
    val (xString, yString, c) = readLine()!!.split(" ")
    val x = xString.toInt()
    val y = yString.toInt()
    if (c == "B") {
      board[y % (2 * k)][x % (2 * k)]++
    } else {
      board[y % (2 * k)][(x + k) % (2 * k)]++
    }
  }
  // board.forEach { println(it.asList()) }

  val acc = Array(2 * k + 1, { IntArray(2 * k + 1 )})
  acc[0][0] = board[0][0]
  for (y in 1 until 2 * k + 1) {
    for (x in 1 until 2 * k + 1) {
      acc[y][x] = acc[y][x - 1] + acc[y - 1][x] - acc[y - 1][x - 1] + board[y - 1][x - 1]
    }
  }
  // acc.forEach { println(it.asList()) }

  fun getRectangle(ix: Int, iy: Int, ex: Int, ey: Int): Int =
      acc[ey][ex] - acc[ey][ix] - acc[iy][ex] + acc[iy][ix]

  var max = 0
  for (iy in 0 until k) {
    for (ix in 0 until 2 * k) {
      if (ix < k) {
        var count = 0
        count += getRectangle(0, 0, ix, iy)
        count += getRectangle(0, iy + k, ix, 2 * k)
        count += getRectangle(ix, iy, ix + k, iy + k)
        count += getRectangle(ix + k, 0, 2 * k, iy)
        count += getRectangle(ix + k, iy + k, 2 * k, 2 * k)
        max = Math.max(max, count)
      } else {
        var count = 0
        count += getRectangle(0, iy, ix - k, iy + k)
        count += getRectangle(ix - k, 0, ix, iy)
        count += getRectangle(ix - k, iy + k, ix, 2 * k)
        count += getRectangle(ix, iy, 2 * k, iy + k)
        max = Math.max(max, count)
      }
    }
  }
  println(max)
}


Measured memory_bytes: 107368
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int count = 0;
    for(int i = 1;i <= n;i++)
    {
        if(i % 2 == 1)
        count++;
    }
    cout << count / double(n);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int n,k;
	cin>>n>>k;
	int w[n+5],v[n+5];
	for(int i=1; i<=n; i++) cin>>w[i]>>v[i];
	int dp[n+5][100005]; //minimum weight needed to make value
	//cout<<"WOOP"<<endl;
	fill( &dp[0][0], &dp[0][0] + sizeof(dp)/sizeof(dp[0][0]) , (int) 2e11);
	//cout<<"YEET"<<endl;
	dp[0][0] = 0;
	for(int i=1; i<=n; i++){
		for(int j=100004; j>=0; j--){
			dp[i][j] = dp[i-1][j];
			if(j!=100004) dp[i][j] = min(dp[i][j], dp[i][j+1]);
			if(j>=v[i]) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
		}
	}
	for(int j=100004; j>=0; j--){
		if(dp[n][j]<=k){ cout<<j; return 0;}
	}
}

Measured memory_bytes: 82432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int targetMoney = Integer.parseInt(br.readLine());
            int oneYenCoin = Integer.parseInt(br.readLine());

            String result = "No";
            if (targetMoney % 500 <= oneYenCoin) {
                result = "Yes";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22356
#include<stdio.h>
#include<math.h>

using namespace std;

double dDISTANCE(const double &x, const double &y, const double &x1, const double &y1, const double &x2, const double &y2){    //点(x, y)と直線の距離
    double a, b, c;    //直線をax+by+c=0 の形式で書く  
    a = y2 - y1;
    b = x2 - x1;
    c = x2 * y1 - x1 * y2;
    return fabs(a * x - b * y + c) / sqrt(a * a + b * b);
}

int iSgn(const double &x, const double &y, const double &x1, const double &y1, const double &x2, const double &y2){    //点(x,y)が直線の正領域か負領域か判定
    if ( (y2 - y1) * x - (x2 - x1) * y + x2 * y1 - x1 * y2 >= 0 ){
        return 1;
    } else {
        return -1;
    }
}

double dNORM(const double &x, const double &y){
    return sqrt(x * x + y * y);
}

void swap(double &a, double &b){
    double iTmp = a;
    a = b; 
    b = iTmp;
}

int main(){
    const double dTolerance = 1.0e-10;
    double cx,cy,r;
    scanf("%lf %lf %lf", &cx, &cy, &r);
    int q;
    scanf("%d", &q);
    
    for (int i = 0; i < q; i++){
        double x1,x2,y1,y2;
        scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
        double dLineDist = dDISTANCE(cx, cy, x1, y1, x2, y2);    //点と直線の距離
        double dDist = dNORM(x2 - x1, y2 - y1);    //点と点の距離
        double px,py;    //射影
        px = cx - (double)iSgn(cx, cy, x1, y1, x2, y2) * (y2 - y1) * dLineDist / dDist;
        py = cy - (double)iSgn(cx, cy, x1, y1, x2, y2) * (x1 - x2) * dLineDist / dDist;

        if (fabs(r - dLineDist) < dTolerance){
            printf("%lf %lf %lf %lf\n", px, py, px, py);
        } else {
            if (x1 - x2 >= dTolerance){
                swap(x1,x2);
                swap(y1,y2);
            } 
            if (fabs(x1 - x2) < dTolerance && y1 - y2 >= dTolerance){
                swap(x1,x2);
                swap(y1,y2);
            }
            double ax1 = px - (x2 - x1) * sqrt(r * r - dLineDist * dLineDist) / dDist;
            double ay1 = py - (y2 - y1) * sqrt(r * r - dLineDist * dLineDist) / dDist;
            double ax2 = px + (x2 - x1) * sqrt(r * r - dLineDist * dLineDist) / dDist;
            double ay2 = py + (y2 - y1) * sqrt(r * r - dLineDist * dLineDist) / dDist;
            printf("%lf %lf %lf %lf\n", ax1, ay1, ax2, ay2);
        }
    }
    return 0;
}


Measured memory_bytes: 2756
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

a,b=map(int, input().split())
c=list(map(int, input().split()))
c = c + [b]
d = sorted(c)
l = []

for i in range(a):
    l += [d[i+1] - d[i]]

f=gcd_list(l)
print(f)

Measured memory_bytes: 20412
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,n,be,af;
  be = 4280;
  while(1){
    cin >> n;
    if(n == -1) break;

    af = 1150;
    if(n > 10 && n <= 20) af += (n - 10) * 125;
    else if(n > 20) af += 10 * 125;
    if(n > 20 && n <= 30) af += (n - 20) * 140;
    else if(n > 30) af += 10 * 140;
    if(n > 30) af += (n - 30) * 160;
    
    cout << be - af << endl;
    
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M,X;
    cin>>N>>M>>X;
    vector<vector<int>> A(N,vector<int>(M));
    vector<int> C(N);
    REP(i,N){
        cin>>C[i];
        REP(j,M) cin>>A[i][j];
    }
    constexpr int inf = 1e9;
    int ans = inf;
    REP(bit, 1<<N){
        vector<int> pts(M);
        int tmp=0;
        REP(i,N) if(bit>>i&1){
            tmp +=C[i];
            REP(j,M) pts[j] += A[i][j];
        }
        bool ok = true;
        REP(i,M) if(pts[i]<X) ok = false;
        if(ok) ans = min(ans, tmp);
    }
    if(ans == inf) cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let n: i64 = read();
    let m: usize = read();
    let mut a: Vec<i64> = vec![0; m];
    for i in 0..m {
        a[i] = read();
    }
    let mut sum: i64 = 0;
    for &a_one in a.iter() {
        sum += a_one;
    }
    let res = n - sum;
    if res < 0 {
        println!("{}", -1);
    } else {
        println!("{}", res);
    }
}


Measured memory_bytes: 2112
#include<cstdio>
#include<cmath>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define LC(a) (a<<1)
#define RC(a) (a<<1|1)
#define MID(a,b) ((a+b)>>1)
#define fin(name)  freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i,start,end) for(int i=start;i<=end;i++)  
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long LL;
const int N=5e4+5;

int main(){
	int A,B,C,D,E,F;
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	double lim=E/100.0,ans=-1;
	int x=0,y=0;
	//±©Á¦Ã¶¾Ù,×¢ÒâÌÇË®Å¨¶ÈÎª0µÄÇé¿ö 
	for(int i=0;i*A*100<=F;i++){
		for(int j=0;i*A*100+j*B*100<=F;j++){
			for(int k=0;k*C<=1.0*F/100*E;k++){
				for(int p=0;k*C+p*D<=1.0*F/100*E;p++){
					if(i==0&&j==0&&k==0&&p==0)
						continue;
					if(i*A*100+j*B*100+k*C+p*D>F||i==0&&j==0)
						continue;
					double rate=(k*C+p*D)/(1.0*i*A*100+j*B*100);
					if(rate<=lim&&ans<rate){
						ans=rate;
						x=i*A*100+j*B*100;
						y=k*C+p*D;
					}
						
				}
			}
		}
	}
	printf("%d %d\n",x+y,y);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int a,b,c;

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

if (a<=b&&b<=c)
printf("%d %d %d\n",a,b,c);

else if(b<=a&&a<=c)
printf("%d %d %d\n",b,a,c);

else if(c<=a&&a<=b)
printf("%d %d %d\n",c,a,b);

else if(b<=c&&c<=a)
printf("%d %d %d\n",b,c,a);

else if(a<=c&&c<=b)
printf("%d %d %d\n",a,c,b);

else 
printf("%d %d %d\n",c,b,a);


return 0;
}

Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n;
	scanf("%d", &n);
	vi d(n);
	for (int i = 0; i < n; i++) scanf("%d", &d[i]);
	sort(all(d));
	int m = n / 2;
	printf("%d\n", d[m] - d[m-1]);
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
#  0 : 未定
#  1 : 増加
# -1 : 減少
res = 0

prv = a[0]
cond = 0
for i in a:
    if cond == 0:
        if prv > i:
            cond = -1
        elif prv < i:
            cond = 1
    elif cond == 1:
        if prv > i:
            cond = 0
            res += 1
    else:
        if prv < i:
            cond = 0
            res += 1
    prv = i

print(res + 1)


Measured memory_bytes: 14224
import collections
S = input()
L = []
M = []
c = collections.Counter(S)
for x in c.items():
    L.append(x[1])
T = input()
c = collections.Counter(T)
for x in c.items():
    M.append(x[1])
if sorted(M) == sorted(L):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4136
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int a, b;

int main() {
  cin >> a >> b;
  if (a > 0) {
    cout << "Positive" << "\n";
    return 0;
  }
  if (a <= 0 and 0 <= b) {
    cout << "Zero" << "\n";
    return 0;
  }
  if (a < 0 and b < 0) {
    if ((abs(a) - abs(b) + 1) % 2 == 1) {
      cout << "Negative" << "\n";
    } else {
      cout << "Positive" << "\n";
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m;
    cin>>n>>m;
    if(m+n==15)
    {
        cout<<"+"<<NL;
    }
    else if(m*n==15)
    {
        cout<<"*"<<NL;
    }
    else
    {
        cout<<"x"<<NL;
    }
    return 0;
}



Measured memory_bytes: 256
package main
import "fmt"
const mod int64 = 1000000007
func main() {
  var n,m,k,s int64
  fmt.Scan(&n,&m,&k)
  initlz(n*m)
  s = (((((m*m)%mod)*((((n-1)*n*(n+1))/6)%mod))%mod+
        (((n*n)%mod)*((((m-1)*m*(m+1))/6)%mod))%mod)*comb(n*m-2,k-2))%mod
  fmt.Println(s)
}

const size int = 50
var f []int64
var invf []int64
func initlz(n int64) {
  f = make([]int64,n+1)
  invf = make([]int64,n+1)
  f[0] = 1
  invf[0] = 1
  for i:=int64(1);i<n+1;i++ {
    f[i] = (f[i-1]*(i%mod))%mod
    invf[i] = inv(f[i])
  }
}
func comb(n,k int64) int64 {
  if k < 0 || k > n { return 0 }
  if n == 0 && k == 0 { return 1 }
  if n == 0 { return 0 }
  return (f[n]*((invf[k]*invf[n-k])%mod))%mod
}
func inv(n int64) int64 {
  if n == 1 { return 1 }
  k := make([]int64,size)
  a,b,u := mod,n,size
  for i:=0;i<size;i++ {
    k[i],a,b = a/b,b,a%b
    if b == 0 { u = i;break }
  }
  var y0,y1 int64 = 1,-k[0]
  for i:=1;i<u;i++ { y0,y1 = y1,y0-k[i]*y1 }
  for y1 < 0 { y1 += mod }
  return y1%mod
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
*/

using namespace std;
#define m 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define make_pair mp
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    int count=0;
    vector<int> temp;
    vector<vector<int> > arr;
    vector<int> e(h,0);
    vector<int> f(w,0);
    int c1=0,c2=0,c3=0,c4=0;
    rep(i,0,h){
        temp.clear();
        c1=0;
        rep(j,0,w){
            char x;
            cin>>x;
            if(x=='.')
            temp.pb(0);
            else{
                c1++;
                temp.pb(1);
                count++;
            }
        }
        e[i]=c1;
        arr.pb(temp);
    }
    
    rep(i,0,w){
        rep(j,0,h){
            if(arr[j][i]==1)
            ++c2;
        }
        f[i]=c2;
        c2=0;
    }
   
    int b=count-k;
    int r=0;
    int c=pow(2,h)+0.5;
    --c;
    int d=pow(2,w)+0.5;
    --d;
    vector<int> flag(6,0);
    vector<int> temp1;
   
    int g=0;
    for(int i=0;i<c;++i){
        g=0;
        int temp2=i;
        temp1.clear();
        /*rep(i,0,6)
        flag[i]=0;*/
         int q=0;
        while(temp2!=0){
            if(temp2%2==1)
            {temp1.pb(q);
            //flag[q]=1;
            g+=e[q];
            }
            ++q;
            temp2/=2;
        }
        // cout<<"hi"<<endl;
        for(int j=0;j<d;++j){
            int temp3=j;
             q=0;
            int sum=g;
            while(temp3!=0){
                if(temp3%2==1){
                    sum+=f[q];
                   // cout<<"hi"<<endl;
                    rep(i,0,(int)temp1.size()){
                        if(arr[temp1[i]][q]==1)
                        sum--;
                       // cout<<"hi"<<endl;
                    }
                }
                ++q;
                temp3/=2;
            }
            if(sum==b)
            ++r;
        }
    }
    cout<<r<<endl;
}



Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

typedef long long ll;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int> > data(M);
    vector<vector<int> > P(N);
    REP(i, M) {
        int p, y;
        cin >> p >> y;
        p--;
        data[i].first = p;
        data[i].second = y;
        P[p].push_back(y);
    }
    
    REP(i, N) {
        sort(P[i].begin(), P[i].end());
    }

    stringstream ss;
    REP(i, M) {
        int p = data[i].first;
        int y = data[i].second;
        int index = distance(P[p].begin(), lower_bound(P[p].begin(), P[p].end(), y));
        ss << setw(12) << setfill('0') << ll(p+1) * 1000000 + index + 1;
        cout << ss.str() << endl;
        ss.str("");
        ss.clear(stringstream::goodbit);
        //printf("%012d\n", 1000000ll * (p+1) + index+1);
    }
    
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 7808
from collections import deque

n, m = list(map(int, input().split()))
li = []
for _ in range(m):
    li.append(list(map(int, input().split())))

ans = 0
for k in range(len(li)):
    li0 = li[:k] + li[k + 1:]
    # construct indirectional graphs
    edges = [[] for _ in range(n)]
    for i, j in li0:
        i -= 1
        j -= 1
        edges[i].append(j)
        edges[j].append(i)
    # check bridge
    S = deque()
    S.append(0)
    visited = set()
    while len(S) > 0:
        u = S.pop()
        visited.add(u)
        for v in edges[u]:
            if v not in visited:
                S.append(v)
    if len(visited) < n:
        ans += 1


print(ans)

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

using namespace std;

vector<int> parent;
vector <int> ranks;

void make_set(int v) {
  parent[v] = v;
  ranks[v] = 0;
}

int find_set(int v) {
  if (v == parent[v]) {
    return v;
  }
  return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (ranks[a] < ranks[b]) {
      swap(a, b);
    }
    parent[b] = a;
    if (ranks[a] == ranks[b]) {
      ranks[a]++;
    }
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  parent.resize(n);
  ranks.resize(n);

  for (int i = 0; i < n; i++) {
    make_set(i);
  } 

  int t, x, y;
  for (int i = 0; i < q; i++) {
    cin >> t >> x >> y;
    if (t == 0) {
      union_sets(x, y);
    } else {
      int a = find_set(x);
      int b = find_set(y);
      if (a == b) {
        cout << "1" << '\n';
      } else {
        cout << "0" << '\n';
      } 
    }
  }
  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main (){
    int n,tmp_max,vote_max,vote_cnt;
    cin >> n;
    vote_max = 0; 
    vote_cnt = 0;
    vector<string> most_voted;
    map<string,int> s;
    string tmp;
    for(int i = 0; i < n; i++){
        tmp = "";
        cin >> tmp;
        if(s.count(tmp) == 1){
 //           cout << s[tmp] << endl;
            s[tmp] =s[tmp] + 1;
   //         cout << s[tmp] << endl;
        }
        else
             s.emplace(tmp,1);
        vote_max = max(vote_max, s[tmp]);
    }
 //   cout << "vote_max " << vote_max << endl;
    for(auto itr = s.begin(); itr != s.end(); ++itr) {
        if(itr->second == vote_max)
        most_voted.push_back(itr->first);
    }
    sort(most_voted.begin(),most_voted.end());
    for(auto itr = most_voted.begin(); itr != most_voted.end(); ++itr) {
        cout << *itr << endl;
    }



    return 0;

}

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

using namespace std;

string t;
int ans = 0;
int main(){
	int n;
	string s;
	cin >> n ;
	char ch[1000];
	for (int i = 0; i < n; ++i){
		cin >> ch[i];
	}
	if(n % 2 != 0){ 
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0 , j = n / 2; i < n / 2 && j < n; j++ && i++){
		if(ch[i] != ch[j]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256