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

using namespace std;

#define MAX 30
#define EPS 1e-9

class Point{
public:
  double x,y,z;
  Point(){}
  Point(double x,double y,double z) : x(x),y(y),z(z) {}
};

double getDistance(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));
}

istream &operator >> (istream &is,Point &p){
  is >> p.x >> p.y >> p.z;
  return is;
}

int main(){
  int N;
  Point point[MAX];
  while(cin >> N, N){
    double x = 0, y = 0, z = 0;
    for(int i = 0 ; i < N ; i++){
      cin >> point[i];
      x += point[i].x;
      y += point[i].y;
      z += point[i].z;
    }
    x /= N; y /= N; z /= N;
    int pos = -1;
    double d = 0.8, ans = 0;
    Point p(x,y,z);
    while(d > EPS){
      for(int i = 0 ; i < 150 ; i++){
        ans = 0;
        for(int j = 0 ; j < N ; j++){
          double dist = getDistance(p,point[j]);
          if(ans < dist){
            ans = dist;
            pos = j;
          }
        }
        p.x += (point[pos].x-p.x)*d;
        p.y += (point[pos].y-p.y)*d;
        p.z += (point[pos].z-p.z)*d;
      }
      d /= 2;
    }
    printf("%.6f\n",ans);
  }
  return 0;
}

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

#define loop(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;
struct __{__(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}__;

int n, m;
vector<vector<int> > g;
vector<int> parent, used;
queue<int> q;
int next_, a, b, child;


int main() {
	cin >> n >> m;
	g.resize(n);
	// cout << "resized g" << "\n";
	for (int i =0 ; i < m; ++i){
		cin >> a >> b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	// cout << "g " << "\n";

	parent.resize(n), used.resize(n);
	fill(used.begin(), used.end(), false);
	fill(parent.begin(), parent.end(), -1);

	q.push(0);
	used[0] = true;

	while (!q.empty()){
		next_ = q.front();
		q.pop();

		loop(i, g[next_].size()){
			child = g[next_][i];
			if (! used[child]){
				used[child] = true;
				q.push(child);
				parent[child] = next_;
			}
		}
	}

	bool flag_connected = true;
	loop(i, n){
		if (!used[i]){
			flag_connected = false;
			break;
		}
	}

	if (flag_connected){
		cout << "Yes" << "\n";
		for (int i =1 ; i<n; ++i){
			cout << parent[i] + 1 << "\n";
		}
	} else {
		cout << "No\n"; 
	}

	return 0;
}

Measured memory_bytes: 10608
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a;
	cin >> b;
	int c[a];
	for(int i=0;i<a;i++) c[i] = i;
	for(int i=0;i<b;i++){
		int d,e;
		char com;
		cin >> d >> com >> e;
		int f = c[d-1];
		c[d-1] = c[e-1];
		c[e-1] = f;
	}
	for(int i=0;i<a;i++) cout << c[i]+1 << endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int L;
vector<pair<pint, int>> edges;
vint actions;
void ac(int l) {
    if (l & 1) { actions.push_back(1), l--; }
    if (l == 2) { return; }
    actions.push_back(0);
    ac(l >> 1);
}
signed main() {
    cin >> L;
    ac(L);
    reverse(all(actions));
    int N = 2, u = 2;
    edges.push_back({{1, 2}, 0});
    edges.push_back({{1, 2}, 1});
    for (int i = 0; i < actions.size(); i++) {
        if (actions[i] == 0) {
            rep(j, edges.size()) { edges[j].second <<= 1; }
            edges.push_back({{N, N + 1}, 0});
            edges.push_back({{N, N + 1}, 1});
            N++;
            u <<= 1;
        } else {
            edges.push_back({{1, N}, u++});
        }
    }
    cout << N << " " << edges.size() << endl;
    rep(i, edges.size()) {
        cout << edges[i].first.first << " " << edges[i].first.second << " " << edges[i].second << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

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

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

    int v[3] = { a, b, c };
    sort(v, v + 3);

    if (v[0] == v[1])
        cout << v[2];
    else if (v[1] == v[2])
        cout << v[0];
}

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

using namespace std;

int n,l,dp[100005],a[100005];

int func(int i){

  if(dp[i]>0)return dp[i];

  int res=0;
  if(a[i]<a[i-1])res=max(res,func(i-1));
  if(a[i]<a[i+1])res=max(res,func(i+1));

  return dp[i]=l-a[i]+res;
}

int main(void){
  int in;
  
  while(cin >> n >> l){
    
    for(int i=0;i<n+2;i++)dp[i]=0;

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

    a[0]=a[n+1]=0;

    int res=0;
    for(int i=1;i<n+1;i++)
      res=max(res,func(i));

    cout << res << endl;
  }
  
  return 0;
}

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

void solve()
{
  int n;
  cin>>n;
  double p[n+1];
  for (int i=1;i<=n;i++)
    cin>>p[i];
  
  double dp[n+1][n+1];
  memset(dp,0.0,sizeof(dp));
  dp[0][0]=1;
  for (int i=1;i<=n;i++)
  {
    for (int j=0;j<=n;j++)
    {
      if (j==0)
        dp[i][j]=(1-p[i])*dp[i-1][j];
      else 
        dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
    }
  }
  double ans=0;
  for (int i=n/2+1;i<=n;i++)
    ans+=dp[n][i];
  cout<<fixed<<setprecision(10)<<ans<<"\n";
}

int main()
{
  int t=1;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 70528
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
const double eps = 1e-10;
#define EQ(a, b) (abs((a) - (b)) < eps)
using P = complex<double>;      // position
struct L : vector<P> {
    L(const P &a = P(), const P &b = P()) {
        emplace_back(a); emplace_back(b);
    }
};
using Polygon = vector<P>;
ostream &operator<<(ostream &os, P p) { return os << real(p) << " " << imag(p); }
double dot(const P &a, const P &b) { return real(conj(a) * b); }
double cross(const P &a, const P &b) { return imag(conj(a) * b); }

enum { OUT, ON, IN };
int contains(const Polygon &ps, const P &p) {
    bool in = false;
    for (int i = 0; i < ps.size(); i++) {
        P a = ps[i] - p, b = ps[(i + 1) % ps.size()] - p;
        if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b) && cross(a, b) < 0) in = !in;
    }
    return in ? IN : OUT;
}

#include <iostream>
int main() {
    int n; cin >> n;
    Polygon ps;
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        ps.emplace_back(x, y);
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int x, y; cin >> x >> y;
        cout << contains(ps, P(x, y)) << endl;
    }
    return 0;
}


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

int main() {
    ll N,K;
    cin >> N >> K;
    cout << min(N%K,K-(N%K)) << endl;   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int cnt=0;
	ll X,Y;
	cin >> X >>Y;
	while(X<=Y){
		if (X<=Y){
			X=X*2;
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
A,B,C = map(int,input().split())

ans = "NO"
for i in range(1,B+1):
    if (A*i)%B == C:
        ans = "YES"
        break

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 5e5;
int a[maxn];
const LL mod = 1e9+7;
int main(){
    LL n,k;
    while(~scanf("%lld%lld",&n,&k)){
        if(k==n+1){
            printf("1\n");
            continue;
        }
        LL all=0;
        for(LL i=k;i<=n+1;i++){
            LL st = (i-1)*i/2;
            LL ed = (n+n-i+1)*i/2;
          //  printf("%lld %lld\n",st,ed);
            all += ed-st+1;
            all%=mod;
        }
        printf("%lld\n",all);


    }
    return 0;
}





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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    VL num(5);
    REP(i, 5) cin >> num[i];
    ll num_min = *min_element(ALL(num));
    cout << 4 + (n + num_min - 1) / num_min << ln;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= h && b[i] >= w) {
                count++;
            }
        }
        System.out.println(count);
    }
}


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

vector<int> to[100005];

int main() {
  int N, M;
  cin >> N >> M;
  rep(i,M) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    to[A].push_back(B);
    to[B].push_back(A);
  }

  queue<int> q;
  vector<int> dist(N,INF); //distance 今回はいらない
  vector<int> pre(N,-1); //直前の頂点prev
  dist[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front(); q.pop();
    for(int u :to[v]) {
      if(dist[u] != INF) continue;
      dist[u] = dist[v]+1;
      pre[u] = v;
      q.push(u); 
    }
  }

  cout << "Yes" << endl;
  rep(i,N) {
    if(i==0) continue;
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 10572
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

// Input string
func scanString() (s string) {
	sc.Scan()
	return sc.Text()
}

func main() {
	input := scanString()
	if input == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}


Measured memory_bytes: 1752
MOD = 10**9+7
n, k = map(int, input().split())

def init_mod_c(lim=10**6, mod=10**9+7):
    fact = [1, 1] + [0] * (lim-1)
    fact_inv = [1, 1] + [0] * (lim-1)
    inv = [0, 1] + [0] * (lim-1)
    
    for i in range(2, lim+1):
        fact[i] = fact[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod

    def mod_c(n, m):
        if n < m or n < 0 or m < 0: return 0
        return fact[n] * (fact_inv[m] * fact_inv[n-m] % mod) % mod

    return mod_c

ans = 1
comb = init_mod_c()
for i in range(1, min(k, n-1)+1):
    ans += comb(n, i) * comb(n-1, i)
    ans %= MOD
print(ans)


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

int n, a[100], Max= 0, Min = INT32_MAX;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		Max = max(Max, a[i]);
		Min = min(Min, a[i]);
	}

	cout << (Max - Min) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict as dic

n = int(input())

data = [0] * 10000000
ans = 0

def judge_753(s):
    judge = 1
    flag = dic(int)
    for i in range(len(s)):
        if s[i] != '7' and s[i] != '5' and s[i] != '3':
            judge = 0
            break
        else:
            flag[int(s[i])] = 1

    if flag[3] != 1 or flag[5] != 1 or flag[7] != 1:
        judge = 0
    return judge

def search_num(num):
    ret = 0
    if num > n:
        return 0
    
    if judge_753(str(num)) == 1:
        ret += 1
    
    ret += search_num(num * 10 + 3) + search_num(num * 10 + 5) + search_num(num * 10 + 7)
    return ret


print(search_num(0))

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

int main(){
  int n;
  cin >> n;
  string x,a,b;
  cin >> x;
  a = x.substr(0, n);//この表記は重要
  b = x.substr(n, n);//
  long long ans = 0;
  map<pair<string, string>, long long > ma;
  for(int i = 0 ; i < (1<<n) ; i++){
    string red = "", blue = "";
    for(int j = 0; j < n; j++){
      if(i & (1 << j)) red += b[j];
      else blue += b[j];
    }
    reverse(red.begin(), red.end());
    reverse(blue.begin(), blue.end());
    auto p = make_pair(red, blue); //autoについて要調査
    ma[p]++;
  }

  for(int i = 0; i < (1 << n); i++){
    string red = "", blue = "";
    for(int j = 0 ; j < n; j++){
      if(i & (1 << j)) red += a[j];
      else blue += a[j];
    }
    auto p = make_pair(red, blue);
    ans += ma[p];
  }

  cout << ans << endl;
}


Measured memory_bytes: 87040
#include <iostream>
#include <cmath>

#include <vector>
#include <algorithm>
#include <limits>
#include <unordered_set>
#include <array>
#include <queue>

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> aj(n);
    long base = pow(10, 9) + 7;
    aj[n-1] = a[n-1] % base;
    for (int i = n-2; i >= 0; --i) {
        aj[i] = (aj[i+1] + (a[i] % base)) % base;
    }

    long answer = 0;
    for (int i = 0; i < n - 1; ++i) {
        answer = (answer + (((a[i] % base) * aj[i+1]) % base)) % base;
    }
    cout << answer << endl;
}


Measured memory_bytes: 4836
n, s = map(int, input().split())
a = list(map(int, input().split()))

dp = [[1 if _2 == 0 else 0 for _2 in range(s + 1)] for _1 in range(n+1)]

MOD = 998244353

for i, ai in enumerate(a):
  for j, v in enumerate(dp[i]):
    dp[i + 1][j] += v
    dp[i + 1][j] %= MOD 
    if j + ai <= s:
      dp[i + 1][j + ai] += v
      dp[i + 1][j + ai] %= MOD


print(sum(dp_i[s] for dp_i in dp) % MOD)
    

Measured memory_bytes: 120156
#https://atcoder.jp/contests/abc065/submissions/5881131
import sys
input = sys.stdin.readline
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

def MST(n, E):
    E = sorted(E, key=lambda x: x[2])
    uf = UnionFind(n)
    ct = 0
    for i,j,cost in E:
      if uf.same_check(i,j):
        continue
      else:
        uf.union(i,j)
        ct += cost
    return ct
  
def solve():
  N = int(input())
  X = []
  append=X.append
  for i in range(N):
    x, y = map(int, input().split())
    append((i, x, y))
 
  F = []
  append = F.append
  Y = sorted(X, key = lambda x: x[1])
  for i in range(len(Y)-1):
    append((Y[i][0], Y[i+1][0], abs(Y[i+1][1]-Y[i][1])))
 
  Y = sorted(X, key = lambda x: x[2])
  for i in range(len(Y)-1):
    append((Y[i][0], Y[i+1][0], abs(Y[i+1][2]-Y[i][2])))
 
  print(MST(N, F))

solve()

Measured memory_bytes: 49812
#include <bits/stdc++.h>
#include <limits>
using namespace std;
double inf = std::numeric_limits<double>::infinity();

void solve(long long X){
    long long ans = 1;
    for(int b=2; b<=X; b++){
        int p = 2;
        long long tmp = 0;
        while(true) {
            tmp = pow(b, p);
            if(tmp > X)break;
            if(tmp > ans)ans = tmp;
            p+=1;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, m;
    cin >> n >> m;
    ll x[n], y[m];
    rep(i, n) { cin >> x[i]; }
    rep(i, m) { cin >> y[i]; }

    ll x_sum = 0, y_sum = 0;
    rep(i, n) {
        x_sum += (2 * i - n + 1) * x[i];
        x_sum %= mod;
    }
    rep(i, m) {
        y_sum += (2 * i - m + 1) * y[i];
        y_sum %= mod;
    }

    ll ans = (x_sum * y_sum) % mod;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
#define N 100000

int Color[N];

int J(int, int);
int search(int);
void R(int,int);

int main()
{
  int i;
  int n,m,q,t,s;
  for(i=0; i<N; i++)
  {
    Color[i]=i;
  }
  scanf("%d %d",&n,&m);
  for(i=0; i<m; i++)
  {
    scanf("%d %d",&s,&t);
    R(s,t);
  }

  scanf("%d",&q);
  for(i=0; i<q; i++)
  {
    scanf("%d%d",&s,&t);
    if(J(s,t)==1)
    {
      printf("yes\n");
    }
    else
    {
      printf("no\n");
    }
  }
  return 0;
}

void R(int s, int t)
{
  s=search(s);
  t=search(t);
  if(s==t)
  {
    return;
  }
  Color[t]=s;
}

int J(int s, int t)
{
  if(search(s)==search(t))
  {
    return 1;
  }
  else return 0;
}

int search(int a)
{
  if(a==Color[a])
  {
    return a;
  }
  return Color[a]=search(Color[a]);
}



Measured memory_bytes: 2100
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of array of char;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
  bh,bw:array of Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(h);
    Readln(w);
    count:=0;
    max  :=0;
    min  :=100;

    if (h=1)and(w=1) then begin
      Writeln('#');
      exit
    end;

    SetLength(bh,h);
    SetLength(bw,w);

    SetLength(l,h);
    for i := 0 to h do
      SetLength(l[i],w);

    for i := 0 to h-1 do begin
      for j := 0 to w-1 do begin
        Read(l[i][j]);      //読み込む
        if l[i][j]='#' then //ついでに横一行を記憶
          bh[i]:=True;
      end;
      Readln;
    end;

    for j := 0 to w-1 do begin //縦
      for i := 0 to h-1 do
        if l[i][j]='#' then
          bw[j]:=True;
    end;

    for i := 0 to h-1 do begin
      if bh[i] then begin //消す行なら1行まるごと飛ばす
        for j := 0 to w-1 do begin
          if bw[j] then //消す列なら1個ずつまたぐ
            Write(l[i][j]);
        end;
        Writeln;
      end;
    end;

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
a,b=map(int,input().split())
if min(a,b)>=3:
    print( (a-2)*(b-2))
    exit()
if a>b: a,b=b,a
if a==1 and b>=3:
    print(b-2)
if a==2 and b>=3:
    print(0)


if [a,b]==[1,1]:
    print(1)
if [a,b]==[1,2]:
    print(0)
if [a,b]==[2,2]:
    print(0)

Measured memory_bytes: 61740
a,b,h,m = gets.chomp.split(" ").map(&:to_f)

t = Math::PI*2*(h+m/60.0)/12.0
g = Math::PI*2*m/60.0

o = Math.cos(g-t)

#p t
#p g
#p o

puts("#{Math.sqrt(a*a+b*b-2*a*b*o)}")

Measured memory_bytes: 14724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll x, n;
    cin >> x;
    n = (x + 10) / 11;
    if (x + 5 <= 11 * n)
    {
        cout << 2 * n - 1;
    }
    else
    {
        cout << 2 * n;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();
			int n = cin.NextInt();
			var a = cin.ArrayInt(n);
			long ans = 0;
            for (int i = 0; i < n; i++)
            {
				while (a[i] % 2 == 0)
                {
					ans++;
					a[i] /= 2;
                }
            }
            Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11744
import numpy as np
[N, D] = map(int, input().split())
X, Y = np.zeros(N), np.zeros(N)

for i in range(N):
    [x, y] = map(int, input().split())
    X[i], Y[i] = x, y

dist = np.sqrt(X * X + Y * Y)
print(len(np.where(dist <= D)[0]))


Measured memory_bytes: 33440
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    string s;cin>>s;
    deque<char>st;
    int n = s.size();
    rep(i,n){
        if(s[i]=='B' && !st.empty())st.pop_back();
      else if(s[i]=='B' && st.empty())continue;
        else st.push_back(s[i]);
    }
    while(!st.empty()){
        cout<<st.front();
        st.pop_front();
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    if (a == b && b == c && c == a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s;
  
  if(s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR") cout << 1 << endl;
  else if(s == "RRS" or s == "SRR") cout << 2 << endl;
  else if(s == "SSS") cout << 0 << endl;
  else cout << 3 << endl;
  
  
}

Measured memory_bytes: 3628
N, M = map(int, input().split())
S = input()
T = input()

from fractions import gcd

def solve(N,M,S,T):
    g = gcd(N,M)
    for i in range(g):
        if S[N//g*i]!=T[M//g*i]:
            return -1
    ans = N*M//g
    return ans
print(solve(N,M,S,T))

Measured memory_bytes: 5360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if (op.equals("+")) {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
	}
}

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


int main()
{
	int A[4],B[4],hit[50],blow[50],h,b,i,j,k=0;

	
	while (scanf("%d %d %d %d\n%d %d %d %d", &A[0], &A[1], &A[2], &A[3], &B[0], &B[1], &B[2], &B[3])!=EOF)
	{
		h = b = 0;
		for (i = 0; i < 4; i++)
		{
			if (A[i] == B[i])
			{
				++h;
			}
		}
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (i != j&&A[i] == B[j])
				{
					++b;
				}
			}
		}
		hit[k] = h;
		blow[k] = b;
		++k;
	}

	for (i = 0; i < k; i++)
	{
		printf("%d %d\n",hit[i],blow[i]);
	}
	return 0;
}


Measured memory_bytes: 596
<?php
fscanf(STDIN, "%d", $n);
$h = explode(' ', trim(fgets(STDIN)));
$x = 0;
$tmp[] = $h;
while($tmp) {
	$tx = [];
	foreach ($tmp as $h) {
		if (count($h) <= 2) {
			$x += max($h);
		} else {
			[$c, $t] = sp($h);
			$x += $c;
			$tx = array_merge($tx, $t);
		}
	}
	$tmp = $tx;
}
echo $x;

function sp($h) {
	$m = min($h);
	$t = $h2 = [];
	foreach ($h as $p) {
		if ($p == $m) {
			if ($t) {
				$h2[] = $t;
				$t = [];
			}
			continue;
		}
		$t[] = $p - $m;
	}
	if ($t) $h2[] = $t;
	return [$m, $h2];
}

Measured memory_bytes: 16084
#include <bits/stdc++.h>
using namespace std;
#define MAX 30
#define NIL -1
struct Node{
    int parent, left, right;
};
Node T[MAX];
int n, Depth[MAX], Height[MAX];

void setdepth(int u, int d){
    if(u == NIL) return;
    Depth[u] = d;
    setdepth(T[u].left, d + 1);
    setdepth(T[u].right, d + 1);
}

int setheight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL){
        h1 = setheight(T[u].left) + 1;
    }
    if(T[u].right != NIL){
        h2 = setheight(T[u].right) + 1;
    }
    return Height[u] = (h1 >= h2 ? h1 : h2);
}
int getsibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}
void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getsibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", Depth[u]);
    printf("height = %d, ", Height[u]);
    if(T[u].parent == NIL) printf("root\n");
    else if(T[u].left == NIL && T[u].right == NIL) printf("leaf\n");
    else printf("internal node\n");
}
int main(){
    int v, l, r, root = 0;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) T[i].parent = NIL;
    for(int i = 0; i < n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }
    for(int i = 0; i < n; i++){
        if(T[i].parent == NIL) root = i;
    }
    setdepth(root, 0);
    setheight(root);
    for(int i = 0; i < n; i++) print(i);
    return 0;
}



Measured memory_bytes: 3236
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    T = rl().rstrip()
    
    ans = []
    for ti in T:
        if ti == '?':
            ans.append('D')
        else:
            ans.append(ti)
    print(''.join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 81932
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 100000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	long long n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	vector<pair<long long, long long>> input;
	long long geko = n;
	long long topper = 1;
	for (int q = 2; q <= sqrt(geko); ++q) {
		if (geko % q == 0) {
			int cnt = 0;
			while (geko % q == 0) {
				cnt++;
				geko /= q;
			}
			topper *= cnt + 1LL;
			input.push_back(make_pair(q, cnt));
		}
	}
	if (geko != 1) {
		input.push_back(make_pair(geko, 1));
		topper *= 2LL;
	}
	long long ans = 0;
	for (int i = 1; i < topper; ++i) {
		long long now = i;
		long long geko = 1;
		for (int q = 0; now != 0; ++q) {
			REP(j, now % (input[q].second + 1)) {
				geko *= input[q].first;
			}
			now /= (input[q].second + 1LL);
		}
		long long m = geko - 1LL;
		if (n / m == n % m) {
			ans += m;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int N, d;
    std::cin >> N >> d;
    int p, res = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> p;
        res += std::max(0, p - d);
    }
    if (res == 0) {
        std::cout << "kusoge" << std::endl;
    } else {
        std::cout << res << std::endl;
    }    
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) {
        return {x-rhs.x, y-rhs.y};
    }
    T dot(const point &rhs) {
        return x*rhs.x + y*rhs.y;
    }
    T cross(const point &rhs) {
        return x*rhs.y - y*rhs.x;
    }
    T len2() {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y-x > 0) return -1;
    if(x-y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q).cross(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
 /*
double angle(point p, point q, point r) 
{
    point v = r - q;
    point u = p - q;
    return acos(v.dot(u) / sqrt(v.len2() * u.len2())); 
}
*/
T dot(point p, point q) { return p.x * q.x + p.y * q.y; }
// modulo^2 de un punto (distance to origin)
double norm2(point p) { return p.x * p.x + p.y * p.y; }


double angle(point a, point o, point b) // angle AOB (radians)
{
   point u = {a.x - o.x, a.y - o.y}; // u: vector oa
   point v = {b.x - o.x, b.y - o.y}; // v: vector ob
   return acos(dot(u,v) / sqrt(norm2(u) * norm2(v))); // dot product
}

 
bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

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

int main(){
  int n;
  cin >> n;
  int b;
  b = n*100/109;
  for(int i=b;i<=n;i++){
    if(floor(i*1.08)==n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

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

int main()
{
    long long n,m,i,j,k,x=0,y,z;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            x++;
        }
    }
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	long long n,i,j,k,d[20],a;
	char s[20] = {0};
  
	scanf("%s",s);
  
	for(i=0;s[i];i++)
		d[i]=s[i]-'0';//printf("%d\n",i);
	for(j=a=0;j<(1<<(i-1));j++)
	{
		n=d[0];
		for(k=0;k<i-1;k++)
		{
			if(j&(1<<k))n=n*10+d[k+1];
			else
			{
				a+=n;//printf("%d\n",n);
				n=d[k+1];
			}
		}
    a+=n;
	}
  printf("%lld\n",a);
  return 0;
}

Measured memory_bytes: 128
// 2013/11/25 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0&&m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		for(int k=0; k<m; k++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
					T[i][j] = min(T[i][j], T[i][k]+T[k][j]);
				}
			}
		}

		int k;
		cin >> k;

		for(int i=0; i<k; i++){
			int p, q, r;
			cin >> p >> q >> r;

			if(r==0){
				cout << C[p-1][q-1] << endl;
			}
			else{
				cout << T[p-1][q-1] << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1236
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int X;
int Y;
char S[50][52];
int main(){
  int di, dj, i, j, k;
  rd(X);
  rd(Y);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(X);Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  for(i=0;i<(X);i++){
    for(j=0;j<(Y);j++){
      if(S[i][j]=='.'){
        k = 0;
        for(di=(i-1);di<(i+2);di++){
          for(dj=(j-1);dj<(j+2);dj++){
            if(0 <= di  &&  di < X && 0 <= dj  &&  dj < Y && S[di][dj] == '#'){
              k++;
            }
          }
        }
        S[i][j] = '0' + k;
      }
    }
  }
  for(i=0;i<(X);i++){
    wt_L(S[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int X, Y;
// char S[50][52];
// {
//   int i, j, di, dj, k;
//   rd(X,Y,S(X));
//   rep(i,X) rep(j,Y) if(S[i][j]=='.'){
//     k = 0;
//     rep(di,i-1,i+2) rep(dj,j-1,j+2) if(0 <= di < X && 0 <= dj < Y && S[di][dj] == '#') k++;
//     S[i][j] = '0' + k;
//   }
//   rep(i,X) wt(S[i]);
// }


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

int main()
{
  // 標準入力
  //N:敵の数
  //K:必殺技の使用回数
  int N, K;
  cin >> N >> K;

  //敵の数より必殺技の使用回数が多ければ、攻撃せずともＯＫ
  if (N <= K) {
    cout << 0;
    return 0;
  }

  long H[N];
  for (int i; i < N; i++) {

    cin >> H[i];

  }

  sort(H, H + N, [](const long x, const long y) {return x < y;});

  long answer = 0;
  for (int i; i < N-K; i++) {
    answer += H[i];

  }

  cout << answer;

  return 0;

}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;
    cin >> n;
    string w[n];
    map<string,int> mp;

    rep(i,n){
        cin >> w[i];
        mp[w[i]]++;
    }

    if(n!=mp.size()){
        cout << "No" << endl;
        return 0;
    }


    for(int i=1;i<n;i++){
        string a = w[i-1];
        string b = w[i];
        if(a[a.size()-1]!=b[0]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x;
  vector<int> y;
  int in;
  rep(i,N){ cin >> in; x.pb(in);}
  rep(j,M){ cin >> in; y.pb(in);}
  x.pb(X);
  y.pb(Y);
  sort(rall(x));
  sort(all(y));
  if(x[0] < y[0]) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
students = []
checkpoint = []
for i in range(N):
    students.append(list(map(int, input().split())))
for j in range(M):
    checkpoint.append(list(map(int, input().split())))
for k in students:
    a, b = k[0], k[1]
    distance = []
    for l in checkpoint:
        c, d = l[0], l[1]
        distance.append(abs(a - c) + abs(b - d))
    print(distance.index(min(distance))+1)


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,(input().split())))

sum=1

if 0 in A:
    print(0)
else:
    for i in range(N):
        sum *= A[i]  
        if sum >= int(1e18):
            break
    print(sum if sum<= int(1e18) else -1)

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

int main() {
    int N;
    cin >> N;
    for (int i=0; i<26; i++) {
        for (int j=0; j<16; j++) {
            if (i*4+j*7==N) {
                cout << "Yes\n";
                return 0;
            }
            else if (i*4+j*7>N) break;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int M;
vector<int> D; vector<ll> C;
int n = 0;
ll ans = 0;

ll memo[10][10] ={};
ll calcC(int n, int m){
    if(memo[n][m] != 0) return memo[n][m];
    deque<int> que;
    que.pb(n);
    rep(i, 9) que.pb(m);
    ll ret = 0;
    while(que.size() > 1){
        int a = que[0];
        int b = que[1];
        que.pop_front();
        que.pop_front();
        if(a+b >= 10){
            que.push_front((a+b)%10);
            que.push_front(1);
        }
        else{
            que.push_front(a+b);
        }
        ret++;
    }
    return memo[n][m] = ret;
}

void calc(deque<int> &que){
    while(que.size() > 1){
        int a = que[0];
        int b = que[1];
        que.pop_front();
        que.pop_front();
        if(a+b >= 10){
            que.push_front((a+b)%10);
            que.push_front(1);
        }
        else{
            que.push_front(a+b);
        }
        ans++;
    }
}

signed main(){
    cin >> M;
    rep(i, M){
        int d; ll c;
        cin >> d >> c;
        if(d == 0){
            ans += c;
        }
        else{
            if(n == 0){
                n = d;
                c--;
            }
            if(c > 0){
                D.pb(d);
                C.pb(c);
            }
        }
    }

    rep(i, D.size()){
        ll k = C[i] / 9;
        ans += k * calcC(n, D[i]);
        deque<int> d;
        d.pb(n);
        rep(j, C[i]-9*k) d.pb(D[i]);
        calc(d);
        n = d.front();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5848
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef unsigned long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,k;
    cin>>n>>k;
    vector<bool> v(n+1,false);
    
    for(;k;k--){
        int e;
        cin>>e;
        for(;e;e--){
            int h;
            cin>>h;
            v[h] = true;
        }
    }
    
    int ans = 0;
    for(int i =1; i<=n; i++){
        if(!v[i])
            ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3616