akhauriyash/Code-Regression huggingface dataset:
#unionfind
class UF:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self._root(self.table[x])
            return self.table[x]
    def find(self, x, y):
        return self._root(x) == self._root(y)
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
    def show(self):
        print(self.table)
    def data(self):
        res={}
        n=len(self.table)
        for i in range(n):
            res.update({i:[i] if self.table[i]<0 else [self.table[i]]})
        for i in range(n):
            res[res[i][0]]+=[i]
        for i in range(n):
            if len(res[i])==1:
                del res[i]
            else:
                del res[i][0]
        return list(res.values())

n,k,l=map(int,input().split())
pq=[list(map(int,input().split())) for _ in range(k)]
rs=[list(map(int,input().split())) for _ in range(l)]
auf=UF(n)
buf=UF(n)
for p,q in pq:
    auf.union(p-1,q-1)
for r,s in rs:
    buf.union(r-1,s-1)
key_list=[]
from collections import defaultdict
count=defaultdict(int)
for i in range(n):
    key=(auf._root(i),buf._root(i))
    key_list.append(key)
    count[key]+=1
ans=[0 for _ in range(n)]
for i,key in enumerate(key_list):
    ans[i]=str(count[key])
print(" ".join(ans))

Measured memory_bytes: 136960
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;
 
 
const int N = 2e5+5;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif
 
 
void solve(){
    int n; cin>>n;
    vector<pii> f;
    vector<pii> b;
    int ans = 0;
    For(i, 0, n){
        int l, r, k; cin>>k>>l>>r;
        ans += min(l, r);
        if(l > r){
            f.pb({l-r, k});
        }
        else if(r > l){
            b.pb({r-l, k});
        }
    }
    sort(all(f)); reverse(all(f));
    sort(all(b)); reverse(all(b));
    set<int> s;
    For(i, 1, sz(f)+1){
        s.insert(i);
    }
    for(pii p: f){
        int ex = p.F;
        int pos = p.S;
        auto it = s.upper_bound(pos);
        if(it == s.begin())
            continue;
        it--;
        ans += ex;
        s.erase(it);
    }
    while(s.size()){
        s.erase(s.begin());
    }
    For(i, sz(f)+1, n+1){
        s.insert(i);
    }
    for(pii p: b){
        int ex = p.F;
        int pos = p.S;
        auto it = s.upper_bound(pos);
        if(it == s.end())
            continue;
        ans += ex;
        s.erase(it);
    }
    cout<<ans;
}
 
 
signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 11176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	long long n, prev;
	cin >> n;
	set<long long>s;
	prev = n;
	s.insert(n);
	for (int i = 0; i <= 1000000; ++i) {
		if (prev % 2 == 0) { prev /= 2; }
		else { prev = 3 * prev + 1; }
		s.insert(prev);
		if (s.size() != i + 2) {
			cout << i + 2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0]; long a = tmp[1], b = tmp[2];
        int[] x = ReadIntArray();

        long cost = 0;
        for (int i = 0; i < n-1; i++)
            cost += Math.Min((x[i+1] - x[i])*a, b);

        WriteLine(cost);
    }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int id, from, to;
  Edge(int id, int from, int to) : id(id), from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(i, v1, v2));
    graph[v2].push_back(Edge(i, v2, v1));
  }
  return graph;
}

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

  int n;
  cin >> n;
  auto graph = ReadUndirectedGraph(n , n - 1, true);
  
  vector<int> colors(n - 1, -1);

  function<void(int, int, int)> dfs_fn = [&](int v, int p, int p_color) {
    int c = 1;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      if (c == p_color) c++;
      colors[e.id] = c;
      dfs_fn(e.to, v, c);
      c++;
    }
  };
  dfs_fn(0, -1, -1);

  int max_color = 0;
  for (int c : colors) max_color = max(c, max_color);
  cout << max_color << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << colors[i] << endl;
  }
}

Measured memory_bytes: 9216
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();
  let mut buf = String::new();
  stdin.read_line(&mut buf).unwrap();
  let mut ite = buf.trim().split_whitespace()
    .map(|x| x.parse::<usize>().unwrap());

  let n = ite.next().unwrap();
  let m = ite.next().unwrap();
  let l = ite.next().unwrap();

  let mut mat_a = vec![];
  let mut mat_b = vec![];

  let mut lines = stdin.lock().lines();

  for line in lines.by_ref().take(n) {
    let line = line.unwrap();
    let v = line.trim().split_whitespace()
      .map(|x| x.parse().unwrap())
      .collect::<Vec<u64>>();
    mat_a.push(v);
  }

  for line in lines.take(m) {
    let line = line.unwrap();
    let v = line.trim().split_whitespace()
      .map(|x| x.parse().unwrap())
      .collect::<Vec<u64>>();
    mat_b.push(v);
  }

  for i in 0..n {
    let mut v = vec![];
    for j in 0..l {
      let mut sum = 0;
      for k in 0..m {
        sum += mat_a[i][k] * mat_b[k][j];
      }
      v.push(sum.to_string());
    }
    let out = v.join(" ");
    println!("{}", out);
  }
}


Measured memory_bytes: 5060
#include <stdio.h>                                                                                                    2 #include   
 #include<iostream>
 #include <string>
 using namespace std;
  
  int main(){
     int d,i;
     string s = "Christmas";
     cin >> d;
    i = 25 -d;
    for(int j = 0;j < i;j++){
      s += " Eve";
    }
    cout << s << endl;
    return 0;
 }


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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)

typedef pair<int, int> P;

const int inf = 1 << 25;

struct edge
{
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

vector< vector<edge> > graph;
vector< vector<int> > mincost;

void dijkstra(int s)
{
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  mincost[s][s] = 0;
  while(!que.empty()) {
    int cost, now;
    tie(cost, now) = que.top(); que.pop();
    if(mincost[s][now] < cost) continue;
    for(edge& e : graph[now]) {
      if(e.cost + cost < mincost[s][e.to]) {
	mincost[s][e.to] = e.cost + cost;
	que.push(P(mincost[s][e.to], e.to));
      }
    }
  }
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, R;
  cin >> N >> R;
  graph.resize(N);
  rep(i, R) {
    int s, t, d;
    cin >> s >> t >> d; s--, t--;
    graph[s].emplace_back(t, d);
    graph[t].emplace_back(s, d);
  }

  mincost.resize(N, vector<int>(N, inf));
  int maxdist = 0;
  rep(i, N) dijkstra(i);
  rep(i, N) reps(j, i+1, N) maxdist = max(maxdist, mincost[i][j]);

  vector<P> ep;
  //vector<int> S, T;
  rep(i, N) reps(j, i+1, N) {
    if(mincost[i][j] == maxdist) {
      ep.emplace_back(i, j);      
      //S.push_back(i), T.push_back(j);
    }
  }

  vector<int> ans;
  rep(i, N) {
    bool flag = true;
    for(auto& p : ep) {
      //rep(j, S.size()) {
      int s, t; tie(s, t) = p;
      if(mincost[s][i] + mincost[i][t] == maxdist) {      
      //if(mincost[S[j]][i] + mincost[i][T[j]] == maxdist) {
	flag = false;
	//break;
      }
    }
    if(flag) ans.push_back(i+1);
  }
  
  cout << ans.size() << endl;
  rep(i, ans.size()) cout << ans[i] << endl;
  
  return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll 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>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  string s; cin >> s;
  int n = s.size();
  int ans = 0, acnt = 0;
  rep(i,n){
    dump(ans, acnt);
    if(s[i] == 'A'){
      acnt++;
      continue;
    }
    if(i < n-1 and s.substr(i,2) == "BC"){
      ans += acnt;
      i++;
      continue;
    }
    acnt = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
class Dice():
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    
    
    def diceMovement(self, step):
        self.step = step
        
        if self.step == 'E':
            temp = self.s1
            self.s1 = self.s4
            self.s4 = self.s6
            self.s6 = self.s3
            self.s3 = temp
            
            
        elif self.step == 'N':
            temp = self.s1
            self.s1 = self.s2
            self.s2 = self.s6
            self.s6 = self.s5
            self.s5 = temp
            
        elif self.step == 'S':
            temp = self.s1
            self.s1 = self.s5
            self.s5 = self.s6
            self.s6 = self.s2 
            self.s2 = temp
            
        else:
            temp = self.s1
            self.s1 = self.s3
            self.s3 = self.s6
            self.s6 = self.s4
            self.s4 = temp
            
            
            
    def getTop(self):
        return self.s1
        
        
def main():
    s1,s2,s3,s4,s5,s6 = map(int, input().split())
    dice = Dice(s1,s2,s3,s4,s5,s6)
    movement = str(input())
    
    for step in movement:
        dice.diceMovement(step)
        
    print(f'{dice.getTop()}')

if __name__ == '__main__': main()


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

	vector<ll> res(N, 101010101010);
	res[0] = 0;
	REP(i, N){
		if(i+1<N) res[i+1] = min(res[i+1], res[i]+abs(h[i+1]-h[i]));
		if(i+2<N) res[i+2] = min(res[i+2], res[i]+abs(h[i+2]-h[i]));
	}
	cout << res[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
### subroutines

def parse_decl(str)
  aname = str[$pos]
  $pos += 2
  num = parse_num(str)
  $pos += 1

  $decls[aname] = num
  true
end

def parse_asgn(str)
  aname = str[$pos]
  $pos += 2
  idx = parse_exp(str)
  return false if idx.nil? || $decls[aname].nil? || idx >= $decls[aname]
  $pos += 2
  
  val = parse_exp(str)
  return false if val.nil?

  $asgns[aname] = {} if $asgns[aname].nil?
  $asgns[aname][idx] = val
  true
end

def parse_exp(str)
  if str[$pos] >= '0' && str[$pos] <= '9'
    return parse_num(str)
  end

  aname = str[$pos]
  $pos += 2
  idx = parse_exp(str)
  $pos += 1

  if ! idx.nil? && ! $asgns[aname].nil? && ! $asgns[aname][idx].nil?
    return $asgns[aname][idx]
  end
  nil
end

def parse_num(str)
  num = 0
  while ! str[$pos].nil? && str[$pos] >= '0' && str[$pos] <= '9'
    num = num * 10 + (str[$pos].ord - '0'.ord)
    $pos += 1
  end
  num
end

### main

loop do
  $decls = {}
  $asgns = {}

  lines = []
  loop do
    line = gets.strip
    break if line == '.'
    lines << line
  end
  break if lines.empty?
  #p lines

  bug = nil

  for ln in (0...lines.length)
    line = lines[ln]

    if ! line.include?('=')
      $pos = 0
      parse_decl(line)
    else
      $pos = 0
      rc = parse_asgn(line)
      if ! rc
        bug = ln + 1
        break
      end
    end
  end

  puts (bug || 0)
end

Measured memory_bytes: 6128
#include<stdio.h>


int main(){

  int A[100],n,temp,i,j,flag=1,cnt=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  while(flag==1){
    flag=0;
    for(j=n-1;j>0;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	cnt++;
	flag=1;
      }
    }
  }

  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
def switches(N, M, array, P):
    count = 0
    for i in range(0,2**N):
        flag = 0
        for j in range(M):
            sum = 0
            for k in range(1,array[j][0]+1):
                if format(i, '0'+str(N)+'b')[array[j][k]-1] == '1':
                    sum += 1
            
            if sum%2 == P[j]:
                flag += 1
            
        if flag == M:
            count += 1

    return count


if __name__ == "__main__":
    N,M = map(int, input().split())
    array = []
    for i in range(M):
        array.append(list(map(int, input().strip().split())))
    P = list(map(int, input().strip().split()))
    print(switches(N,M,array,P))


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

int main(){
  string s,t;
  cin >> s >> t;
  
  rep(i,s.size()){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


void solve() {
    string s; cin >> s;
    ll n = s.size();
    ll p = 2019;
    vector<ll> a(n), sum(n+1);
    for (ll i = 0; i < n; ++i) {
        ll tmp = (ll)(s[i] - '0');
        a[i] = tmp * modpow(10LL, n-1LL-i, p);
        a[i] %= p;
        sum[i+1] = sum[i] + a[i];
        sum[i+1] %= p;
    }

    ll ans = 0;
    map<ll, ll> mp;
    for(int i = 0; i <= n; ++i){
        ans += mp[sum[i]];
        ++mp[sum[i]];
    }
    cout << ans << endl;
    return;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 6756
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, K = LI()
    A = LI()
    A.sort()

    print(sum(A[:K]))


main()


Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    cout << n * n * n << endl;
}


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

  return 0;
}



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

int main(){

  int a[5];

  for(int i=0;i<5;i++) cin >> a[i];

  sort(a,a+5);
  reverse(a,a+5);

  for(int i=0;i<4;i++) cout << a[i] << ' ';

  cout << a[4] << endl;
} 

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    i64 N,K,T,U,V,L;
    cin >> N >> K >> T >> U >>V >> L;
    priority_queue<pair<i64, int>, vector<pair<i64,int>>, greater<pair<i64, int>>> que;
    que.push({L, 0}); //goal
    for(int i = 0;i < N;i++){
        i64 a;cin >> a;
        que.push({a, 1});
    }
    int now_nizinn = 0;
    bool is_burst = false;
    i64 prev = 0;
    i64 kireru = 1e9;
    long double ans = 0.0;
    while(!que.empty()){
        pair<i64, int> q = que.top();
        que.pop();
        if(q.second == 0){
            //G
            ans += 1.0*(q.first - prev) / (is_burst ? V : U);
            break;
        }else if(q.second == 1){
            //ninnzinn
            ans += 1.0*(q.first - prev) / (is_burst ? V : U);
            if(now_nizinn == K){
                kireru = q.first + V * T;
                is_burst = true;
            }else{
                now_nizinn++;
            }
            if(now_nizinn && !is_burst){
                now_nizinn--;
                is_burst = true;
                kireru = q.first + V * T;
            }
            prev = q.first;
        }else{
            //kireru
            ans += 1.0*(q.first - prev) / (is_burst ? V : U);
            if(now_nizinn){
                now_nizinn--;
                kireru = q.first + V * T;
            }else{
                kireru = 1e9;
                is_burst = false;
            }
            prev = q.first;
        }
        if(is_burst){
            if(que.top().first > kireru){
                que.push({kireru, 2});
            }
        }
    }
    cout<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define YN(f) (f?"YES":"NO")
#define yn(f) (f?"Yes":"No")	
#define INF 123456789123456
#define MOD (int)(1e9+7)
#define MAX_N 100100
#define MAX_V 1

int temp[2][MAX_N], tt[MAX_N];
signed main(){
	int n, v, ma1=0,ma2=0, m1=0, m2=0, ans = 0;
	cin>>n;
	
	rep(i,n){
		cin>>v;
		if(i%2==0)temp[0][v]++;
		else temp[1][v]++;
	}
	
	for(int i = 1; i <= 100000; i++){
		if(ma1 < temp[0][i]){
			m1 = i;
			ma1 = max(ma1,temp[0][i]);
		}
		else if(ma2 < temp[1][i]){
			m2 = i;
			ma2 = max(ma2,temp[1][i]);
		}
		
	}
	
	ans = n-ma1-ma2;
	ma1 = ma2 = 0;
	
	for(int i = 1; i <= 100000; i++){
		if(ma2 < temp[1][i]){
			m2 = i;
			ma2 = max(ma2,temp[1][i]);
		}
		else if(ma1 < temp[0][i]){
			m1 = i;
			ma1 = max(ma1,temp[0][i]);
		}
		
	}
	
	ans = min(ans, n-ma1-ma2);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void DFS(int V,int P,vector<vector<int> > & GRAPH,vector<int> & B,vector<int> &W)
{
  B[V] = 1;
  W[V] = 1;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    int nV = GRAPH[V][i];
    if(nV == P )continue;
    DFS(nV,V,GRAPH,B,W);
    B[V] *= W[nV];
    B[V] %= MOD;
    W[V] *= W[nV] + B[nV];
    W[V] %= MOD;
  }
  
}
void solve(void)
{
  int N; cin>>N;
  vector<vector<int> > GRAPH (N);
  for (int i = 0; i < N-1; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
  }
    vector<int> WHITE (N,0);
    vector<int> BLACK (N,0);
  DFS(0,-1,GRAPH,BLACK,WHITE);
  cout<<(BLACK[0]+WHITE[0])%MOD<<endl;
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
using namespace std;

const int N = 1e5 + 10;
int n;
double a[4000], d[4000][4000], ans;
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> a[i];
    d[1][1] = a[1];
    d[1][0] = 1 - a[1];
    for(int i = 2; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            d[i][j] = d[i - 1][j - 1] * a[i] + d[i - 1][j] * (1 - a[i]);
        }
    }
    for(int i = n / 2 + n % 2; i <= n; i++)ans += d[n][i];
    printf("%.9f", ans);
}


Measured memory_bytes: 94208
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int k,x;
    cin >> k >> x;
    if (500*k>=x)
    {
        cout << "Yes" << endl;
    }   
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	double r, ans;
	cin >> r;
	ans = 2.0 * r * PI;
	printf("%.10lf\n", ans);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<int> a;
  rep(i,s.size()-2){
    int x = stoi(s.substr(i,3));
    a.push_back(abs(753-x));
  }
  sort(a.begin(),a.end());
  cout << a.at(0) << endl;
 }


Measured memory_bytes: 256
#include <iostream>
using namespace std; 
int main() {
    short n; 
    cin >> n;
    n = n%10; 
    if ( n == 3)
        cout << "bon"; 
    else if ((n == 0) || (n == 1) || (n == 6) || (n == 8) )
        cout << "pon"; 
    else {
        cout << "hon"; 
    }
    return 0; 
}


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

#define all(x) (x).begin(), (x).end()
#define pb push_back

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

const int mod=1e9+7;

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

	sort(a,a+n);
	if(n%2==1){
		if(a[0]!=0){
			cout<<0<<endl;
			return 0;
		}
		for (int i = 1; i < n; i+=2){
			if(a[i]!=a[i+1]){
				cout<<0<<endl;
				return 0;
			}
		}
	}else{
		for (int i = 0; i < n; i+=2){
			if(a[i]!=a[i+1]){
				cout<<0<<endl;
				return 0;
			}
		}
	}

	ll ans=1;
	for (int i = 0; i < n/2; ++i){
		ans*=2;
		ans%=mod;
	}


	cout<<ans<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;

  string a = s.substr(0, 4), b = s.substr(5, 2), c = s.substr(8, 2);

  if(a > "2019"){
    cout << "TBD" << endl;
    return 0;
  }
  if(b > "04"){
    cout << "TBD" << endl;
    return 0;
  }
  if(c > "30"){
    cout << "TBD" << endl;
    return 0;
  }
  cout << "Heisei" << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import product
import numpy as np

n, m, x = map(int, input().split())
cost = []
aaa = []

for _ in range(n):
    c, *a = map(int, input().split())
    cost.append(c)
    aaa.append(a)

cost = np.array(cost, dtype=np.int64)
aaa = np.array(aaa, dtype=np.int64)

ans = 10 ** 18
for books in product([True, False], repeat=n):
    books = list(books)
    if (aaa[books].sum(axis=0) >= x).all():
        ans = min(ans, cost[books].sum())
if ans == 10 ** 18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27364
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MOD = (int)1e9 + 7;
const double PI = acos(-1.0);


int32_t main(){
	int x, y;
	cin >> x >> y;
	
	for(int i = 0; i <= x; i++){
		if(i*2 + (x - i) * 4 == y){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	
	return 0;
}


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

using namespace std;


void solve() {
    int a, b;
    cin >> a >> b;
    if (a>=6 && a<= 12) {
        b/=2;
    }
    if (a < 6) b =0;
    cout << b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
int main() {
	char X, Y;
	cin >> X >> Y;
	if (X == Y) {
		cout << "=";
		return 0;
	}
	cout << (X < Y ? "<" : ">");
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut count: usize = 0;
    for a in 1..n {
        if n % a == 0 {
            count += n / a - 1;
        } else {
            count += n / a;
        }
    }
    count.to_string()
}


Measured memory_bytes: 2156
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;

int main() {
    //get input
    int n, k;
    cin >> n >> k;
    
    vector<int> prices(n);
    for (int i=0; i<n; ++i) {
        cin >> prices[i];
    }

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

    int total {0};

    for (int i=0; i<k; ++i) {
        total += prices[i];
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n;
signed main() {
	cin >> n;
	rep(i, (1 << n)) {
		vector<int>v;
		rep(j, n) {
			if ((i >> j) & 1)v.push_back(j);
		}
		if (i == 0)puts("0:");
		else {
			cout << i << ":";
			for (int x : v)cout << " " << x;
			cout << endl;
		}
	}
	return 0;
}


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

int g[100][100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, u, k, v;
    int i, j;
    cin>>n;
    for(i=0; i<n; i++) {
        cin>>u>>k;
        for(j=0; j<k; j++) {
            cin>>v;
            g[u-1][v-1]=1;
        }
    }
    for(i=0; i<n; i++) {
        cout<<g[i][0];
        for(j=1; j<n; j++) {
            cout<<' '<<g[i][j];
        }
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
int main()
{
  int p,yen,z,yu,x;
  scanf("%d",&yen);
  z=yen/500;
  yu=yen-z*500;
  x=yu/5;
  p=z*1000+x*5;
  printf("%d",p);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

using namespace std;

int main(){
    int X, Y;
    scanf("%d %d", &X, &Y);
    for (int i = 0; i <= X; i++) {
        int numOfLeags = i * 4 + (X - i ) * 2;
        if (numOfLeags == Y) {
            printf("Yes\n");
            return 0;
        } 
    }
    printf("No\n");
}


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

int main() {
	int n;
	int h[20];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	int max[20];
	max[0] = h[0];
	int highest = h[0];
	for (int i = 1; i < n; i++) {
		if (highest < h[i])
			highest = h[i];
		max[i] = highest;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (max[i] == h[i])
			ans++;
	cout << ans << endl;
	return 0;
}

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

long long fact(int n)
{
	return 1LL*n*(n-1);
}

int main()
{
	string s;
	map<string,int> str;
	long long T,sum = 0;
	long long a = 0;
	cin >> T;
	while(T--)
	{
		cin >> s;
		sort(s.begin(),s.end());
		map<string,int>::iterator iter;
		iter = str.find(s);
		if(iter != str.end())
		    str[s]++;
		else str[s] = 1;
	}
	map<string,int>::iterator iter;
	for(iter = str.begin(); iter != str.end(); iter++)
	{
		if(iter->second > 2)
		{
			a = fact(iter->second);
			sum += a/2;
		}
		if(iter->second == 2) sum += 1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 11136
#include <cstdio>

int a[105];

int main()
{
    //freopen("a.in", "r", stdin);
    int n, m, sum = 0;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int cnt = 0;
    for(int i = 0; i < n; i++)
    if(4 * m * a[i] >= sum) cnt++;
    puts(cnt < m ? "No" : "Yes");
    return 0;
}

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


signed main(){
    int A,B,K;
    cin >> A >> B >> K;
    for(int i=A;i<=B;i++){
        if(i-A<K||B-i<K){
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;

    return 0;
}


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

template <typename T>
void print(const T &v);

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> v;
    bool flag = true; // '1'が継続している間はtrue
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if ((flag && s[i] == '1') || (!flag && s[i] == '0'))
        {
            ++cnt;
        }
        else
        {
            v.push_back(cnt);
            cnt = 1;
            flag = !(flag);
        }
    }
    v.push_back(cnt);
    v.push_back(0);
    v.push_back(0);
    if (v.size() <= k * 2 + 1)
    {
        int total = 0;
        for (int num : v)
        {
            total += num;
        }
        cout << total << endl;
        return 0;
    }
    int total = 0;
    for (int i = 0; i < k * 2 + 1; i++)
    {
        total += v[i];
    }
    int maxi = total;
    for (int i = 0; i < v.size() - (k * 2) - 3; i += 2)
    {
        total -= v[i];
        total -= v[i + 1];
        total += v[i + 2 * k + 1];
        total += v[i + 2 * k + 2];
        maxi = max(maxi, total);
    }
    cout << maxi << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

using namespace std;
typedef vector<int> vi;
typedef long long ll;

bitset<10000010> bs;
vi primes;

void sieve(ll size){
  bs.set();
  bs[0] = bs[1] = 0;
  for(int i=2;i<=size;++i){
    if(!bs[i]) continue;
    for(int j=i*i;j<=size;j+=i) bs[j] = 0;
    primes.push_back(i);
  }
}

vi factors(ll n){
  vi fact;
  for(int i=0;i<primes.size();++i){
    int p = primes[i];
    if(n%p==0){
      while(n%p==0) n/=p;
      fact.push_back(p);
    }
  }
  if(n!=1) fact.push_back(n);
  return fact;
}


main(){
  sieve(32000);
  ll n, m;
  cin >> n >> m;
  vi f = factors(m);
  f.push_back(1);
  ll maxi = 1;
  for(ll i=0;i<(ll)f.size();++i){
    int val = f[i];
    for(ll j=val;j*j<=m;j+=val){
      if(m%j==0 and m/j >= n) maxi = max(maxi,j);
      ll val2 = m/j;
      if(m%val2==0 and m/val2 >= n) maxi = max(maxi,val2);
    }
  }
  cout << maxi << endl;
}

Measured memory_bytes: 1536
N,K=map(int,input().split())
listH=list(map(int,input().split()))
cost=[10**9]*N
cost[0]=0
for i in range(1,N):
  for k in range(1,K+1):
    if i-k>=0:
      cost[i]=min(abs(listH[i-k]-listH[i])+ cost[i-k],cost[i])
ans=cost[N-1]      
print(ans)

Measured memory_bytes: 52448
#include <iostream>
using namespace std;
int n;
int a,b,c,d;
char s[200000];
int main(){
    cin>>n>>a>>b>>c>>d;
    cin>>s;
    a--; b--; c--; d--;
    for(int i=a;i<c;i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout<<"No\n";
            return 0;
        }
    }for(int i=b;i<d;i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout<<"No\n";
            return 0;
        }
    }
    if(c<d){
        cout<<"Yes\n";
        return 0;
    }
    for(int i=b;i<=d;i++){
        if(s[i-1]==s[i]&&s[i]==s[i+1]){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}

int d[100][100];

void solve() {
	int n, m, l; 
	while (cin >> n >> m >> l, n) {
		rep(i, n) {
			rep(j, n) {
				if (i == j)d[i][j] = 0;
				else d[i][j] = mod;
			}
		}
		rep(i, m) {
			int u, v, x; cin >> u >> v >> x;
			d[u][v] = d[v][u] = x;
		}
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		vector<int> p(l), t(l);
		rep(i, l) {
			cin >> p[i] >> t[i];
		}
		rep(i, 2 * l + 2)G[i].clear();
		int ans = l;
		int s = 2 * l; int g = s + 1;
		rep(i, l) {
			rep(j, l) {
				if (i == j)continue;
				int dif = t[j] - t[i];
				if (dif >= 0) {
					if (dif >= d[p[i]][p[j]]) {
						add_edge(i, j + l, 1);
					}
				}
			}
		}
		rep(i, l) {
			add_edge(s, i, 1);
			add_edge(i + l, g, 1);
		}
		ans -= max_flow(s, g);
		cout << ans << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 30260
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	auto read = [](int n) {
		vector<int> v;
		while (n--)
			v.push_back(in());
		return move(v);
	};
	vector<int> a = read(in()), b = read(in()), r;
	set_intersection(a.begin(), a.end(), b.begin(), b.end(), inserter(r, r.end()));
	for (int x: r)
		outl(x);
}


Measured memory_bytes: 4664
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 998244353LL;
const double eps = 1e-7;
int N, M, K, Q, T;
ll gcd(ll a, ll b) {
	if (b == 0LL) return a;
	return gcd(b, a % b);
}
int A[3010];
ll dp[3010][3010];

int main()
{
	int i, j;
	int S;
	scanf("%d%d", &N, &S);
	for (i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (i = 1; i <= N; ++i) {
		if (i == 1) {
			dp[i][A[i]]++;
			continue;
		}
		for (j = S; j >= 1; --j) {
			dp[i][j] = dp[i - 1][j];
			if (j - A[i] > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j - A[i]]) % MOD;
		}
		dp[i][A[i]] = (dp[i][A[i]] + i) % MOD;
	}
	ll ans = 0LL;

	for (i = 1; i <= N; ++i) ans = (ans + dp[i][S]) % MOD;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 74376
#include <cstdio>
#include <algorithm>
using namespace std;

int a,b,tmp1,tmp2;

int main(void){
	scanf("%2d%2d",&a,&b);
	if(a<=12&&a>0)tmp1++;
	if(b<=12&&b>0)tmp2++;
	if(tmp1+tmp2==0){
		printf("NA");
		return 0;
	}
	if(tmp1+tmp2==2){
		printf("AMBIGUOUS");
		return 0;
	}
	if(tmp2==1){
		printf("YYMM");
		return 0;
	}
	printf("MMYY");
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int n,m;
int k[15];
int s[15][15];
bool p[15];

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	ll ans=0;
	
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<m;j++){
			bool cou=0;
			for(int l=0;l<k[j];l++){
				if(i>>s[j][l]&1){
					cou=!cou;
				}
				
			}
			if(cou!=p[j]){
				break;
			}
			if(j==m-1){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	string N;
	cin >> N;
	if (N[0] == '9' || N[1] == '9') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main(){
    ll n,ans=0,x,y;
    cin>>n;
    cout<<360/gcd(360,n);
}



Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;
//initialization here


//initialization finish


// your function is here

// your function finished

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	int a, b; cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;

	if (a > b) cout << "Alice" << endl;
	else if(b > a) Print("Bob");
	else Print("Draw");


	// your code finished
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int M; cin >> M;
  int result = 48-M;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256