akhauriyash/Code-Regression huggingface dataset:
import heapq

class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r):
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)

INF = float("inf")
YEN = pow(10,15)
n,m,s,t = map(int,input().split())
s-=1;t-=1 #s,tを0index
yedge = [[] for _ in range(n)]
sedge = [[] for _ in range(n)]
for i in range(m):
  u,v,a,b = map(int,input().split())
  u-=1;v-=1
  yedge[u].append([a,v]);yedge[v].append([a,u])
  sedge[u].append([b,v]);sedge[v].append([b,u])

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定。始点として探索されたか。というかdが更新されたか。
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中からスタートから最小の距離のものを探す
        if not used[minedge[1]]: #すでに探索済みの場合にはスキップして次のプライオリティーキューへ。
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False #ここで始点として探索済みにする。
        for e in edge[v]:
            if used[e[1]]: #行き先がすでに始点として探索済みでない場合には値を更新。
                heapq.heappush(edgelist,[e[0]+d[v],e[1]]) #重みをスタートからの最短重みにするため+d[v]
    return d ##始点sから各頂点への最短距離がアウトプットとなる。  
yto = dijkstra_heap(s,yedge)
#sto = dijkstra_heap(s,sedge)
#yot = dijkstra_heap(t,yedge)
sot = dijkstra_heap(t,sedge)
#print(yto)
#print(sto)
#print(yot)
#print(sot)
A = []
for i in range(n):
  if i == s:
    temp = sot[i]
  elif i == t:
    temp = yto[i]
  else:
    temp = yto[i]+sot[i]
  A.append(temp)
#print(A)
Tree = SegmentTree(A,min, INF)
for i in range(n):
  temp = Tree.sum(i,n)
  ans = YEN - temp
  print(ans)

Measured memory_bytes: 169264
N=int(input())
S=input()
ans=0
 
for i in range(N):
    A=S[:i]
    B=S[i:]
    sum=0
    l=[]
    for j in A:
        if (j in B) and (j not in l):
            sum+=1
            l.append(j)
    ans=max(sum,ans)
print(ans)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long T, std::vector<long long> c, std::vector<long long> t){
    LL ans = INFL;
    REP(i, N) {
        if(t[i] <= T){
            ans = min(ans, c[i]);
        }
    }

    if (ans == INFL) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> c(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&c[i]);
        scanf("%lld",&t[i]);
    }
    solve(N, T, std::move(c), std::move(t));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
//12:34
int main(){
	string s;
	cin>>s;
	int head,cnt,max,min=s.size();
	for(char c='a';c<='z';c++){
		head=0;
		cnt=0;
		max=0;
		while(head<s.size()){
			if(s[head]==c){
				cnt=0;
			}else{
				cnt+=1;
				if(max<cnt)max=cnt;
			}
			head++;
		}
		if(min>max)min=max;
	}
	cout<<min<<endl;
	return 0;
}

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

const int N = 500000 + 10;

int mx[N << 2], P[N], Q[N];
int ret[N], n, m;

#define lson (rt<<1)
#define rson (rt<<1|1)
#define mid ((l+r)>>1)
void build(int rt, int l, int r) {
  if (l + 1 == r) {
    mx[rt] = P[l];
    return;
  }
  build(lson, l, mid);
  build(rson, mid, r);
  mx[rt] = std::max(mx[lson], mx[rson]);
}
void ins(int rt, int l, int r, int x, int v) {
  if (l + 1 == r) {
    mx[rt] = v;
    return;
  }
  if (x < mid) ins(lson, l, mid, x, v);
  else ins(rson, mid, r, x, v);
  mx[rt] = std::max(mx[lson], mx[rson]);
}
int ask(int rt, int l, int r, int L, int R) {
  if (L <= l && R >= r) return mx[rt];
  int ret = -1;
  if (L < mid) ret = std::max(ret, ask(lson, l, mid, L, R));
  if (R > mid) ret = std::max(ret, ask(rson, mid, r, L, R));
  return ret;
}

bool is_local(int x) {
  if (x == -1) return false;
  int mx = ask(1, 0, n, x - m + 1, x + m);
  return mx != -1 && mx == P[x];
}

void run() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    std::cin >> P[i];
    Q[--P[i]] = i;
  }
  build(1, 0, n);
  std::vector<bool> mark(n, 0);
  std::priority_queue<int> pq;
  for (int i = 0; i <= (n - 1) / m; ++i) {
    int l = i * m, r = l + m;
    int x = Q[ask(1, 0, n, l, r)];
    if (is_local(x) && !mark[x]) pq.push(x), mark[x] = 1;
  }
  for (int i = n; i >= 1; --i) {
    int u = pq.top();
    pq.pop();
    ret[u] = i;
    ins(1, 0, n, u, -1);
    int x = u / m, l, r, y;
    l = x * m, r = l + m;
    y = ask(1, 0, n, l, r);
    if (y != -1) y = Q[y];
    if (is_local(y) && !mark[y]) pq.push(y), mark[y] = 1;
    if (r > 0) {
      r = x * m, l = r - m;
      y = ask(1, 0, n, l, r);
      if (y != -1) y = Q[y];
      if (is_local(y) && !mark[y]) pq.push(y), mark[y] = 1;
    }
    l = x * m + m, r = l + m;
    if (l < n) {
      y = ask(1, 0, n, l, r);
      if (y != -1) y = Q[y];
      if (is_local(y) && !mark[y]) pq.push(y), mark[y] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d\n", ret[i]);
  }
}

int main() {
  run();
  return 0;
}


Measured memory_bytes: 15728
macro_rules! input {
    ($t : ty) => {{
        use std::io::BufRead;
        let tmp_handle = std::io::stdin();
        let mut handle = tmp_handle.lock();
        let mut buf = String::new();
        handle.read_line(&mut buf).unwrap();
        let tmp_var: $t = buf.trim().parse().unwrap(); 
        buf.clear();
        tmp_var
    }};
    ($t : ty, $size : expr) => {{
        use std::io::BufRead;
        let tmp_handle = std::io::stdin();
        let mut handle = tmp_handle.lock();
        let mut buf = String::new();
        handle.read_line(&mut buf).unwrap();
        let tmp_var: $t = buf.trim().split_whitespace()
            .map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp_var
    }};
}
#[derive(Debug)]
pub struct UnionFind {
    parents: Vec<usize>,
    rank: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let mut parents: Vec<usize> = Vec::with_capacity(n);
        for i in 0..n {
            parents.push(i);
        }
        let rank = vec![1; n];
        UnionFind {
            parents: parents,
            rank: rank,
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            x
        } else {
            let par = self.parents[x];
            let root = self.find(par);
            self.parents[x] = root;
            root
        }
    }
    // union x and y
    pub fn union(&mut self, x: usize, y: usize) {
        let x_root = self.find(x);
        let y_root = self.find(y);
        // if x_root == y_root, do nothing
        if x_root == y_root { return (); }
        if self.rank[x_root] > self.rank[y_root] {
            // x <--- y
            self.parents[y_root] = x_root;
        } else {
            // y <--- x
            self.parents[x_root] = y_root;
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[y_root] += 1;
            }
        }
    }
}
fn main() {
    let config = input!(Vec<usize>, 2);
    let nums: Vec<usize> = input!(Vec<usize>, config[0]).into_iter().map(|a| a - 1).collect();
    let mut uf = UnionFind::new(config[0]);
    for _ in 0..config[1] {
        let change = input!(Vec<usize>, 2);
        uf.union(change[0]-1, change[1]-1);
    }
    let mut count = 0;
    for (i, num) in nums.into_iter().enumerate() {
        if uf.find(i) == uf.find(num) { count += 1; }
    }
    println!("{}", count);
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    vector<int> a(3);
    cin >> a;
    cout << (accumulate(all(a), 0) >= 22 ? "bust" : "win") << endl;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
    size_t a, b;
    cin >> a >> b;
    if (a > 12)
        cout << b << endl;
    else if (a > 5)
        cout << b / 2 << endl;
    else
        cout << 0 << endl;
    cout << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int K; cin >> K;
  string S; cin >> S;
  if(S.size() <= K) {
    cout << S << endl;
  } else if(S.size() > K) {
    string ans = S.substr(0, K);
    cout << ans << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int main() {
	lli a, b, c, d;
	cin>>a>>b>>c>>d;
	lli pro1, pro2, pro3, pro4;
	pro1 = a*c;
	pro2 = a*d;
	pro3 = b*c;
	pro4 = b*d;
	cout<<max(max(max(pro1, pro2), pro3), pro4)<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
const int N=2e5+11,p=1e9+7;
int g[N],s[N];
int f(int x){return g[x]==x?x:g[x]=f(g[x]);}
int n,m;
int main(){
	int i,x,y;
	cin>>n>>m;
	for(i=1;i<=n;++i)g[i]=i,s[i]=1;
	for(i=1;i<=m;++i){
		cin>>x>>y;
		x=f(x);
		y=f(y);
		if(x!=y){
			g[x]=y;
			s[y]+=s[x];
		}
	}
	int ans=1;
	for(i=1;i<=n;++i)ans=max(ans,s[i]);
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
const int N=1e5+10;
struct bb{
    int a,b,c,d;
}q[55];
int x[15];
int n,m,Q;
int ans;
void dfs(int last,int A[],int cou){
    if(cou==n){
       // for(int i=1;i<=n;i++) cout<<A[i]<<" ";
       // cout<<endl;
        int sum=0;
        for(int i=1;i<=Q;i++){
            if(A[q[i].b]-A[q[i].a]==q[i].c) sum+=q[i].d;
        }
        ans=max(ans,sum);
        return ;
    }
    for(int i=last;i<=m;i++){
        A[cou+1]=i;
        dfs(i,A,cou+1);
    }
}

int main()
{


    cin>>n>>m>>Q;
    for(int i=1;i<=Q;i++){
        cin>>q[i].a>>q[i].b>>q[i].c>>q[i].d;
    }
    ans=0;
    dfs(1,x,0);
    cout<<ans<<endl;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std ;
int main(){
    long long n ;
    cin >> n ;
    long long f ;
    for(long long i=1 ; i*i<=n ; i++){
        if(n%i==0){
            f=i ;
        }
    }
    cout << (f+n/f)-2;
}

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

int main() {

	std::string s;
	std::cin >> s;

	int N = s.size();
	int st = 0;
	int ed = 0;

	for (int i = 0; i < N; i++) {
		if (s[i] == 'A') {
			st = i;
			break;
		}
	}

	for (int i = 0; i < N; i++) {

		if (s[i] == 'Z') {
			ed = i;
		}
	}

	int ans = ed - st + 1;

	std::cout << ans << std::endl;

}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int 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;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int a,b; cin >> a >> b;
  cout << max({a+b,a-b,a*b}); 

  return 0;
}


Measured memory_bytes: 256
n = int(input())
arr = [int(i) for i in input().split(" ")]
allOdd = True
count = 0
while allOdd:
  for i in arr:
    if i % 2 == 1:
      allOdd = False
      break
  else:
    arr = [x/2 for x in arr]
    count += 1
  
print(count)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X, t;
    cin >> X >> t;
    cout << max(0LL, X - t) << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {   
  ll n;cin>>n;
  ll one = 0;
  for(ll i = 1;i*i <= n;++i){
    if(n%i == 0)one = i;
  }
  ll ans = one+n/one;
  print(ans-2);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> connection(N);
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    connection.at(a).push_back(b);
    connection.at(b).push_back(a);
  }
  ll ans = 0;
  vector<ll> c(N);
  for (ll i = 0; i < N; ++i) {
    cin >> c.at(i);
    ans += c.at(i);
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  ans -= c.at(0);
  cout << ans << "\n";
  vector<ll> num(N, -1);
  queue<ll> q;
  q.push(0);
  num.at(0) = c.at(0);
  ll cnt = 1;
  while (!q.empty()) {
    ll now = q.front();
    q.pop();
    for (ll i = 0; i < connection.at(now).size(); ++i) {
      ll check = connection.at(now).at(i);
      if (num.at(check) != -1) {
        continue;
      }
      num.at(check) = c.at(cnt);
      cnt += 1;
      q.push(check);
    }
  }
  for (ll i = 0; i < N; ++i) {
    cout << num.at(i) << " ";
  }
  cout << "\n";
}


Measured memory_bytes: 4228
import sys
 
lines = sys.stdin.readlines()
for line in lines:
    a, b, c, d, e, f = map(float, line.split())
    if a * e - b * d == 0:
        break
    x = (e * c + (-b) * f)/(a * e - b * d)
    y = ((-d) * c + a * f)/(a * e - b * d)
    print('{:.3f} {:.3f}'.format(x+0, y+0))

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

using namespace std;

template<typename TH>
void _dbg(const char* sdbg, TH h)
{
	cerr << sdbg << " = " << h << "\n";
}

template<typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t)
{
	while (*sdbg != ',') cerr << *sdbg++;
	cerr << " = " << h << ",";
	_dbg(sdbg + 1, t...);
}

#define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define chkpt cerr << "--- Checkpoint here ---\n";

int64_t x;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>x;
	int64_t a=100;
	int64_t ans=0;
	while(a<x){
        double b=(double)a*101/100;
        a=(int64_t)b;
        ans++;
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+10;
ll l[200];
int solve(){
    ll x,k,d,m;
    cin>>x>>k>>d;
    if (x==0){
        if (k%2==0)return cout<<0<<endl,0;
        else return cout<<d<<endl,0;
    }
    if (x<0)x=-x;
    ll n=x/d;
    if(x<d){
        if (k%2==0)return cout<<x<<endl,0;
        else return cout<<d-x<<endl,0;
    }
    if (n<k){
        if (n>0) m=x%d;
        if((k-n)%2==0)cout<<m<<endl;
        else cout<<d-m<<endl;
        return 0;
    } else{
        m=x-k*d;
        cout<<m<<endl;
        return 0;
    }
}
int main(){
    int _=1;
//    cin>>_;
    while(_--){
        solve();
    }
}


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

int main(void){
    int i,n,cnt;
    string s;

    cnt = 0;
    cin >> s;
    n = s.size();

    for(i=0; i<=(n-1)/2; i++){
        if(s.at(i) != s.at(n-1-i))    cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

class C{
  public:
    int s, t;
    string name;
    C(){}
    C(int _s, int _t, string _n){ s = _s; t = _t; name = _n; }
};

int check(int y, vector<C> &v){
  REP(i, v.size()) if(v[i].s <= y && y <= v[i].t) return i;
  return -1;
}

int main() {
  int N, Q;
  while(cin >>N >>Q && N){
    vector<C> v(N);
    REP(i, N){
      cin >>v[i].name >>v[i].s >>v[i].t;
      v[i].s = v[i].t - v[i].s + 1;
    }
    REP(i, Q){
      int y; cin >>y;
      int r = check(y, v);
      if(r == -1) cout <<"Unknown" <<endl;
      else cout <<v[r].name <<" " <<y - v[r].s + 1 <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1280
from collections import defaultdict, deque
n, m = list(map(int, input().split()))
graph = defaultdict(set)
for i in range(m):
  u, v = list(map(int, input().split()))
  graph[u].add(v)
s, t = list(map(int, input().split()))
dist = [[-1 for i in range(3)] for i in range(10**5+10)]

def bfs():
  que = deque([(s, 0, 0)]) #(x, cost, kenkenpa)
  while len(que) > 0:
    p = que.popleft()
    if dist[p[0]][p[2]] != -1:
      continue
    dist[p[0]][p[2]] = p[1]
    for nx in graph[p[0]]:
      que.append((nx, p[1]+1, (p[2]+1)%3))

bfs()
print(dist[t][0]//3)


Measured memory_bytes: 105688
#include <stdio.h>

#define N_MAX 100000
#define A_MAX 100000

int parse(char *text);

int main(void)
{
	int i, n, max, cnt;
	int count[A_MAX+2];
	char buf[7];

	for(i=0;i<A_MAX+1;i++) {
		count[i] = 0;
	}

	scanf("%d%*c", &n);

	i = 0;
	while(1) {
		int flag = 0;
		scanf("%c", &buf[i]);
		if(buf[i] == ' ' || buf[i] == '\n') {
			if(buf[i] == '\n') flag = 1;
			buf[i] = '\0';
			int a = parse(buf);
			count[a]++;
			if(a-1 >= 0) count[a-1]++;
			if(a+1 <= A_MAX+1) count[a+1]++;
			if(flag) break;
			i = 0;
			continue;
		}
		i++;
	}

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

	return 0;
}

int parse(char *text)
{
	int i = 0, ret = 0, len;
	while(1) {
		if(text[i] == '\0') {
			len = i;
			break;
		}
		i++;
	}

	for(i=len-1;i>=0;i--) {
		int a = 1, j;
		for(j=0;j<len-i-1;j++) a *= 10;
		ret += (int)(text[i] - '0') * a;
	}

	return ret;
}


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

int main (){
  int a,b,c,d,e,f=0,e1,e2,e3,e4;
  cin >>a >>b;
  c=b-a;
  for (int i=0;i<c+1;i++){
    d=a+i;
    e=d/10000;
    e1=d/1000-e*10;
    e2=d/100-e*100-e1*10;
    e3=d/10-e*1000-e1*100-e2*10;
    e4=d-e*10000-e1*1000-e2*100-e3*10;
    if ((e==e4)&&(e1==e3)){
      f++;
    }
  }
  cout << f << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

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

    ll n;
    cin >> n;
    ll x = (ll)sqrt(n);
    while(n%x!=0 && x>0){
        x--;
    }
    ll b = n/x;
    ll steps = x-1+b-1;
    cout << steps;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string S;
  cin >> S;

  ll N = S.size();

  // [i, j)
  rep(j, N + 1) rep(i, j + 1) {
    string res = "";

    rep(k, N) { unless(i <= k && k < j) res.push_back(S[k]); }

    if (res == "keyence") drop("YES");
  }

  cout << "NO" << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
    while(true){
        int x, y, s;
        int t;
        set<int> kouho;
        cin >> x >> y >> s;
        if(!(x||y||s)) break;
        for(int i=1;i<s;++i){
            for(int j=1;j<s;++j){
                t = i*(100+x)/100 + j*(100+x)/100;
                if(t>s) break;
                if(t==s){
                    kouho.insert(i*(100+y)/100 + j*(100+y)/100);
                }
            }
        }
        cout << *(kouho.rbegin()) << endl;
    }
}

Measured memory_bytes: 1196
#include <stdio.h>



int main(void)
{
    char str[10];

    scanf("%s", str);

    switch(str[0]){
        case 'S' : printf("Cloudy\n"); break;
        case 'C'  : printf("Rainy\n"); break;
        case 'R'  : printf("Sunny"); break;
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>

using namespace std;

int main() {
	int n,a[100005],ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == i + 1) {
			int tmp = a[i];
			a[i] = a[i + 1];
			a[i + 1] = tmp;
			ans++;
		}
	}
    if (a[n - 1] == n)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int H, W; cin >> H >> W;
    
    rep(i, 0, W+2) cout << '#';
    cout << endl;

    rep(i, 0, H) {
      string s; cin >> s;
      cout << '#' << s << '#' << endl;
    }
  
    rep(i, 0, W+2) cout << '#';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<string>
#include<iomanip>

int main() {
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double>>q;
	rep(i, n) {
		int buffer;
		cin >> buffer;
		q.push(buffer);
	}
	while (q.size() > 1) {
		double a = q.top();
		q.pop();
		double b = q.top(); 
		q.pop();
		double c = (a + b) / 2;
		q.push(c);
	}
	double ans = q.top();
	cout <<fixed<<setprecision(9)<< ans;

	return 0;
}

Measured memory_bytes: 256
S = list(input())
N = int(input())
for _ in range(N):
    Q = input().split()
    if Q[0] == "print":
        si = int(Q[1])
        ei = int(Q[2])
        print(*S[si: ei + 1], sep="")
    elif Q[0] == "reverse":
        si = int(Q[1])
        ei = int(Q[2])
        S[si:ei+1] = S[si:ei+1][::-1]
        #S[] = S[:si+1] + str(rev_S) + S[ei+1:]
    elif Q[0] == "replace":
        si = int(Q[1])
        ei = int(Q[2])
        S[si: ei + 1] = list(Q[3])


Measured memory_bytes: 5736
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
vi A;
int H;
void maxHeapify(int i) {
	int x,largest;
	int l = 2 * i + 1;
	int r = 2 * i + 2;
	if (l < H&&A[l] > A[i]) {
		largest = l;
	}
	else {
	    largest = i;
	}
	if (r < H&&A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {
		x = A[i];
		A[i] = A[largest];
		A[largest] = x;
		maxHeapify(largest);
	}
}

void buildMaxHeap(int H) {
	for (int i = H / 2; i >= 0; i--) {
		maxHeapify(i);
	}
}

int main() {
	int y;
	cin >> H;
	for (int i = 0; i < H;i++){
		cin >> y;
		A.push_back(y);
	}
	buildMaxHeap(H);
	for (int i = 0; i < H; i++) {
		cout << " " << A[i];
		if (i == H - 1) {
			cout << endl;
		}
	}
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	long long a;
	long double b;
	long double multi = 0;
	cin >> a >> b;
	multi = a *b;
	// while(a>0){
	// 	a-=1;
	// 	multi +=b;
	// }
	long long multi2 = multi;
	cout << multi2;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long m,n,L,i,j,k,temp;
    int a[100][100] = {};
    int b[100][100] = {};
    long long ans[100][100] = {};
    cin>>n>>m>>L;
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0; i<m; i++)
    {
        for(j=0; j<L; j++)
        {
            cin>>b[i][j];
        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<L; j++)
        {
            temp=0;
            for(k=0; k<m; k++)
            {
                temp+=a[i][k]*b[k][j];
            }
            ans[i][j]=temp;
        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<L; j++)
        {
            if(j<=L-2)
                cout<<ans[i][j]<<" ";
            else
                cout<<ans[i][j];
        }
        cout<<endl;
    }
    return 0;
}




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

int main()
{
    int A, B;
    cin >> A >> B;
    int count = 1;
    int ans = 0;
    while (count < B)
    {
        ans++;
        count += A - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const ll MOD = TEN(9) + 7;
ll n, m;

ll fact(ll x) {
    ll ans = 1;
    forn1(i, x) {
        ans = ans * i % MOD;
    }
    return ans;
}

int main() {
    fastio();

    cin >> n >> m;

    if (abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }

    ll x = fact(n);
    ll y = fact(m);

    cout << x * y % MOD * (n == m ? 2 : 1) % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char str[105][105];
char ch[105][1045];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",str[i]);
	for(int i=0;i<m;i++){
		scanf("%s",ch[i]);
	}
	if(m==n){
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				if(str[i][j]!=ch[i][j]){
					puts("No");
					return 0;
				}
			}
		}
		puts("Yes");
		return 0;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(str[i][j]==ch[0][0]){
				int flag=1;
				for(int k=0;k<m;k++){
					for(int b=0;b<m;b++){
						if(str[k+i][b+j]!=ch[k][b]){
							flag=0;
							break;
						}
					}
					if(flag==0){
						break;
					}
				}
				if(flag){
					puts("Yes");
					return 0;
				}
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
x = list(map(int, input().split()))

xmin = min(x)
xmax = max(x)

ans = sum([(i-xmax)**2 for i in x])

for j in range(xmin,xmax):
  ans = min(ans,sum([(i-j)**2 for i in x]))

print(ans)



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

int main(){
  string a,b;
  cin >> a >> b;
  int s=stoi(a+b);
  int i=1;
  bool flag=false;
  while(i*i<=s){
    if(i*i==s) {
      flag=true;
      break;
    }
    i++;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;   
    ll n,m,ans=0;
    scanf("%lld%lld",&n,&m);
    ll x[m],y[m];
    rep(i,0,m){
        scanf("%lld%lld",&x[i],&y[i]);
    }
    ll red[n],ball[n];
    red[0]=1;
    rep(i,1,n) red[i]=0;
    rep(i,0,n) ball[i]=1;
    
    rep(i,0,m){
            ball[y[i]-1]++;
            if(red[x[i]-1]) red[y[i]-1]=1;
            ball[x[i]-1]--;
            if(ball[x[i]-1]==0) red[x[i]-1]=0;
            // rep(j,0,n){
            //     printf("%lld %lld ||",ball[j],red[j]);
            // }
            // PN;
    }
    rep(i,0,n){
        if(red[i]) ans++;
    }
    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
/**
	Language: C++
	Author  : 21
**/

#include <bits/stdc++.h>

using namespace std;

#define FastIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define Debug(v) cerr << '\n' << #v << ":\t" << v << '\n'

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

int a[12][12], c[12];

int main() {
	FastIO();
	int n, m, x;
	cin >> n >> m >> x;
	int i, j, k;
	for (i = 0; i < n; ++i) {
		cin >> c[i];
		for (j = 0; j < m; ++j)
			cin >> a[i][j];
	}
	int ans = INT_MAX, co;
	vi al(m);
	for (i = 1; i < (1<<n); ++i) {
		al.assign(m, 0);
		co = 0;
		for (j = 0; j < n; ++j) {
			if (i & (1<<j)) {
				co += c[j];
				for (k = 0; k < m; ++k)
					al[k] += a[j][k];
			}
		}
		bool poss = true;
		for (j = 0; j < m; ++j) {
			if (al[j] < x) {
				poss = false;
				break;
			}
		}
		if (poss) {
			ans = min(co, ans);
		}
	}
	if (ans == INT_MAX) ans = -1;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d; ll g; cin >> d >> g;
  vector<ll> P(d), C(d);
  rep(i, d) cin >> P[i] >> C[i];
  ll ans = longinf;
  rep(i, 1<<d) {
    ll cur = 0;
    ll cnt = 0;
    set<int> se;
    rep(j, d) {
      if((i>>j)&1) {
        cur += P[j]*100*(j+1) + C[j];
        cnt += P[j];
      } else {
        se.insert(j);
      }
    }
    if(cur >= g) {
      ans = min(ans, cnt);
    } else {
      for(auto j: se) {
        if(cur+(P[j]-1)*100*(j+1) < g) continue;
        ans = min(ans, cnt+((g-cur)+(100*(j+1))-1)/(100*(j+1)));
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll n,W;
    cin>>n>>W;
    vl w(n),v(n);
    REP(i,n){
        cin>>w[i]>>v[i];
    }
    vvl dp(2,vl(n*1000+1000,INF));
    dp[0][0]=0;
    REP(i,n){
        REP(j,n*1000+1){
            chmin(dp[(i+1)%2][j+v[i]],dp[i%2][j]+w[i]);
            chmin(dp[(i+1)%2][j],dp[i%2][j]);
        }
    }
    REPR(i,n*1000+100){
        if(dp[n%2][i]<=W){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
typedef long long ll;

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
  int ans = b - (a - c);
  if(ans > 0)
    cout << ans << endl;   
  else
    cout << 0 << endl;

}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final int LEN = 41;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextLong();
		}
		
		long goal = 0;
		for(int i=2; i<N; i++)
			goal ^= A[i];
		
		System.out.println(solve(A[0], A[1], goal));
		sc.close();
	}
	
	static long solve(long a0, long a1, long goal) {
		
		long sum = a0+a1;
		if(sum < goal || ((sum-goal)&1)!=0)
			return -1;
		
		long and = (sum-goal)>>1;
		
		if((and&goal)!=0)
			return -1;
		
		if(and>a0)
			return -1;
		
		long after = and;
		for(int i=LEN-1; i>=0; i--) {
			if((goal&(1l<<i)) != 0) {
				if((after|(1l<<i)) <= a0) {
					after |= 1l<<i;
				}
			}
		}
		
		return after > 0 ? a0-after : -1;
	}
}


Measured memory_bytes: 27564
from bisect import bisect_left
A, B, Q = map(int, input().split())
S = [-float('inf')] + [int(input()) for i in range(A)] + [float('inf')]
T = [-float('inf')] + [int(input()) for i in range(B)] + [float('inf')]


for i in range(Q):
    x = int(input())
    Sx = bisect_left(S, x)
    Tx = bisect_left(T, x)
    S_w, S_e = S[Sx - 1], S[Sx]
    T_w, T_e = T[Tx - 1], T[Tx]

    S_wc, S_ec = abs(x - S_w), abs(x - S_e)
    T_wc, T_ec = abs(x - T_w), abs(x - T_e)

    west_only = max(S_wc, T_wc)
    east_only = max(S_ec, T_ec)
    west_east = 2 * min(S_wc, T_ec) + max(S_wc, T_ec)
    east_west = 2 * min(S_ec, T_wc) + max(S_ec, T_wc)

    print(min(west_only,
              east_only,
              west_east,
              east_west))


Measured memory_bytes: 14464
N = int(input())
T = list(map(int,input().split()))

M = int(input())
P = []
for i in range(M):
  P.append(list(map(int,input().split())))
  
SU = sum(T)

for i in range(M):
  print( SU - T[P[i][0]-1] + P[i][1] )

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();

        int a = 0;
        int b = 0;
        int c = 0;

        boolean isOk = false;
        for (int i = 0; i < n + 1; i++) {
            a = i;
            for (int j = 0; j < n - i + 1; j++) {
                b = j;
                c = n - a - b;
                if (10000*a + 5000*b + 1000*c == y) {
                    isOk = true;
                    break;
                }
            }
            if (isOk) break;
        }
        if (!isOk) {
            a = -1;
            b = -1;
            c = -1;
        }

        System.out.print(a);
        System.out.print(" ");
        System.out.print(b);
        System.out.print(" ");
        System.out.println(c);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
int GRID(int**matrix,int n,int m){

  ll dp[n][m];
  //base case
  memset(dp,0,sizeof(dp));
  for(int i=0;i<n;i++){
    if(matrix[i][0]==0){
      dp[i][0]=0;
      break;
    }
    else{
      dp[i][0]=1;
    }
  }

  for(int j=0;j<m;j++){
    if(matrix[0][j]==0){
      dp[0][j]=0;
      break;
    }
    else{
      dp[0][j]=1;
    }
  }

  //fill dp array
  for(int i=1;i<n;i++){
    for(int j=1;j<m;j++){
      if(matrix[i][j]==0){
        dp[i][j]=0;
      }else{
        dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD )%MOD;
      }
    }
  }

  return dp[n-1][m-1];


}

int main(){
  int n,m;
  cin>>n>>m;
  int**matrix=new int*[n];
  for(int i=0;i<n;i++){
    matrix[i]=new int[m];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      char x;
      cin>>x;
      if(x=='#'){
        matrix[i][j]=0;
      }else{
        matrix[i][j]=1;
      }
    }
  }

  int ans=GRID(matrix,n,m);
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int N;

int main() {
  cin >> N;

  for (int i = 1; i <= 9; i++) {
    if (N % i == 0 && 1 <= N / i && N / i <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int distance[]={6,7,5,5,20,15},money[6][6]={{300,500,600,700,1350,1650},{350,450,600,1150,1500},{250,400,1000,1350},{250,850,1300},{600,1150},{500}};
	int start,finish;
	while(cin>>start,start){
		int time[2][2];
		for(int i=0;i<2;i++)cin>>time[0][i];
		cin>>finish;
		for(int i=0;i<2;i++)cin>>time[1][i];
		int num=0;
		for(int i=start-1;i<finish-1;i++)num+=distance[i];
		bool kawa=0;
		for(int i=0;i<2&&!kawa&&num<41;i++)if(time[i][0]==18||time[i][0]==17&&time[i][1]>29||time[i][0]==19&&time[i][1]<31)kawa=1;
		num=money[start-1][finish-start-1];
		if(kawa){
			num/=2;
			if(num%50!=0)num+=25;
		}
		cout<<num<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)
int main(){
	int n;	cin>>n;
	map<int,int> d;
	rep(i,n){
		int a;	cin>>a;
		d[a]++;
	}
	int diff=n-d.size();
	if(diff&1)	diff++;
	cout<<n-diff<<endl;
	return 0;
}


Measured memory_bytes: 4992
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

#define MAX 999999

using namespace std;

int main()
{
    int n;
    static int num_prime[MAX+1];
    static bool not_prime_flag[MAX+1];

    for (int i = 2; i < MAX+1; ++i) {
        if(!not_prime_flag[i]){
            for (int j = 2; i*j < MAX+1; ++j) {
                not_prime_flag[i*j] = true;
            }
        }
        num_prime[i]=num_prime[i-1]+!not_prime_flag[i];
    }
    while (cin>>n){
        cout<<num_prime[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6044