akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 H, W;
  std::cin >> H >> W;
  std::vector<std::string> a;
  tools::read(a, H);

  std::unordered_map<char, i64> map;
  for (const std::string& a_i : a) {
    for (const char& a_ij : a_i) {
      ++map[a_ij];
    }
  }
  std::vector<i64> slots;
  slots.reserve(map.size());
  std::transform(map.begin(), map.end(), std::back_inserter(slots), [](const std::pair<char, i64>& pair) {
    return pair.second;
  });

  i64 fours = (H / 2 * 2) * (W / 2 * 2) / 4;
  i64 twos = ((H % 2) * W + (W % 2) * H - (H % 2) * (W % 2) * 2) / 2;
  i64 ones = (H % 2) * (W % 2);
  for (i64& slot : slots) {
    while (slot >= 4 && fours > 0) {
      slot -= 4;
      --fours;
    }
  }
  for (i64& slot : slots) {
    while (slot >= 2 && twos > 0) {
      slot -= 2;
      --twos;
    }
  }
  for (i64& slot : slots) {
    while (slot >= 1 && ones > 0) {
      --slot;
      --ones;
    }
  }

  std::cout << (fours == 0 && twos == 0 && ones == 0 ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a[] = new int[n];
        for(int i = 0;i < n;i++)a[i] = scan.nextInt();

        int t = 0; 
        for(int i = 0;i < n;i++){
            int minj = i;
            for(int j = i;j < n;j++){
                if(a[j] < a[minj])minj = j;
            }
            if(i != minj){
                int x = a[i];
                a[i] = a[minj];
                a[minj] = x;
                t++;
            }
        }

        for(int i = 0;i < n;i++){
            if(i != 0)System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println("\n" + t);

        scan.close();
    }

}


Measured memory_bytes: 26412
N,L=map(int,input().split())

sum=0
a=[]
for i in range(N):
     a.append(L+i)
if L<=0 and L+N-1>=0:
    for j in range(N):
        sum+=a[j]
    print(sum)
elif L>0:
    for j in range(N-1):
        sum+=a[j+1]
    print(sum)
else:
    for j in range(N-1):
        sum+=a[j]
    print(sum)

Measured memory_bytes: 3064
n, m = map(int, raw_input().split(" "))

switch = []
for i in range(0, m):
    s = map(int, raw_input().split(" "))
    switch.append(s[1:])

power = map(int, raw_input().split(" "))

ans = 0
for state_int in range(0, 2 ** n):
    format_str = "{:0" + str(n) + "b}"
    state_bin = format_str.format(state_int)
    # print(state_bin)

    state = [0 for j in range(0, len(state_bin))]
    for i in range(0, len(state)):
        if state_bin[i] == "1":
            state[i] = True
        else:
            state[i] = False

    # print(state)
    on = True
    for s in range(0, m):
        ts = switch[s]
        count = 0

        for j in range(0, len(ts)):
            if state[ts[j] - 1]:
                count += 1

        if power[s] != count % 2:
            on = False
            break

    if on:
        # print(state_bin)
        ans += 1

print(ans)


Measured memory_bytes: 2696
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n, i, k, len, flag;
	cin >> n;
	string s[n];
	char a;
	getline(cin,s[0]);
	getline(cin,s[0]);
	len=s[0].length();
	a=s[0][len-1];
	flag=1;
	for(i=1;i<n;i++)
	{
		getline(cin,s[i]);
	    len=s[i].length();
	   	if(s[i][0]!=a)
	   	{
	   		flag=0;
		}
	   	for(k=0;k<i;k++)
	   	{
	   	    if(s[i]==s[k])
	   	    {
	   	    	flag=0;
	        }
	    }
	    a=s[i][len-1];
	}
	if(flag==0)
	   	cout << "No";
	else
	   	cout << "Yes";
	return 0;
}


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

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

   int odd = 0;
   for (int i = 1; i <= n; i++) {
       if (i % 2 == 1) {
           odd++;
       }
   }

   double ans;
   ans = (double)odd / n;

   printf("%.10lf\n", ans);

   return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    int x, n ;
    cin >> x >> n ;
    vint a(n) ;
    REP(i,n){
        cin >> a[i] ;
    }
    sort(ALL(a)) ;
    vint vec = {-1,1} ;
    int j = 0 ;
    while(1){
        int tmp ;
        REP(i,2){
            tmp = x + j*vec[i] ;
            if(!BS(ALL(a),tmp)){
                cout <<tmp <<endl;
                return 0 ;
            }
        }
        j++ ;
    }




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	mp := make(map[int]int)
	for i := 0; i < n; i++ {
		x := nextInt()
		mp[x]++
	}
	ok := true
	m := nextInt()
	for i := 0; i < m; i++ {
		x := nextInt()
		if mp[x] <= 0 {
			ok = false
		}
		mp[x]--
	}
	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

typedef long long ll;
// int = ll;

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

	ll a,b;
	
	cin >> a >> b;
	
	if(a<=9&&b<=9){
		cout << (a*b) << endl;
	}else{
		cout << -1 << endl;
	}

return 0;	
}


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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = (y); x <= (z); x++)
#define REPP(x, y, z) for(int x = (y); x >= (z); x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn
#define IOS ios::sync_with_stdio(false); cin.tie(0);

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	IOS;

	map<string ,int> mp;
  	bool flag = true;
  
  	int n;
  	string num;
  	cin >> n;
  	REP(i, 1, n)
    {
      cin>>num;
      if(mp[num])
        flag = false;
      else
        mp[num]++;
    }
  
	if(flag)
      cout << "YES\n";
  else
    cout << "NO\n";
	return 0;
}


Measured memory_bytes: 22144
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int cnt = 0;
    int ans = n;
    for(int i=0; i<n; ++i){
        if(s[i] == 'S'){
            ++ cnt;
        }
        else if(cnt > 0){
            -- cnt;
            ans -= 2;
        }

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import copy
import itertools

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

def check(c, k):
  cnt = 0
  for i in range(len(c)):
    cnt += c[i].count('#')
  if cnt == k:
    return True
  else:
    return False

def make_list(c, h, w):
  for h_ in h:
    c[h_] = ['*'] * len(c[h_])
  for w_ in w:
    for i in range(len(c)):
      c[i][w_] = '*'
  return c

cnt = 0

for i in range(h):
  h_comb = list(itertools.combinations(range(h), i))
  for j in range(w):
    w_comb = list(itertools.combinations(range(w), j))
    for h_ in h_comb:
      for w_ in w_comb:
        c_ = copy.deepcopy(c)
        c_ = make_list(c_, h_, w_)
        if check(c_, k):
          cnt += 1

print(cnt)

Measured memory_bytes: 9316
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    char s[201], t[101], p[101];

    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);

    if(strstr(s, p) == NULL) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1132
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;


int digit(long long x){
    int count = 0;
    while(x > 0){
        count++;
        x /= 10;
    }
    return count;
}

int main(){
long long n;
cin >> n;
long long a;
int digit_a, digit_b;
int ma = 0, ans = 12;

for(long long i = 1; i*i <= n; i++){
    if(n%i == 0){
        a = n/i;

        digit_a = digit(a);
        digit_b = digit(i);
        ma = max(digit_a, digit_b);
        ans = min(ans, ma);
    }
}

cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

//
//(0, 0) (1, 1) (2, 2)
//(1, 0) (2, 1) (3, 2)
//(2, 0) (3, 1) (4, 2)
//(3, 0) (4, 1) (5, 2)

//1 1  1  1=> 4
//1 2  3  4=> 10
//1 3  6 10=> 20
//1 4 10 20=> 35
//1 5 15 35
ll power(ll x, ll pw, ll mod) {
    ll res = 1;
    x = x % mod;  // if it x >= p
    while (pw > 0) {
        if (pw & 1)
            res = (res*x) % mod;
        pw /= 2;
        x = (x*x) % mod;
    }
    return res;
}
ll modInverse(ll n, ll p) {
    return power(n, p-2, p) % p; // Fermat's little theorem
}
ll nCr(ll n, ll m, ll mod=1e9+7) {
    m = min(m, n-m);
    if (m == 0) return 1;
    ll num = 1, dem = 1;
    for(ll i = 1; i <= m; i++) {
        num = (num*(n+1-i)) % mod;
        dem = (dem*(i)) % mod;
    }
    return (num * modInverse(dem, mod)) % mod;
}

ll sub(ll r, ll c) {
    ll mod = 1e9 + 7;
    // sum(r=0) = nCr(r=1+(c-1), c-1)
    ll acc = nCr(r+c+2, r+1) - 1;
    // cout << "ret = " << acc << endl;
    return (acc + mod)% mod;
}
int main() {
    ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll mod = 1e9 + 7;
    ll ans = sub(r2, c2) - sub(r2, c1-1) - sub(r1-1, c2) + sub(r1-1, c1-1);
    ans = (ans + mod * 10) % mod;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>


int main(){
	//入力機構
	int A,B;
	std::cin>>A>>B;
	//解答
	//A,Bが共に奇数かどうか
	const bool ans=(A%2==1)&&(B%2==1);

	//結果出力
	std::cout<<(ans?"Yes":"No")<<std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/scc>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    atcoder::scc_graph graph(N);
    for(int i=0; i<M; i++)
    {
        int u, v;
        cin >> u >> v;
        graph.add_edge(u, v);
    }

    auto vec2 = graph.scc();
    cout << vec2.size() << '\n';
    for(auto vec : vec2)
    {
        cout << vec.size();
        for(auto n : vec) cout << ' ' << n;
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 40128
fn main() {
    let n = read::<u32>();
    let a = read::<u32>();
    yn(n % 500 <= a);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;

  ll result = 0;
  unordered_map<string, int> m;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;

    sort(s.begin(), s.end());
    result += m[s];
    m[s]++;
  }

  cout << result << endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> m;
    REP(i,n) {
        int x; cin >> x;
        m[x]++;
    }

    int ans = 0;
    for (auto p:m) {
        if(p.second % 2 == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int 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;
  }
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
#define MAX 100000
int main(void)
{
  int n;
  long long a[MAX], b[MAX];
  long long c=0;
  cin>>n;
  for(int i=0; i<n; i++)
    cin>>a[i]>>b[i];

  for(int i=n-1; i>=0; i--)
    {
      long long x=(a[i]+c)%b[i];
      if(x!=0)
	c+=b[i]-x;
    }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

int memo[31][100010];

signed main() {
	int N, C;
	cin >> N >> C;

	rep(i, N) {
		int s, t, c;
		cin >> s >> t >> c;
		c--;
		memo[c][s] += 1;
		memo[c][t + 1] += -1;
	}

	rep(c, 30) rep(i, 100005) memo[c][i + 1] += memo[c][i];

	int ret = 0;
	rep(i, 100005) {
		int tmp = 0;
		rep(c, 30) tmp += memo[c][i] > 0;
		ret = max(ret, tmp);
	}

	cout << ret << endl;
}


Measured memory_bytes: 23680
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;

int main() {
	char a, b, c, d;
	int res = 0;
	for(int i = 1; i <= 4; ++i) {
		cin >> a;
		if(a == '-') res --;
		else res++;
	}
	cout<<res;
	return 0;
} 

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    int w, a, b;
    cin >> w >> a >> b;

    int a_min = a, a_max = a + w;
    int b_min = b, b_max = b + w;

    if ((b_min >= a_min && b_min <= a_max) || (b_max >= a_min && b_max <= a_max))
        cout << 0 << '\n';
    else if (a_max < b_min)
        cout << b_min - a_max << '\n';
    else if (b_max < a_min)
        cout << a_min - b_max << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int a, b, q;
  cin >> a >> b >> q;
  vector<LL> s,t,x(q);
  s.push_back(-1123456789012ll);
  REP(i,a) {
    LL f;
    cin >> f;
    s.push_back(f);
  }
  s.push_back(1123456789012ll);
  t.push_back(-1123456789012ll);
  REP(i,b) {
    LL f;
    cin >> f;
    t.push_back(f);
  }
  t.push_back(1123456789012ll);
  for(auto &y: x) cin >> y;
  vector<LL> sc(s.size(),1123456789012ll), tc(t.size(),1123456789012ll);
  FOR(i,1,a+1) {
    auto ite = upper_bound(t.begin(), t.end(), s[i]);
    sc[i] = abs(*ite - s[i]);
    --ite;
    sc[i] = min(sc[i], abs(*ite - s[i]));
  }
  FOR(i,1,b+1) {
    auto ite = upper_bound(s.begin(), s.end(), t[i]);
    tc[i] = abs(*ite - t[i]);
    --ite;
    tc[i] = min(tc[i], abs(*ite - t[i]));
  }
  for(auto y: x) {
    LL answer = 1123456789012ll;
    auto ite = upper_bound(s.begin(), s.end(), y);
    answer = min(answer, *ite - y + sc[ite - s.begin()]);
    --ite;
    answer = min(answer, y - *ite + sc[ite - s.begin()]);
    ite = upper_bound(t.begin(), t.end(), y);
    answer = min(answer, *ite - y + tc[ite - t.begin()]);
    --ite;
    answer = min(answer, y - *ite + tc[ite - t.begin()]);
    cout << answer << endl;
  }
  return 0;
}


Measured memory_bytes: 5364
#include <bits/stdc++.h>  // ver2.2.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0 * 10 ^ 18 (MAXの1/3くらい)
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

bool sq(int n){
  int a = sqrt(n);
  if(a*a==n) return true;
  else return false;
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,qw,er,sum=0;
  cin >> n;
  
  if(n==2){
    cin >> qw >> er;
    if(qw>er) swap(qw,er);
    cout << er-qw << endl << er << ' ' << qw << endl;
    return 0;
  }
  
  
  Vi plus(0),minus(0);
  
  rep(i,0,n){
    cin >> qw;
    sum += abs(qw);
    if(qw>=0) plus.pb(qw);
    else minus.pb(qw);
  }
  
  int maxx;
  sort(ALL(plus));
  sortr(ALL(minus));
  
  if(plus.size()==0){
    maxx = sum + minus[0] + minus[0];
    cout << maxx << endl;
    cout << minus[0] << ' ' << minus[1]<<endl;
    plus.pb(minus[0]-minus[1]);
    minus.erase(minus.begin());
    minus.erase(minus.begin());
  }
  else if(minus.size()==0){
    maxx = sum - plus[0] - plus[0];
    cout << maxx << endl;
    cout << plus[0] <<' '<<plus[1]<<endl;
    minus.pb(plus[0]-plus[1]);
    plus.erase(plus.begin());
    plus.erase(plus.begin());
  }
  else cout << sum << endl;
  
  //Vout(plus);
  //Vout(minus);
  
  qw = plus.size(),er = minus.size();
  
  rep(i,1,qw){
    cout << minus[0]<<' '<<plus[i]<<endl;
    minus[0] -= plus[i];
  }
  rep(i,0,er){
    cout << plus[0]<<' '<<minus[i]<<endl;
    plus[0] -= minus[i];
  }
  
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  int cntb = 0,cntw = 0;
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 0){
      if(S.at(i) == '1') cntb++;
    }
    if(i % 2 == 1){
      if(S.at(i) == '0') cntb++;
    }
  }
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 0){
      if(S.at(i) == '0') cntw++;
    }
    if(i % 2 == 1){
      if(S.at(i) == '1') cntw++;
    }
  }
  cout << min(cntb, cntw) << endl;
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <map>
using namespace std;

const int mod = 1000000007;

bool isvaild(string s){
    if(s.size()<3) return true;
    if(s.size()==3) return s!="AGC"&&s!="ACG"&&s!="GAC";
    if(s.substr(1,3)=="AGC"||s.substr(1,3)=="ACG"||s.substr(1,3)=="GAC") return false;
    if(s[0]=='A'&&(s[1]=='G'||s[2]=='G')&&s[3]=='C') return false;
    return true;
}

int main(){
    int N;
    cin>>N;
    map<string,int> M[101];
    M[0][""]=1;
    string ATCG="ATCG";
    for(int n=1;n<=N;n++){
        for(auto p:M[n-1]){
            string s; int cnt;
            tie(s,cnt)=p;
            for(auto c:ATCG){
                string ss=s+c;
                if(ss.size()==5) ss=ss.substr(1,4);
                M[n][ss]=(M[n][ss]+M[n-1][s])%mod;
                if(!isvaild(ss)) M[n][ss]=0;
            }
        }
    }
    int ans=0;
    for(auto p:M[N]){
        // cout<<p.first<<' '<<p.second<<endl;
        ans=(ans+p.second)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

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

		@SuppressWarnings("unused")
		FastReader sc = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int arr[] = new int[n];
		Map<Integer, Integer> mp = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int x = sc.nextInt();
			if (mp.containsKey(x)) {
				mp.put(x, mp.get(x) + 1);
			} else {
				mp.put(x, 1);
			}
		}
		Map<Integer,Integer> mp2 =
			    mp.entrySet().stream()
			       .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
			       .limit(n)
			       .collect(Collectors.toMap(
			          Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));

		int ans=0;
		int i=0;
		for(Integer c:mp2.values())
		{
			if(i++>=k)
			{
				ans+=c;
			}
		}
		System.out.println(ans);
		out.close();

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 62132
#include<bits/stdc++.h>
using namespace std;
#define yeah ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define ll long long
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0;i<n;++i)
#define pii pair<int,int>
#define mp make_pair
int main()
{int t;
 cin>>t;
 string s;
 cin>>s;
 if(int(s.length())<t)
 {cout<<s<<endl;
 return 0;
 }
 for(int i=0;i<t;++i)
 cout<<s[i];
 if(int(s.length())>t)
 cout<<"..."<<endl;
 return 0;	
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
using namespace std;

double minmin(int x , double y) {
	double a = y - x;
	if (a < 0) return -a;
	else return a;
}

int main() {
	vector<int> v;
	int n, m, tmp = 0;
	double sum = 0.0, min;
	cin >> n;
	for (int i = 0; i<n; i++) {
		cin >> m;
		v.push_back(m);
		sum += m;
	}
	sum /= n;
	for (int i = 0; i<v.size(); i++) {
		if (minmin(v[tmp], sum) > minmin(v[i], sum)) tmp = i;
	}
	cout << tmp << endl;

	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
time = 0
abs = []
result = "Yes"

N.times{
    abs.push(gets.chomp.split(" ").map(&:to_i))
}

abs_sort = abs.sort{ |a, b| a[1] <=> b[1] }

abs_sort.each{|ab|
    time = time + ab[0]
    if time <= ab[1]
        next
    else
        result = "No"
        break
    end
}

print result

Measured memory_bytes: 19320
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int n, d;

	cin >> n;
	cin >> d;
	
	vector< vector<int> > pos;
	for (size_t i = 0; i < n; ++i) {
		vector<int> tmp_vec;
		for (size_t j = 0; j < d; ++j) {
			int tmp;
			cin >> tmp;
			tmp_vec.push_back(tmp);
		}
		pos.push_back(tmp_vec);
	}

	int ret = 0;

	for (size_t i = 0; i < n - 1; ++i) {
		for (size_t j = i + 1; j < n; ++j) {
			int sum = 0;
			for (size_t k = 0; k < d; ++k) {
				sum += pow(pos.at(i).at(k) - pos.at(j).at(k), 2);
			}
			double sqrt_sum = sqrt(static_cast<double>(sum));
			if (ceil(sqrt_sum) == floor(sqrt_sum)) {
				ret += 1;
			}
		}
	}

	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int n, d, x;
  int a;
  int sum=0;
  cin >> n >> d >> x;
  d--;
  r(i,n){
    cin >> a;
    sum++;
    sum+=d/a;
  }
  cout << sum+x << endl;
}


Measured memory_bytes: 256
use proconio::*;

fn mod_pow(x: usize, n: usize, p: usize) -> usize {
    let mut ret = 1;
    let mut n = n;
    let mut x = x;
    while n > 0 {
        if n & 1 > 0 {
            ret *= x;
            ret %= p;
        }
        x *= x;
        x %= p;

        n >>= 1;
    }

    ret
}

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }

    let mo = 1_000_000_007usize;
    let mut sum = 0;
    for &aa in a.iter() {
        sum += aa;
        sum %= mo;
    }

    let mut ans = sum * sum % mo;
    for i in 0..n {
        ans += mo - a[i] * a[i] % mo;
        ans %= mo;
    }

    ans = ans * mod_pow(2, mo - 2, mo) % mo;

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


Measured memory_bytes: 5588
#include <stdio.h>
int main () {
  int flag = 1, n, a[100], num = 0, i, j, tmp, min = 0;

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

  while(flag) {
    flag = 0;
    for(j = n-1 ; j > min ; j--) {
      if(a[j] < a[j-1]) {
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	num++;
	flag = 1;
      }
    }
    min++;
  }
  for(i = 0 ; i < n ; i++) {
    printf("%d", a[i]);
    if(i != n - 1) printf(" ");
  }
  printf("\n");
  printf("%d\n", num);

  return 0;
}

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

int n;

void dfs(string s, char c) {
	if (s.size() == n) {
		cout << s << '\n';
	} else {
		for (char i = 'a'; i <= c; i++)
			dfs(s + i, (i == c) ? c + 1 : c);
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	dfs("", 'a');
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,m,a[35][35],b[35][35],c[35],ans,num; 
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=c[i];j++)
		    cin>>a[i][j],b[i][a[i][j]]=1;
	}
	for(int i=1;i<=30;i++)
	{
		num=0;
		for(int j=1;j<=n;j++)
		    if(b[j][i]==1) num++;
		if(num==n) ans++;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N,M; cin>>N>>M;
    vector<int> lan[100010];
    int k,l;
    for (int i = 0; i < N; ++i) {
        cin>>k;
        for (int j = 0; j < k; ++j) {
            cin>>l; --l;
            lan[i].push_back(l);
        }
    }

    vector<int> tonari[100010];
    vector<int> root(M,-1);

    for (int i = 0; i < N; ++i) {
        for (auto la:lan[i]) {
            if(root[la]==-1){
                root[la]=i;
            }else{
                tonari[i].push_back(root[la]);
                tonari[root[la]].push_back(i);
            }
        }
    }

    vector<bool> visit(N,false);

    queue<int> q;
    visit[0]=true;
    q.push(0);
    while(!q.empty()){
        int tmp=q.front();
        q.pop();
        for(auto tsugi:tonari[tmp]){
            if(visit[tsugi]) continue;
            visit[tsugi]=true;
            q.push(tsugi);
        }
    }

    for(auto node:visit){
        if(!node){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 12408
n = int(input())
s = list(map(int, input().split()))
count = 0

def main():
    mergeSort(s, 0, n)
    print(' '.join(map(str, s)))
    print(count)

def mergeSort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)

def merge(a, left, mid, right):
    global count
    l = a[left:mid]
    r = a[mid:right]
    i = 0
    j = 0
    l.append(float('inf'))
    r.append(float('inf'))
    for k in range(left, right, 1):
        if l[i] < r[j]:
            a[k] = l[i]
            i += 1
        else :
            a[k] = r[j]
            j += 1
        count += 1


if __name__ == '__main__':
    main()



Measured memory_bytes: 66780
#include<iostream>
#include<map>
#include<algorithm>
#define f first
#define s second
#define MAX_T 100005
using namespace std;

typedef pair<int, int> P;
P teamp[MAX_T * 4 - 1];
P teamt[MAX_T * 4 - 1];
void init(int n);
void updateP(int k, int a, int n);
void updateT(int k, int a, int n);

int main(){
  int N, R, L;
  int d, t, x;
  int befd = 0, beft = 0, nt, n = 1;
  cin >> N >> R >> L;
  while(n < N) n *= 2;
  init(n);
  for(int i = 0; i < R; i++){
    cin >> d >> t >> x;
    updateP(d - 1, x, n);
    nt = t - beft;
    beft = t;
    updateT(befd, nt, n);
    befd = teamp[0].s;
  }
  nt = L - beft;
  updateT(befd, nt, n);
  cout << teamt[0].s + 1 << endl;
}

void init(int n){
  for(int i = 0; i < n * 2 - 1; i++){
    teamp[i].f = 0;
    teamt[i].f = 0;
  }
  for(int i = n - 1; i < n * 2 - 1; i++){
    teamp[i].s = i - (n - 1);
    teamt[i].s = i - (n - 1);
  }
  return;
}

void updateP(int k, int a, int n){
  k += n - 1;
  teamp[k].f += a;
  while(k > 0){
    k = (k - 1) / 2;
    if(teamp[k * 2 + 1].f >= teamp[k * 2 + 2].f){
      teamp[k].f = teamp[k * 2 + 1].f;
      teamp[k].s = teamp[k * 2 + 1].s;
    }
    else{
      teamp[k].f = teamp[k * 2 + 2].f;
      teamp[k].s = teamp[k * 2 + 2].s;
    }
  }
  return;
}

void updateT(int k, int a, int n){
  k += n - 1;
  teamt[k].f += a;
  while(k > 0){
    k = (k - 1) / 2;
    if(teamt[k * 2 + 1].f >= teamt[k * 2 + 2].f){
      teamt[k].f = teamt[k * 2 + 1].f;
      teamt[k].s = teamt[k * 2 + 1].s;
    }
    else{
      teamt[k].f = teamt[k * 2 + 2].f;
      teamt[k].s = teamt[k * 2 + 2].s;
    }
  }
  return;
}

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for(int i=max(A,B);i>0;i--){
    if(A%i==0&&B%i==0){
      K--;
      if(K==0){
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
import math
from itertools import permutations
 
N = int(input())
xy = [[int(i) for i in input().split()] for j in range(N)]
 
dist = [[0]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        dist[i][j] = math.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)
 
answer = 0.0
 
for i in permutations(range(N)):
    for j in range(1,N):
        answer += dist[i[j-1]][i[j]]
answer /= math.factorial(N)
 
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v(4);
    for(int i = 0; i < 3; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        v[a]++;
        v[b]++;
    }
    sort(v.begin(), v.end());
    if(v[0] == 1 && v[1] == 1 && v[2] == 2 && v[3] == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
struct S{
  double t;
  int v;
  int p;
  int from;
  S(){}
  S(double t, int v, int p,int from) :
    t(t), v(v), p(p),from(from) {}
};
struct edge{
  int to, dist, lim;
  edge(int to, int dist, int lim) :
    to(to), dist(dist), lim(lim) {}
};
typedef vector<edge> edges;
bool operator < (const S& s, const S& t){
  return s.t > t.t;
}
int main(){
  int n,m,s,g;
  while(cin>>n>>m>>s>>g, n){
    s--; g--;
    vector<edges> graph(n);
    REP(i,m){
      int x,y,d,c;
      cin>>x>>y>>d>>c; x--; y--;
      graph[x].push_back(edge(y, d, c));
      graph[y].push_back(edge(x, d, c));
    }
    priority_queue<S> que;
    FORIT(it, graph[s]){
      que.push(S(it->dist, 1, it->to, s));
    }
    bool used[40][40][40] = {};
    double ans = -1;
    while(!que.empty()){
      S s = que.top(); que.pop();
      //printf("quesize:%d time:%lf speed:%d point:%d\n",que.size(), s.t,s.v,s.p);
      if(s.p == g && s.v == 1){
        ans = s.t;
        break;
      }
      for(int nv = s.v - 1; nv <= s.v + 1; nv++)if(nv > 0){
        FORIT(it, graph[s.p])if(it->lim >= nv && it->to != s.from){
          if(used[nv][it->to][s.p]) continue;
          used[nv][it->to][s.p] = true;
          que.push(S(s.t + (double)it->dist/nv, nv, it->to, s.p));
        }
      }
    }
    if(ans != -1) printf("%.4lf\n",ans);
    else cout<<"unreachable"<<endl;
  }
    
  return 0;
}

Measured memory_bytes: 1536
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

a = 0
b = 0
c = 0
d = [0 for j in range(n)]

for i in range(n):
 a += abs(x[i]-y[i])
 b += (x[i]-y[i])**2
 c += abs(x[i]-y[i])**3
 d[i] = abs(x[i]-y[i])

b = b**(1/2)
c = c**(1/3)

print(a)
print(b)
print(c)
print(max(d))


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

int main() {
	vector<int> graph[100005];
	int H[100005];
	int N, M;
	cin >> N >> M;
	for(int i=0;i<N;i++) {
		cin >> H[i];
	}
	int u,v;
	for(int i=0;i<M;i++) {
		cin >> u >> v;
		u = u-1;
		v = v-1;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	int cnt = 0;
	for(int i=0;i<N;i++) {
		bool flag = true;
		for(int j=0;j<graph[i].size();j++) {
			int v = graph[i][j];
			if(H[v] >= H[i]) {
				flag = false;
				break;
			}
		}
		if(flag == true)
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 9152
n = int(input())
sp = []
for i in range(n):
    city, point = input().split()
    sp.append([city, int(point), int(i+1)])

sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key=lambda x: x[0])
for i in sp:
    print(i[2])


Measured memory_bytes: 9156
#include <cstdio>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstdlib>

int count[13];

int main()
{
  int n;
  scanf("%d", &n);
  count[0] = 2;
  count[12] = 1;
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    count[a]++;
  }
  std::vector<int> time;
  std::vector<int> amb;
  for (int i = 0; i <= 12; ++i)
  {
    if (count[i] >= 3)
    {
      puts("0");
      return 0;
    }
    else if (count[i] == 2)
    {
      count[i] = 0;
      if (i == 0 || i == 12) time.emplace_back(i);
      else
      {
        time.emplace_back(i);
        time.emplace_back(24 - i);
      }
    }
    else if (count[i] == 1)
    {
      if (i == 12) continue;
      amb.emplace_back(i);
    }
  }
  
  int ans = 0;
  int sz = time.size();
  int lim = 1 << amb.size();
  for (int i = 0; i < lim; ++i)
  {
    for (int j = 0; j < amb.size(); ++j)
    {
      time.emplace_back(i & (1 << j) ? 24 - amb[j] : amb[j]);
    }
    int min = 24;
    for (int a = 0; a < time.size() - 1; ++a)
    {
      for (int b = a + 1; b < time.size(); ++b)
      {
        int dif = std::abs(time[b] - time[a]);
        min = std::min(min, std::min(dif, 24 - dif));
      }
    }
    if (min > ans) ans = min;
    time.erase(std::next(time.begin(), sz), time.end());
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
answer = 0
for i in range(N):
    sum=0
    for j in range(M):
        sum = sum + A[i][j]*B[j]
    if sum + C > 0:
        answer = answer +1

print(answer)


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

using namespace std;

int main()
{
    int n, l, ans = 0;
    cin >> n >> l;
    vector<int> s(n+1, l-1);

    for (int i = 1; i <= n; ++i) {
        s[i] += i;
        ans += s[i];
    }
    if (s[1] * s[n] <= 0) {
        cout << ans << endl;
    } else if (s[1] < 0) {
        ans -= s[n];
        cout << ans << endl;
    } else if (s[n] > 0) {
        ans -= s[1];
        cout << ans << endl;
    } else {
        cout << "unknown" << endl;
    }
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3,unroll-loops")
//#pragma loop_opt(on)
#include <bits/stdc++.h>
//#include <bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    array<array<int,3>,3> ary;
    Fr(i, 0, 3) Fr(j, 0, 3) cin >> ary[i][j];
    int n; cin >> n;
    unordered_set<int> st{};
    Fr(i, 0, n) {
        int bi;
        cin >> bi;
        st.insert(bi);
    }
    array<array<bool,3>,3> bk;
    Fr(i, 0, 3) Fr(j, 0, 3) bk[i][j] = st.find(ary[i][j]) != st.end();
    bool can = false;
    Fr(i, 0, 3) can |= bk[i][0] && bk[i][1] && bk[i][2];
    Fr(j, 0, 3) can |= bk[0][j] && bk[1][j] && bk[2][j];
    can |= bk[0][0] && bk[1][1] && bk[2][2];
    can |= bk[0][2] && bk[1][1] && bk[2][0];
    cout << (can ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		long[,] LR = new long[N,2];
		long[] L = new long[N];
		long[] R = new long[N];
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			LR[i,0] = long.Parse(str2[0]);
			LR[i,1] = long.Parse(str2[1]);
			L[i] = LR[i,0];
			R[i] = LR[i,1];
		}
		Array.Sort(L);
		Array.Sort(R);
		long count = 0;
		long count2 = 0;
		long n1 = 0;
		long n2 = N-1;
		long nn = 0;
		while(true){
			if(L[n2] <= nn){
				count += Math.Abs(nn);
				break;
			}
			count += Math.Abs(L[n2]-nn);
			nn = L[n2];
			//if(n1 == n2){
			//	count += Math.Abs(nn);
			//	break;
			//}
			n2 -= 1;
			if(nn <= R[n1]){
				count += Math.Abs(nn);
				break;
			}
			count += Math.Abs(R[n1]-nn);
			nn = R[n1];
			//if(n1 == n2){
			//	count += Math.Abs(nn);
			//	break;
			//}
			n1 += 1;
		}
		n1 = 0;
		n2 = N-1;
		nn = 0;
		while(true){
			if(nn <= R[n1]){
				count2 += Math.Abs(nn);
				break;
			}
			count2 += Math.Abs(R[n1]-nn);
			nn = R[n1];
			//if(n1 == n2){
			//	count2 += Math.Abs(nn);
			//	break;
			//}
			n1 += 1;
			if(L[n2] <= nn){
				count2 += Math.Abs(nn);
				break;
			}
			count2 += Math.Abs(L[n2]-nn);
			nn = L[n2];
			//if(n1 == n2){
			//	count2 += Math.Abs(nn);
			//	break;
			//}
			n2 -= 1;
		}
		//Console.WriteLine(count +" "+count2);
		count = Math.Max(count,count2);
		Console.WriteLine(count);
	}
}

Measured memory_bytes: 20424
#include <stdio.h>
int main(){
	int n ,h ,m ,s  ;
	
	scanf("%d", &n);
	
	h=n/3600;
	
	m=n%3600/60;
	
	s=n%60;
	
	printf("%d:%d:%d\n",h ,m ,s);
	

}



Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N;
  for(int i=1;i<=N;i*=2){
A=i;     	
}
 
  cout << A;
}

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

int	dp[3][100005];
int main(){
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	for(int i=1;i<n;i++){
		dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]);
		dp[1][i] = b[i] + max(dp[2][i-1],dp[0][i-1]);
		dp[2][i] = c[i] + max(dp[1][i-1],dp[0][i-1]);
	}
	cout << max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]) << endl; 
}		

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

int main() {
  int a,b;
  cin >> a >> b;
  if((a+b) % 2 == 0)
    cout << (a + b) / 2 << endl;
  else 
    cout << ((a + b) / 2) + 1 << endl;
}

Measured memory_bytes: 256
n = int(input()) 

import math
def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1
        is_prime(n)
    print(n)
        
    

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

int main() {
	int s, ans=1;
	cin >> s;

	set<int> already;

	while (1) {
		if (already.count(s)) {
			cout << ans << endl;
			return 0;
		}

		already.insert(s);
		if (s % 2 == 0) {
			s = s / 2;
		}
		else {
			s = 3 * s + 1;
		}
		ans++;
	}

	

	return 0;
}

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

int main(void){
    int A, B;
    cin >> A >> B;
    
    if(A >= 13){
        cout << B <<endl;
    } else if(A < 13 && A >= 6){
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;

}

Measured memory_bytes: 256