akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll            long long
#define pb            emplace_back
#define fi            first
#define se            second
#define mp            make_pair
//#define int           int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = (int)2003;

int n, u, v, low[N], high[N], cnt[N], d[N];
vector<int> a[N], maxa[N];
string s;

void dfs(int u, int p) {
    maxa[u].clear(), high[u] = 0, cnt[u] = (s[u] == '1');
    int mxa = 0, dis, sum = 0, mx = 0;
    for(int v: a[u]) {
        if(v == p) continue;
        d[v] = d[u] + 1; dfs(v, u);
        cnt[u] += cnt[v], high[u] += (high[v] += cnt[v]);
        low[v] += cnt[v], mxa = max(mxa, low[v]);
        maxa[u].pb(high[v]);
    }
    low[u] = high[u];
    sort(maxa[u].begin(), maxa[u].end(), greater<int>());
    if(maxa[u].size() == 0) return;
    if(maxa[u].size() == 1) {
        for(int v: a[u]) {
            if(v == p) continue;
            low[u] = low[v];
        }
        return;
    }
    mxa = max(mxa, maxa[u][1]);
    for(int v: a[u]) {
        if(v == p) continue;
        dis = min(high[v], mxa - ((mxa - low[v]) & 1));
        mx = max(mx, dis); sum += dis;
    }
    low[u] = max((sum & 1), mx * 2 - sum);
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define FileName      "test"
    if(fopen(FileName".inp", "r")) {
       freopen(FileName".inp", "r", stdin);
       freopen(FileName".out", "w", stdout);
    }
    cin >> n >> s; s = ' ' + s;
    for(int i = 2; i <= n; ++i) {
        cin >> u >> v;
        a[u].pb(v), a[v].pb(u);
    }
    int res = 1e9;
    for(int i = 1; i <= n; ++i) {
        d[i] = 0; dfs(i, i);
        if(low[i] == 0 && high[i] % 2 == 0) res = min(res, high[i] / 2);
    }
    if(res == 1e9) res = -1;
    cout << res;
}


Measured memory_bytes: 768
N,M = map(int, input().split())
num_list = list(map(int, input().split()))
sum_num=sum(num_list)
sum=0
for i in range(N):
  item_no=num_list[i]
  if(item_no>=sum_num/(4*M)):
    sum=sum+1
if(sum>=M):
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 38384
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    S=list(input())
    while True:
        S.pop(-1)
        l=len(S)
        if S[:l//2]==S[l//2:]:
            print(l)
            break



resolve()

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  rep(i,h) cin >> a[i];

  rep(i,h){
    rep(j,w){
      if(a[i][j] == '#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }

  rep(i,h){
    if(row[i]){
      rep(j,w){
        if(col[j]){
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}


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

int main(){
    int N;
    cin >> N;

    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }

    int count = 0;
    
    for(int i = 1; i < N; i++){
        bool flg = true;

        for(int j = 0; j < i; j++){
            if(H.at(i) < H.at(j)){
                flg = false;
            }
        }

        if(flg) count++;
    }
    cout << count+1 << endl;
}

Measured memory_bytes: 256
import collections
import sys

n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

ct=collections.Counter(t)
cd=collections.Counter(d)
cct=list(ct.items())
#print(cc)
if n < m:
    print('NO')
else:
    for i in range(len(cct)):
        if cd[cct[i][0]]<cct[i][1]:
            print('NO')
            sys.exit()
    print('YES')

Measured memory_bytes: 68848
package main

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

type node struct {
	childEdges []int
}

type edge struct {
	from int
	to   int
}

var n int
var nodes map[int]*node
var edges []*edge
var colors []int
var colorSize int

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	nodes = map[int]*node{}
	edges = make([]*edge, n-1)
	colors = make([]int, n-1)
	for i := range edges {
		var a, b int
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ = strconv.Atoi(sc.Text())
		edges[i] = &edge{a, b}
		_, exists := nodes[a]
		if !exists {
			nodes[a] = &node{[]int{}}
		}
		_, exists = nodes[b]
		if !exists {
			nodes[b] = &node{[]int{}}
		}
		nodes[a].childEdges = append(nodes[a].childEdges, i)
	}
	// pp.Print(edges)
	abc146d()
	fmt.Println(colorSize)
	for _, color := range colors {
		fmt.Println(color)
	}
}

func abc146d() {
	// pp.Print(nodes)
	current := 1
	parentColor := 0
	setColor(current, parentColor)
}

func setColor(current int, parentColor int) {
	color := 1
	for _, e := range nodes[current].childEdges {
		if color == parentColor {
			color++
		}
		colors[e] = color
		if color > colorSize {
			colorSize = color
		}
		setColor(edges[e].to, color)
		color++
	}
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  int Q, H, S, D; cin >> Q >> H >> S >> D;
  int N; cin >> N;
  H = min(H, 2 * Q);
  S = min(S, 2 * H);
  D = min(D, 2 * S);
  cout << (N / 2) * D + (N % 2 == 1 ? S : 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
void solve(const vector<int> &v){

}
int main(){
  int N;  cin>>N;
  vector<ll> A(N), B(N+1, 0);
  B[0] = 3;
  rep(i,0,N) cin>>A[i], A[i]++;
  ll ans = 1;
  rep(i,0,N){
    ans *= B[A[i]-1] % mod;
    ans %= mod;
    B[A[i]-1]--;
    B[A[i]]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
// All Heil Fire Lord Zuko

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

const int N = 3 * 100 * 1000 + 19;

int n;
int a[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < 3 * n; i++)
        cin >> a[i];
    sort(a, a + (3 * n), greater<int>());
    LL cnt = n, ans = 0;
    for (int i = 1; i < 3 * n; i += 2)
        if (cnt)
            ans += a[i], cnt--;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
N=int(input())
A=list(map(int,input().split()))
from fractions import gcd
gcd_l=[0]
gcd_r=[0]
for i in range(N):
    gcd_l.append(gcd(gcd_l[i],A[i]))
    gcd_r.append(gcd(gcd_r[i],A[-(i+1)]))
gcd_r=gcd_r[::-1]
ans=[]
for i in range(N):
    ans.append(gcd(gcd_l[i],gcd_r[i+1]))
print(max(ans))

Measured memory_bytes: 14076
#include<bits/stdc++.h>
#define ll long long int
#define pi pair<int,int>
#define eps 0.001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const int MAXN = 1e6 + 5;

void cp()
{
    long double a, b;
    cin >> a >> b;
    ll c = a * b + eps;
    cout << setprecision(0) << fixed << c;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

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

int main(){
    string S;
    cin>>S;

    sort(S.begin(),S.end());
    if(S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {

        int digitSums = 0;
        int input = int.Parse(Console.ReadLine());
		int num = input;
        while (input > 0)
        {
            digitSums += (input % 10);
            input /= 10;
        }
		int remainder = num % digitSums;

        //出力
		if(remainder==0){
			Console.WriteLine("Yes");
		}
		else{
			Console.WriteLine("No");
		}


    }
}


Measured memory_bytes: 11092
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

int N;

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N;
	cout<<(N*N*N)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll n, m, l, q;
VVP G;
VVL ans;
constexpr ll INF = 1e15;
typedef tuple<ll,ll,ll> nakiri; // cnt, dist, idx

void dijkstra(vector<vector<pair<ll,ll>>> G, vector<ll> &cnt, vector<ll> &d, ll srt){
    priority_queue<nakiri, vector<nakiri>, greater<nakiri>> que;
    que.push({0, 0, srt});
    d[srt] = 0;
    cnt[srt] = 0;
    while(!que.empty()){
        auto q = que.top();
        que.pop();
        if(get<0>(q) > cnt[get<2>(q)]) continue;
        if(get<0>(q) == cnt[get<2>(q)] && get<1>(q) > d[get<2>(q)]) continue;
        for(auto g : G[get<2>(q)]){
            if(g.second > l) continue;
            ll next_d = get<1>(q) + g.second;
            ll next_cnt = get<0>(q);
            if(next_d > l) {
                next_d = g.second;
                next_cnt++;
            } 
            if(cnt[g.first] < next_cnt) continue;
            if(cnt[g.first] == next_cnt && d[g.first] <= next_d) continue;
            cnt[g.first] = next_cnt;
            d[g.first] = next_d;
            que.push({cnt[g.first], d[g.first], g.first});
        }
    }
}

int main(){

    // input
    cin >> n >> m >> l;
    G.resize(n);
    rep(i, 0, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    
    // dijkstra from all nodes
    ans.resize(n, VL(n));
    rep(i, 0, n) {
        VL cnt(n, INF), d(n, INF);
        dijkstra(G, cnt, d, i);
        rep(j, 0, n) ans[i][j] = cnt[j];
    }

    // query
    cin >> q;
    rep(i, 0, q){
        ll s, t;
        cin >> s >> t;
        s--; t--;
        cout << (ans[s][t] >= INF ? -1 : ans[s][t]) << endl;
    }

    return 0;
}

Measured memory_bytes: 9256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

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

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

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

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt64

func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	n := nextInt()
	a := nextInts(n)
	sort.Ints(a)
	if a[0] == 0 {
		fmt.Println(0)
		return
	}
	max := a[len(a)-1]
	ans := 0
	check := make([]bool, max+1)
	for i := 0; i < n; i++ {
		if check[a[i]] {
			continue
		} else {
			if i < n-1 && a[i] == a[i+1] {
				check[a[i]] = true
				m := a[i]
				for m <= max {
					check[m] = true
					m += a[i]
				}
				continue
			}
			ans++
			m := a[i]
			for m <= max {
				check[m] = true
				m += a[i]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6116
#include<iostream>
#include<algorithm>
using namespace std;
int main(int,char**){
    string s,sl,t;
    cin>>s;cin>>t;
    sl=s;
    transform(sl.begin(),sl.end(),sl.begin(),[](unsigned char c){ return tolower(c); });
    if(s==sl&&s.size()>=1&&s.size()<=10&&
        s.size()+1==t.size()&&s==t.substr(0,s.size())){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
        
    }
}

Measured memory_bytes: 3628
N, K = map(int, input().split())
# aで1~Nまでの数を割っていったときにK以下はいくつあるか？


def f(a, n, k):
    syou, amari = divmod(n, a)
    one_syou = max(a - k, 0)
    plus = max(amari+1 - k, 0) if k != 0 else amari
    # print(syou, amari, one_syou, plus)
    return syou * one_syou + plus


ans = 0
for a in range(max(K, 1), N+1):
    ans += f(a, N, K)
    # print(a, f(a, N, K))

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  
  ll D;
  cin >> D;
  ll c[26];
  ll s[366][26];
  
  for(i=0; i<26; i++) cin >> c[i];
  for(i=0; i<D; i++) {
    for(j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  
  srand((unsigned)time(NULL));
  for(i=0; i<D; i++) pt((ll)(1+26*(rand()/(RAND_MAX+1.0))));
  
  
  
}



Measured memory_bytes: 3664
n = int(input())
y = 0
if  n==2 or n==4 or n==5 or n== 7 or n==9:
    y =0
elif n==0 or n==1 or n==6 or n==8:
    y = 1
else:
    y = 2
 
f = n%10
if f==2 or f==4 or f==5 or f== 7 or f==9: 
    print('hon')
elif f==0 or f==1 or f==6 or f==8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#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)


using namespace std;
using ll = long long;

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 main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin >> a >> b >> c >>k;
    if(k <= a){
        cout << k << endl; 
        
    } else if(k <=a+b){
        cout << a << endl;
    }else {
        cout << 2*a+b-k <<endl;
    }


   

    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MAXN = 21, MOD = 1e9 + 7;

int N, a[MAXN][MAXN];
vector<ll> dp;

ll pairs(int mask) {
    if (mask == 0)
        return 1;
    if (dp[mask] == -1) {
        dp[mask] = 0;
        int i = __builtin_popcount(mask) - 1;
        for (int j = 0; j < N; j++)
            if (a[i][j] && (mask & (1 << j)))
                dp[mask] = (dp[mask] + pairs(mask & ~(1 << j))) % MOD;
    }
    return dp[mask];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> a[i][j];
    dp.assign(1 << N, -1);
    cout << pairs((1 << N) - 1) << endl;
}


Measured memory_bytes: 16640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
   
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
                String spl[] = line.split(" ");
                int nen=Integer.parseInt(spl[0]);
                int getu=Integer.parseInt(spl[1]);
                int hi=Integer.parseInt(spl[2]);
                int mix = nen*10000+getu*100+hi;
                if(mix<18680908){System.out.println("pre-meiji");continue;}
                if(18680908<=mix&&mix<19120730){//meiji
                    int newNen=nen-1867;
                    System.out.println("meiji "+newNen+" "+getu+" "+hi);
                }else if(19120730<=mix&&mix<19261225){//taisho
                    int newNen=nen-1911;
                    System.out.println("taisho "+newNen+" "+getu+" "+hi);
                }else if(19261225<=mix&&mix<19890108){//showa
                    int newNen=nen-1925;
                    System.out.println("showa "+newNen+" "+getu+" "+hi);
                }else{//heisei
                    int newNen=nen-1988;
                    System.out.println("heisei "+newNen+" "+getu+" "+hi);
                }
                
             } br.close();
            
         }catch(Exception e){e.printStackTrace();}         
     }  
    
     
     
}
 

Measured memory_bytes: 16916
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	vector<ll> abc(3);
	abc[0] = a; abc[1] = b; abc[2] = c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	else {
		sort(abc.begin(), abc.end());
		cout << abc[0] * abc[1] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    int cnt=0;
    bool ok=false;
    for(int i=0;i<n;i++){
        if(a[i]==i&&!ok){
            cnt++;
            ok=true;
        }
        else ok=false;
    }
    cout << cnt << endl;
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    ll sum = 0;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    ll ans = -1, mn = L_INF;
    for (ll i = 0; i < N; i++) {
        if (abs(sum - A[i] * N) < mn) {
            ans = i;
            mn = abs(sum - A[i] * N);
        }
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7;

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

int main() {
    int n, q;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];
    cin >> q;
    vector<int> qs(q);
    REP(i, q) cin >> qs[i];
    vector<int> comb;
    REP(S, (1<<n)) {
        int res = 0;
        REP(i, n) {
            if (S & (1<<i)) res += A[i];
        }
        comb.push_back(res);
    }
    REP(i, q) {
        REP(j, (int)comb.size()) {
            if (qs[i] == comb[j]) {
                cout << "yes" << endl;
                break;
            }
            if (j == (int)comb.size()-1) {
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 7084
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int a[1000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, cnt = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++){
		int j = i, k = i;
		while(a[j] <= a[j + 1] && j < n)
			j++;
		while(a[k] >= a[k + 1] && k < n)
			k++;
		i = max(j , k);
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
N, A, B = map(int, input().split())

if (A + B > N + 1) or (A * B < N):
    print(-1)
    exit()


distributes = [1] * A
remain = N - A
for i in range(A):
    d = min(remain, B - 1)
    distributes[i] += d
    remain -= d

marker = 1
ans = []
for d in distributes:
    ans.extend(list(range(marker, marker + d))[::-1])
    marker += d
print(*ans, sep=' ')


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

using namespace std;

int main()
{
    set <int> A;
   int a, b, c;
   cin>>a>>b>>c;
   A.insert(a);
   A.insert(b);
   A.insert(c);
   cout<<A.size()<<endl;
   return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
l=[0]*(n+1)
mod=10**9+7
M=set([int(input()) for _ in range(m)])
for i in M:
    l[i]=-1
l[0]=1
for i in range(n):
    if l[i]!=-1:
        if l[i+1]!=-1:
            l[i+1]=(l[i+1]+l[i])%mod
        if i+2<=n:
            if l[i+2]!=-1:l[i+2]=(l[i+2]+l[i])%mod
print(l[n])

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

int main(){
  int L,R,d;
  cin >> L >> R >> d;
  int count = 0;
  for(int i = L; i < R+1; i++){
    if(i%d == 0){
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3592
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N, M;
	cin >> N >> M;

	if (abs(N - M) <= 1) {
		long long ans = 1;
		for (long long i = 1; i <= N; ++i) {
			ans = (ans * i) % MOD;
		}
		for (long long i = 1; i <= M; ++i) {
			ans = (ans * i) % MOD;
		}
		if ((N + M) % 2 == 0) {
			ans = (ans * 2) % MOD;
		}

		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 3608
from collections import Counter
import itertools as it
MOD = 10 ** 9 + 7
n = int(input())
s = input()

b = Counter(s)
c = list(b)

ans = 1
for i in b:
    ans = ans * (b[i]+1) % MOD
    
print((ans + MOD - 1) % MOD)

Measured memory_bytes: 39280
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  {[ss] <- getInts
  ; let (mm,s) = ss `divMod` 60
  ; let (h,m)  = mm `divMod` 60
  ; putStrLn (intercalate ":" (map show [h,m,s]))
  }

getInts :: IO [Int]
getInts = do
  { line <- getLine
  ; let ints = map readInt (words line)
  ; return ints
  }

getInts' :: IO [Int]
getInts' = do
  { line <- getLine
  ; return (map readInt (words line))
  }

getInts'' :: IO [Int]
getInts'' = map readInt . words <$> getLine

readInt :: String -> Int
readInt = read

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

int main(){
  int N;
  int ans=0;
  cin>>N;
  vector<int> V(N);
  vector<int> C(N);
  vector<int> SA(N);
  for(int i=0;i<N;i++) cin>>V.at(i);
  for(int i=0;i<N;i++){
    cin>>C.at(i);
    SA.at(i)=V.at(i)-C.at(i);
    if(SA.at(i)>0) ans+=SA.at(i);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
list = [int(j) for j in input().split()]
ans = 0
while True:
  cnt = 0
  for i in range(N):
    if list[i] == 0:
      break
    if list[i] % 2 == 0:
      list[i] /= 2
      cnt += 1  
  if cnt == N:
    ans += 1
  else:
    print(ans)
    break

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long int;
using ll = long long int;

struct UnionFind {
    vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(
        int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {  // xとyの木を併合
        int rx = root(x);       // xの根をrx
        int ry = root(y);       // yの根をry
        if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] =
            ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        // cout << i << endl;
        tree.unite(x - 1, y - 1);
    }

    std::set<int> s;
    vector<int> baketu(n, 0);
    for (int i = 0; i < n; i++) {
        baketu[tree.root(i)]++;
    }
    auto iter = std::max_element(baketu.begin(), baketu.end());
    cout << *iter << endl;

    return 0;
}

Measured memory_bytes: 10980
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  cout<<180*(n-2)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    string s;
    cin >> N >> s;
    ll r = 0;
    rep(i, N) {
        if (s[i] == 'R') r++;
    }
    if (r > N-r) {
        yes;
    } else {
        no;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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 main(){
    int N, M;
    cin >> N >> M;

    if (N % 2 == 0){
        for (int i = 1; i <= M; ++i){
            if (i <= N / 4) {
                cout << i << " " << N + 1 - i << endl;
            } else{
                cout << i << " " << N - i << endl;
            }
        }
    } else{
        REP(i, 0, M){
            cout << i + 1 << " " << N - i << endl;
        }
    }

    return 0;
}


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

int main() {
  int n; string s; cin >> n >> s;

  int x = 0;
  for (int i=0; i<n; i++){
  if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') x++;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	count := 0
	fmt.Scan(&s, &t)
	tSlice := strings.Split(t, "")

	for pos, value := range s {
		// valueはrune
		if string(value) != string(tSlice[pos]) {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 6752
// Subset-Sum Correlated with Knapsack Problem because of lower Prices and higher weights
#include "bits/stdc++.h"
using namespace std;
long long dp[101][100001];
pair<int,int> Array[101];

int FindMaximumValue( int N , int W , int MaxValue ){
    int i , j , Ans = 0;
    
    for( i = 0 ; i <= N ; ++i ){
        dp[i][0] = 0LL;

        for( j = 1 ; j <= MaxValue ; ++j )
            dp[i][j] = -1LL;
    }

    for( i = 1 ; i <= N ; ++i ){
        for( j = 1 ; j <= MaxValue ; ++j ){
            if( Array[i].first <= W && Array[i].second <= j ){
                if( dp[i - 1][j - Array[i].second] != -1 ){ 
                    if( dp[i - 1][j - Array[i].second] + Array[i].first <= W )
                        dp[i][j] = dp[i - 1][j - Array[i].second] + Array[i].first;
                }
            }

            if( dp[i - 1][j] != -1 ){
                if( dp[i][j] == -1 ) dp[i][j] = dp[i - 1][j];
                else dp[i][j] = min( dp[i - 1][j] , dp[i][j] );
            }

            if( dp[i][j] != -1 ) Ans = max( Ans , j );
        }
    }

    return Ans;
}

int main(){
    int N , W , i , Total = 0;
    scanf( "%d%d" , &N , &W );

    for( i = 1 ; i <= N ; ++i ){
        scanf( "%d%d" , &Array[i].first , &Array[i].second );
        Total += Array[i].second;
    }    

    printf( "%d\n" , FindMaximumValue( N , W , Total ) );
    return 0;
}

Measured memory_bytes: 79104
import java.util.Scanner;
import java.lang.Math;

class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	Double r=sc.nextDouble();
	System.out.printf("%7f %7f\n",r*r*Math.PI,r*2.0*Math.PI);
    }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    string s;
    cin >> s;

    int red = 0;
    int blue = 0;

    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') {
            red++;
        } else {
            blue++;
        }
    }

    if (red > blue) {
        Yes;
    } else {
        No;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000
 
int cnt = 0;
int a[N];
 
void insertionSort(int a[], int n, int g)
{
    int v;
    int i, j;
 
    for(i = g; i < n; i++) {
        v = a[i];
        j = i - g;
        while(j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j + g] = v;
    }
}
 
void shellSort(int a[], int n)
{
    int i,m = 14;
    int G[] = {1, 4, 14, 56, 131, 544, 2093, 4580, 10383, 29224, 98572, 332242, 898323,1267543};
    cnt = 0;
    
    while(G[m-1] > n) m--;
    printf("%d\n",m);
    printf("%d", G[m-1]);
    for(i = m - 2; i >= 0; i--) printf(" %d", G[i]);
    printf("\n");
    for(i=m-1; i>=0; i--) {
        insertionSort(a, n, G[i]);
    }
}
 
int main()
{
    int i, n;
 
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    printf("\n");
    shellSort(a, n);
    printf("%d\n", cnt);
    for(i=0; i<n; i++) printf("%d\n", a[i]);
    return 0;
}


Measured memory_bytes: 5600
#include<stdio.h>
int main()
{
	int n, i, pa = 0, pb = 0, a[10000] = {}, b[10000] = {};
	while (scanf("%d", &n))
	{
		if (n == 0) break;
		for (i = 0; i < n; i++)
		{ 
			scanf("%d %d", &a[i],&b[i]);
			if (a[i] > b[i]){ pa += a[i] + b[i]; }
			else if (a[i] < b[i]){ pb += a[i] + b[i]; }
			else if (a[i] == b[i]){ pa += a[i]; pb += b[i]; }
		}
		printf("%d %d\n", pa, pb);
		pa = 0;pb=0;
	}

	return 0;

}

Measured memory_bytes: 684
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c, x,y = f()
    ans = 0
    if 2*c <= a+b:
        ans += 2*c*min(x,y)
    else:
        ans += (a+b)*min(x,y)
    
    mxy = min(x,y)
    x -= mxy
    y -= mxy

    if x:
        if 2*c <= a:
            ans += x * 2*c
        else:
            ans += x * a
    if y:
        if 2*c <= b:
            ans += y* 2*c
        else:
            ans += y*b
    
    print(ans)


solve()


Measured memory_bytes: 3064
// AOJ 2161 Defend the Bases
// 2018.3.9 bal4u

#include <stdio.h>
#include <string.h>
#include <math.h>

#define MAX 210
int  hi[MAX], to[MAX][MAX];
char seen[MAX];
int  match[MAX];

int bpm(int u);
int bipartiteMatching(int m, int n, int V)
{
	int u, max;

	memset(match, -1, V*sizeof(int));
	max = 0;
	for (u = 0; u < m; u++) {
		memset(seen, 0, V);
		if (bpm(u)) max++;
	}
	return max;
}

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (match[v] < 0 || bpm(match[v])) {
			match[u] = v, match[v] = u;
			return 1;
		}
	}
	return 0;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define LIM 55
#define EPS 1e-8

typedef struct { int from, to; double d; } EDGE;
EDGE edge[10010], *tail;
typedef struct { int x, y, v; } TROOP;
TROOP troop[102];
typedef struct { int x, y; } BASE;
BASE  base[102];
int   N, M, V;

double dist(int t, int b) {	return hypot(troop[t].x-base[b].x, troop[t].y-base[b].y); }

int check(double md)
{
	EDGE *e;

	memset(hi, 0, V << 2);
	for (e = edge; e < tail; e++) {
		if (e->d < md+EPS) to[e->from][hi[e->from]++] = e->to;
	}
	return bipartiteMatching(N, M, V) == M;
}

int main()
{
	int i, j, lim;
	double lb, ub, md;
	EDGE *e;

	while (N = in()) {
		M = in(), V = N+M;
		for (i = 0; i < N; i++) troop[i].x = in(), troop[i].y = in(), troop[i].v = in();
		for (i = 0; i < M; i++) base[i].x = in(), base[i].y = in();

		e = edge; for (i = 0; i < N; i++) for (j = 0; j < M; j++) {
			e->from = i, e->to = N+j, e->d = dist(i, j) / troop[i].v, e++;
		}
		tail = e;

		lb = 0, ub = 15000;
		lim = LIM; while (lim--) {
			md = 0.5*(lb+ub);
			if (check(md)) ub = md; else lb = md;
		}
		printf("%.20lf\n", ub);
	}
	return 0;
}


Measured memory_bytes: 2092
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
     
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;				\
								 c>0?i<b:							\
								 i>b;								\
								 i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
     
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
     
//.....................
const int MAX = (int)2e5 + 5;
     
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
     
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

void solve();

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

class Mycin {
	bool flag = true;
public:
	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
	operator bool() {return flag;}
} mycin;

class Mycout {
public:
	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
	Mycout& operator << (const char c) {printf("%c", c); return *this;}
	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
} mycout;

#define cin mycin
#define cout mycout
#define endl '\n'


int H, W;
string a[105];

void solve() {
	cin >> H >> W;
	rep2(i, 1, H + 1) cin >> a[i];
	rep(j, W) {
		a[0] += '#';
		a[H + 1] += '#';
	}
	rep(i, H + 2) {
		a[i] = '#' + a[i] + '#';
	}
	rep(i, H + 2) cout << a[i] << endl;
} 


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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N], B[N], P[N];

int mat[1005][1005];
pint edges[N];
unordered_map<int, set<int>> m;

bool compare(vi a, vi b)
{
    return a[0] < b[0];
}

int lcm(int a, int b)
{
    return (a*b)/(__gcd(a,b));
}

int mypow(int a, int x)
{
    if(a<=1 || x==1) return a;
    if(x==0) return 1;

    int temp = mypow(a,x/2);
    if(x%2==0) return ((temp%mod) * (temp%mod))%mod;
    else return (a%mod * ((temp%mod) * (temp%mod))%mod)%mod;
}

int count_bits(int n)
{
    int cnt = 0;
    while(n)
    {
        n = n & (n-1);
        cnt++;
    }return cnt;
}

void bfs(int src, int n)
{
    unordered_map<int, bool> visited;
    for(int i=0;i<n;i++) visited[i] = false;
    queue<int> q;
    q.push(src);
    visited[src] = true;

    while(!q.empty())
    {
        int curr = q.front();
        q.pop();
        B[curr] -= min(B[curr], A[src]);
        //cout<<curr<<" "<<endl;

        for(auto neigh: m[curr])
        {
            if(visited[neigh] == false)
            {
                //cout<<neigh<<endl;
                q.push(neigh);
                visited[neigh] = true;
                m[src].erase(neigh);
                m[neigh].erase(src);
            }
        }
    }
}

void void_solve(int n)
{

}

int int_solve(int n)
{

}

string string_solve(string s, int x)
{

}

bool bool_solve(int n)
{

}

int32_t main()
{
    //code
	IOS;

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    t = 1;
    while(t--)
    {
        cin>>n;
        int arr[n][2];
        for(i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1];
        bool flag = false;
        for(i=0;i<n-2;i++)
        {
            if((arr[i][0] == arr[i][1]) && (arr[i+1][0] == arr[i+1][1])
                && (arr[i+2][0] == arr[i+2][1]))
            {
                cout<<"Yes"<<endl;
                flag = true;
                break;
            }
        }
        if(flag == false) cout<<"No"<<endl;
        //cout<<int_solve(n)<<endl;

        //if(bool_solve(n)) cout<<"YES"<<endl;
        //else cout<<"NO"<<endl;
        //void_solve(n);


    }

	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;


int main()
{
	fast;
	string s,t;
	cin>>s>>t;
	ll i;
	ll cnt=0;
	ll n=s.size();
	rep(i,n)
	{
		if(s[i]!=t[i])
		cnt++;
	}
	cout<<cnt<<Endl;
	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  int N, M; cin >> N >> M;
  vector<vector<int>> A(31, vector<int>(31, 0));
  // int A[31][31];
  for (int i = 1; i <= N; i++) {
    int Ki; cin >> Ki;
    for (int j = 1; j <= Ki; j++) {
      int aij; cin >> aij;
      A[i][aij] = 1;
    }
  }

  int count = 0;
  for (int j = 1; j <= M; j++) {
    bool flag = true;
    for (int i = 1; i <= N; i++) {
      if (A[i][j] != 1) { flag = false; break; }
    }
    if (flag)
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
int main() {
    int n; cin >> n;
    if(n % 1000 == 0) cout << 0 << endl; 
    else{
        int ans = 1000 - n % 1000;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3628