akhauriyash/Code-Regression huggingface dataset:
def dfs(f):
    if vis[f] == 1:
        return
    vis[f] = 1 #fを訪問済にする
    for t in v[f]: #fとつながっている頂点を読み込む
        if f != a or t != b: #(a,b)の組み合わせでなければ繰り返す
            dfs(t)

n, m = map(int, input().split())
v = [[] for i in range(n)]
e = []

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
    e.append([a, b])

ans = 0

for a, b in e:
    vis = [0]*n
    dfs(a)
    if vis[b] == 0: #aからa-bの辺以外を辿ってbに行けるなら1になる
        ans += 1

print(ans)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

  int N;
  cin >> N;
  vi a(N);
  rep(i, N) cin >> a[i];

  int ans = inf;
  rep2(t, -100, 100 + 1) {
    int sm = 0;
    rep(i, N) {
      sm += (a[i] - t) * (a[i] - t);
    }
    ans = min(ans, sm);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

string divide[4] = { "dream", "dreamer", "erase", "eraser" };

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

	string s;
	cin >> s;

	reverse(allof(s));
	rep(i, 4) reverse(allof(divide[i]));

	bool can = true;

	rep(i, (int)s.size()) {
		bool can2 = false;
		rep(j, 4) {
			string tmp = s.substr(i, (int)divide[j].size());
			if (tmp == divide[j]) {
				i += (int)divide[j].size() - 1;
				can2 = true;
				break;
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}

	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 512
firstLine = input()
numOfPoints, limitDisatnce = list(map(int,firstLine.split(' ')))[0], list(map(int,firstLine.split(' ')))[1]
points = []
for i in range(0, numOfPoints):
  cordinate = list(map(int,input().split(' ')))
  points.append(cordinate)

count = 0
for i in range(0, len(points)):
  distance = (points[i][0] ** 2) + (points[i][1] ** 2)
  if (limitDisatnce ** 2) >= distance:
    count = count + 1

print(count)

Measured memory_bytes: 45320
using System;

namespace Acs
{
    class Program
    {
        static void Main(string[] args)
        {
            //int a, b;
            var ss = Console.ReadLine().Split(' ');
            var a = int.Parse(ss[0]);
            var b = int.Parse(ss[1]);

            Console.WriteLine(a<=b ?a:a-1);
        }
    }
}


Measured memory_bytes: 13140
class Card
  attr_reader :suit, :number

  def initialize(val)
    @suit = val[0]
    @number = val[1].to_i
  end

  def to_s
    "#{suit} #{number}"
  end

  def <=(card)
    number <= card.number
  end

  def ==(card)
    suit == card.suit && number == card.number
  end
end

def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = [] * n1
  r = [] * n2
  n1.times do |i|
    l << a[left + i]
  end
  n2.times do |i|
    r << a[mid + i]
  end
  li = 0
  ri = 0
  l << Card.new(["?", 0xffffffff.to_s])
  r << Card.new(["?", 0xffffffff.to_s])
  left.upto(right - 1) do |i|
    if l[li] <= r[ri]
      a[i] = l[li]
      li += 1
    else
      a[i] = r[ri]
      ri += 1
    end
  end
end

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

def merge_sort(a)
  _merge_sort(a, 0, a.size)
end

def swap(a, i, j)
  tmp = a[i]
  a[i] = a[j]
  a[j] = tmp
end

def partition(a, p, r)
  ans = p
  p.upto(r - 1) do |i|
    if a[i] <= a[r]
      swap(a, ans, i)
      ans += 1
    end
  end
  swap(a, ans, r)
  ans
end

def _quicksort(a, p, r)
  if p < r
    q = partition(a, p, r)
    _quicksort(a, p, q - 1)
    _quicksort(a, q + 1, r)
  end
  a
end

def quicksort(a)
  _quicksort(a, 0, a.size - 1)
end

def stable?(bef, aft)
  merge_sort(bef) == aft
end

n = gets.chomp.to_i
a = []

n.times do
  a << Card.new(gets.chomp.split)
end

sorted = quicksort(a.dup)

puts stable?(a, sorted) ? 'Stable' : 'Not stable'
puts sorted.map(&:to_s).join("\n")


Measured memory_bytes: 23668
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int x, y; cin >> x >> y;
	int Min = INT_MAX;
	rep(i, 2) {
		rep(j, 2) {
			int a = x, b = y;
			if (i)a = -a;
			if (j)b = -b;
			if (a <= b)Min = min(Min, b - a + i + j);
		}
	}
	cout << Min << endl;
}

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

using namespace std;
const int N = 10e5 + 3;
char b[N], a[N];
int result[N];

int find_idx(int idx, int l){
  char pivot = a[idx];
  while(a[idx] == pivot){
    if (idx < l){
      idx++;
    }
    else{
      return idx;
    }
  }
  return idx - 1;
}

int main(){
  cin >> b;

  int l = strlen(b);

  for(int i = 0; i < l; ++i){
      a[i+1] = b[i];
  }

  int f = 1;
  while(true){
    int first = find_idx(f, l);
    int second = find_idx(first + 1, l);

    int numf = first - f + 1;
    int nums = second - first;
    result[first] = (numf + 1) / 2 + nums / 2;
    result[first + 1] = (nums + 1) / 2 + numf / 2;
    f = second + 1;
    if (f > l){
      break;
    }
  }

  for (int i = 1; i <= l; ++ i){
    cout << result[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2944
import sys
input = sys.stdin.readline
S = set()
s = list(input().rstrip())
K = int(input())
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        if "".join(s[i:j]) not in S:
            S.add("".join(s[i:j]))
S = list(S)
S.sort()
print("".join(S[K-1]))


Measured memory_bytes: 40432
def solve(x):
    for i in range(1001):
        for j in range(-1001,1001):
            if i**5-j**5==x:
                return (i,j)
            
def main():
    x=int(input())
    Ans=solve(x)
    print(*Ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 63552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

vector<ll> ret;
void make_prime(vector<ll>& ret, ll n) {
    ll x = n;
    for (ll i = 2; i * i <= x; i++) {
        while (n % i == 0) {
            n /= i;
            ret.push_back(i);
        }
    }
    if (n != 1) {
        ret.push_back(n);
    }

    return;
}

int main() {
    ll n;
    cin >> n;
    ll p;
    cin >> p;
    make_prime(ret, p);

    sort(ret.begin(), ret.end());
    ret.push_back(-1ll);  // sentinel
    vector<P> pairs;

    ll cnt = 1;
    rep(i, ret.size() - 1) {
        if (ret[i] == ret[i + 1]) {
            cnt++;
        } else {
            pairs.push_back({ret[i], cnt});
            cnt = 1;
        }
    }

    /*rep(i,ret.size()){
        cout<<ret[i]<<endl;
    }*/

    ll ans = 1;
    rep(i, pairs.size()) {
        rep(j, pairs[i].se / n) { ans *= pairs[i].fi; }
    }

    /*rep(i,pairs.size()){
        cout<<pairs[i].fi<<" "<<pairs[i].se<<endl;
    }*/

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<vector>
using namespace std;
bool cmp(string l,string r);
int main(){
    int n;
    scanf("%d",&n);
    map<string,int> Data;
    for(int i = 0; i < n; i++){
        string str;
        int x;
        cin >> str >> x;
        Data[str] += x;
    }
    map<string,int> :: iterator it = Data.begin();
	vector<string> str_ans;
   	for(it =Data.begin();it != Data.end(); it++){
        str_ans.push_back((*it).first);
    }
	
    sort(str_ans.begin(),str_ans.end(),cmp);
    for(int i = 0; i < str_ans.size(); i++){
        cout << str_ans[i] << " " << Data[str_ans[i]] << endl;
    }
    return 0;
}
bool cmp(string l,string r){
    if(l.size() < r.size())return 1;
    if(l.size() > r.size())return 0;
    else {
        if(l < r)return 1;
        else return 0;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


int dp[3005][3005];

int main()
{
    int n,t;
    cin >> n >> t;
    vector<P> p(n);
    rep(i,n)
    {
        cin >> p[i].first >> p[i].second;
    }
    int ans = 0;
    sort(p.begin(),p.end());
    rep(i,n)
    {
        rep(j,t)
        {
            chmax(dp[i+1][j], dp[i][j]);
            int nj = j+p[i].first;
            if (nj < t)
            {
                chmax(dp[i+1][nj], dp[i][j]+p[i].second);
            }
        }
        ans = max(ans, dp[i][t-1]+p[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 35456
n,m,k = map(int, input().split())
t = [0 for i in range(n*m+1)]
for i in range(n+1):
    a = i * m
    b = n - i - i
    for j in range(m):
        t[a] = 1
        a += b
if t[k] == 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 10904
#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::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

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

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::unordered_set<i64> even_numbered;
  {
    std::vector<i64> sorted_A = A;
    std::sort(sorted_A.begin(), sorted_A.end());
    for (i64 i = 0; i < N; i += 2) {
      even_numbered.insert(sorted_A[i]);
    }
  }

  i64 answer = 0;
  for (i64 i = 0; i < N; i += 2) {
    if (even_numbered.find(A[i]) == even_numbered.end()) {
      ++answer;
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 3852
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    int q;cin>>q;
    rep(i,0,q){
        int x;cin>>x;
        cout<<binary_search(all(v),x)<<endl;
    }
    
}



/*

*/



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
int main () {
    string s;
    cin>>s;
    int cur = 0;
    FOR(i, 0, size(s)) {
        cur += s[i] - '0';
    }
    if ( cur%9==0 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3736
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) <<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

vii a(100001, vi());
vll dp(100001, vl(2));

void dfs(int from, int par=-1){
    vi children = a[from];
    dp[from][0] = 1;
    dp[from][1] = 1;
    for(int i=0; i<children.size(); i++){
        int ch = children[i];
        if(ch==par) continue;
        dfs(ch, from);
        dp[from][0] = dp[from][0] * ((dp[ch][0] + dp[ch][1]) % MOD) % MOD;
        dp[from][1] = dp[from][1] * dp[ch][0] % MOD;
    }
}

int main(){
    int N; cin >> N;
    rep(i, 0, N-1){
       int x,y; cin >> x >> y;
       x--; y--;
       a[x].push_back(y);
       a[y].push_back(x);
    }
    dfs(0);
    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    int n, k;
    //int cost=0;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int dp[n]; //, mn[n];
    s(dp, 0);
    //s(mn, 0);
    for (int j = 0; j < k; j++)
    {
        dp[0] = 0;
        dp[1] = abs(a[1] - a[0]);
    }
    //smn[1] = dp[1];
    for (int i = 2; i < n; i++)
    {
        int ans = INT_MAX;
        for (int j = 0; j < k; j++)
        {
            if (i - (j + 1) >= 0)
            {
                ans = min(ans, dp[i - j - 1] + abs(a[i] - a[i - j - 1]));
            }
        }
        dp[i] = ans;
    }
    cout << dp[n - 1] << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4412
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n ;i++){
            a[i] = stdIn.nextInt();
        }

        int[] b = new int[n];
        
        for(int i = n-1; i >= n/2  ; i--) {
            b[i] = a[i];
        }

        for(int i = n/2 - 1; i >= 0; i--) {
            int countBall = 0;
            //int m = n / (i+1);
            for(int j = i; j < n;j += (i + 1)) {
                if((j+1) % (i+1) == 0 ){
                    if(b[j] == 1) {
                        countBall++;
                    }
                }
            }
            if(countBall % 2 == 0) {
                b[i] = a[i];
            }else if(a[i] == 0){
                b[i] = 1;
            }else {
                b[i] = 0;
            }
        }

        int count = 0;
        for(int i = 0;i < n ;i++) {
            if(b[i] == 1) {
                count++;
            }
        }
        System.out.println(count);
    
        for(int i = 0 ; i < n;i++) {
            if(b[i] == 1){
                System.out.println(i+1);
            }
        }

    }
}

Measured memory_bytes: 92688
from collections import defaultdict
N = int(input())
A = []
a_dict = defaultdict(int)
for _ in range(N):
    a = int(input())
    A.append(a)
    a_dict[a] += 1

max_a = max(A)
for i, a in enumerate(A):
    if a == max_a and a_dict[a] == 1:
        B = []
        for j, b in enumerate(A):
            if b != a:
                B.append(b)
        ans = max(B)
        print(ans)
    else:
        print(max_a)

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

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
INF = 10**6+1
MIN, MAX = INF, -INF
for i, a in enumerate(A, start=1):
    if a < MIN:
        MIN, MINi = a, i
    if MAX < a:
        MAX, MAXi = a, i
if MAX < 0 or (MAX + MIN < 0):
    print(2*N-1)
    for i in range(1, N+1):
        print(MINi, i)
    for i in range(2, N+1)[::-1]:
        print(i, i-1)
    quit()
flag = 0
if MIN < 0 and MAX + MIN >= 0:
    print(2*N-1)
    flag = 1
    for i in range(N):
        print(MAXi, i+1)
if not flag:
    print(N-1)
for i in range(1, N):
    print(i, i+1)


Measured memory_bytes: 38384
#include<stdio.h>
int main()
{
  int n, m;
  while(1)
  {
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0)
    {
    break;
    }
    if(n > m)
    {
        printf("%d %d\n", m, n);
    }
    
    else 
    {
        printf("%d %d\n", n, m);
    }
  }
  return 0;
}



Measured memory_bytes: 1972
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n,last_r=114514;
  cin>>n;

  vector <int> a(n),b;
  for(int i=0;i<n;i++) cin>>a[i];

  for(int i=0;i<=3;i++){
    b=a;
    int r=i;
    b[0]-=i;
    if(b[0]<0) b[0]=0;

    for(int j=0;j<n-1;j++){
      r+=b[j]*2;
      b[j+1]-=b[j];
      if(b[j+1]<0) b[j+1]=0;
    }

    last_r=min(last_r,r+b[n-1]);

  }

  cout<<last_r<<endl;

  return 0;

}



Measured memory_bytes: 3172
import sys

C_MAX = 1000 + 1

if __name__ == "__main__":
    N, T = map(int, input().split())

    input_list = []
    for n in range(N):
        c, t = map(int, input().split())
        input_list.append((c, t))

    min_cost = C_MAX 

    for c, t in input_list:
        if t <= T and c < min_cost:
            min_cost = c

    if min_cost == C_MAX:
        print("TLE")
    else:
        print(min_cost)
            


Measured memory_bytes: 3060
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        String[] A = new String[N];
        ArrayList<String> list = new ArrayList<String>();

        for(int i=0; i<N; i++){
            A[i] = sc.next();
            list.add(A[i]);
        }

        Collections.sort(list);

        for(int i=0 ; i<N-1; i++){
            if(list.get(i).equals(list.get(i+1))){
                System.out.println("NO");
                break;
            }
            if(i==N-2){
                System.out.println("YES");
            }
        }
    }
}


Measured memory_bytes: 71828
#include<cstdio>
#include<algorithm>
using namespace std;
int D[1 << 15][15], S[1 << 15];
int w[15][15], n, m, sum;
int main() {
	int i, a, b, c, j, k, l;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		a--, b--;
		w[a][b] = w[b][a] = c;
		sum += c;
		for (j = 0; j < (1 << n); j++) {
			if (((~j)&((1 << a) | (1 << b))) == 0)S[j] += c;
		}
	}
	for (i = 0; i < (1 << n); i++) {
		for (j = 0; j < n; j++)D[i][j] = -1e9;
		if (i & 1) D[i][0] = S[i];
	}
	for (i = 0; i < (1 << n); i++) {
		for (j = 0; j < n; j++) {
			if (D[i][j] < 0)continue;
			int b = (1 << n) - i - 1;
			for (k = b;k; k = (k - 1)&b) {
				for (l = 0; l < n; l++) {
					if (w[j][l] && ((k >> l) & 1) ){
						D[i | k][l] = max(D[i | k][l], D[i][j] + S[k] + w[j][l]);
					}
				}
			}
		}
	}
	printf("%d\n", sum - D[(1 << n) - 1][n - 1]);
}

Measured memory_bytes: 2176
s = list(input())
n = len(s)
ans = 0
for i in range(2**(n-1)):
  t = s[:]
  bag = []
  for j in range(n-1):
    if (i >> j) & 1:
      bag += [j]
  for idx in bag[::-1]:
    t.insert(idx+1, "+")
  ans += eval(''.join(t))

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a+b>=24) cout << (a+b)-24 << endl;
    else cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S) - 1

ans = 0
for i in range(2 ** N):
    equation = S[0]
    for j in range(N):
        if (i >> j) & 1:
            equation += "+" + S[j + 1]
        else:
            equation += S[j + 1]
    ans += sum(list(map(int, equation.split("+"))))

print(ans)

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

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

  long r = c - a - b;

  if (r < 0)
    cout << "No" << endl;
  else if (4 * a * b < r * r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(n):
  ans += B[A[i]-1]
  if i<n-1 and A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 9204
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
  
      int all = 0;
      for(int i=1; i<=N; i++){
		all += i;
}
    System.out.println(all);
    }
}

Measured memory_bytes: 35656
use proconio::fastout;
use proconio::input;
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        hs: [u32; n],
        ms: [(Usize1, Usize1); m],
    }
    let mut map: Vec<Vec<usize>> = vec![Vec::new(); n];
    for &(a, b) in &ms {
        map[a].push(b);
        map[b].push(a);
    }
    let mut ans = 0;
    for n in 0..n {
        if map[n].iter().all(|&x| hs[x] < hs[n]) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s.substr(i, 2) == "AC") {
            cout << "Yes\n"; return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = list(map(int, input().split('/')))
    if s[0] < 2019:
        print("Heisei")
    elif s[0] > 2019:
        print("TBD")
    else:
        if s[1] < 4:
            print("Heisei")
        elif s[1] > 4:
            print("TBD")
        else:
            if s[2] <= 30:
                print("Heisei")
            else:
                print("TBD")
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
#include <stdio.h>

void ch(int x, int y, int n[30]) {
	int temp = n[x-1];
	n[x-1] = n[y-1];
	n[y-1] = temp;
}

int main(void) {
	int w, n, i;
	int a[30][2];
	int num[30];
	
	scanf("%d %d", &w, &n);
	
	for(i=0; i<w; i++)
		num[i] = i+1;
	
	for(i=0; i<n; i++) 
		scanf("%d,%d", &a[i][0], &a[i][1]);
	
	
	for(i=0; i<n; i++) {
		ch(a[i][0], a[i][1], num);
	}
	
	for(i=0; i<w; i++){
		printf("%d\n", num[i]);
	}
	
	return 0;
}
		

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

char S[100];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S;

    n = strlen(S);

    for(int i=0;i<n-2;i++){

        cur = 100*(S[i]-'0')+10*(S[i+1]-'0')+(S[i+2]-'0');
        mn = min(mn,abs(cur-753));
    }

    cout<<mn<<"\n";

    return 0;
}


Measured memory_bytes: 256
main :: IO()
main = do
    str <- getLine
    putStrLn $ if getsolve (reverse str) then "YES" else "NO"

getsolve "" = True
getsolve ('m':'a':'e':'r':'d':ls) = getsolve ls
getsolve ('r':'e':'m':'a':'e':'r':'d':ls) = getsolve ls
getsolve ('e':'s':'a':'r':'e':ls) = getsolve ls
getsolve ('r':'e':'s':'a':'r':'e':ls) = getsolve ls
getsolve _ = False









Measured memory_bytes: 7548
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
 
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
 
typedef long long ll;
typedef pair<int, int> PII;
 
const double EPS = 1e-10;
 
typedef struct edge_def {
  int from;
  int to;
  int cost;
 
  edge_def(int _from, int _to, int _cost) {
    from = _from;
    to   = _to;
    cost = _cost;
  }
} edge;
 
const int INF = INT_MAX;
const int V = 10000;
int n, t;
vector<edge> es[V];
int d[V];
 
void dijkstra(int s) {
  int i;
  priority_queue<PII, vector<PII>, greater<PII > > q;
  for (i=0; i<n; i++) d[i] = INF;
  d[s] = 0;
  q.push(PII(0, s));
 
  while (q.size()) {
    PII p = q.top();
    q.pop();
    int v = p.second;
 
    if (d[v] < p.first) continue;
 
    for (i=0; i<(int)es[v].size(); i++) {
      edge e = es[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        q.push(PII(d[e.to], e.to));
      }
    }
  }
}
 
int main() {
  int i, j, k;
  int u, v, c;
  for (i=0; i<V; i++) es[i].clear();
 
  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    scanf("%d%d ", &u, &k);
    for (j=0; j<k; j++) {
      scanf("%d%d ", &v, &c);
      es[u].psb(edge(u, v, c));
    }
  }
 
  dijkstra(0);
 
  for (i=0; i<n; i++) {
    printf("%d %d\n", i, d[i]);
  }
 
    return 0;
}

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

using namespace std;

void maxHeapify(int *A, int H, int i)
{
    int l, r, largest;

    l = i * 2;
    r = i * 2 + 1;

    largest = i;

    if (l <= H &&  A[l] > A[i])
    {
        largest = l;
    }

   if (r <= H &&  A[r] > A[largest])
    {
        largest = r;
    }

    if (largest != i)
    {
        swap(A[i],A[largest]);
        maxHeapify(A,H,largest);
    }
}

int main()
{
    int H;

    cin >> H;

    int A[H + 1];

    for (int i = 1; i <= H; i++)
    {
        cin >> A[i];
    }

    for (int i = H / 2; i >= 1; i--)
    {
        maxHeapify(A,H,i);
    }

    for (int i = 1; i <= H; i++)
    {
        cout << " " << A[i];
    }

    cout << endl;

    return 0;
}



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

int main(){
	int profit = -1000000001;
	int n, num, min;
	int R[200000];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> R[i];
	min = R[0];
	for (int j = 1; j <= n-1; j++){
		profit = (R[j] - min) > profit ? (R[j] - min) : profit;
		min = min < R[j]? min: R[j];
	}
	if (profit < 0){
		for (int j = 1; j <= n-1; j++)
			profit = profit > (R[j] - R[j-1])? profit : (R[j] - R[j-1]);
	}
	
	cout << profit << endl;
	return 0;
}


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

int N,M,A,B;
bool ans[100000]={0};
vector<int> vec[100000];
int number=0;

void DFS(int n){
	if(!ans[n]){
		ans[n]=true;
		for(int i : vec[n]){
			DFS(i);
		}
	}
}
int main(){
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>A>>B;A--;B--;
		vec[A].push_back(B);
		vec[B].push_back(A);
	}
	for(int i=0;i<N;i++){
		if(!ans[i]){
			number++;
			DFS(i);
		}
	}
	cout<<number-1;
	return 0;
}

Measured memory_bytes: 9660
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int d, t, s; cin >> d >> t >> s;
    if(d <= t*s) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3648
#include <cstdio>
using namespace std;
long long n,a;
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		if((a%2==0)&&a%3&&a%5)
		{
			printf("DENIED");
			return 0;
		}
	}
	printf("APPROVED");
	return 0;
}

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

int main() {
  
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  if(a >= k){
    cout << k << endl;
  }
  
  else{
    
    if( b >= k - a){
      cout << a << endl;
    }
    
    else{
      cout << 2 * a + b - k << endl;
    }
    
  }
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
int j,i;
char haiku[19];
for(j=0;j<19;j++){
scanf("%c",&haiku[j]);
}
for(i=0;i<19;i++){
if(haiku[i]==','){
haiku[i]=' ';
}
}
printf("%s",haiku);
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int a[1000], b[1000], x, y, i, j, ans[1000];
	char op;

	i=0;

	while(1){
		scanf("%d %c %d", &a[i], &op, &b[i]);

		if(op=='?'){
			break;
		}else if(op=='?' && b[i]==0){
			break;
		}

		x = a[i];
		y = b[i];
	
		switch(op){
			case '+' : ans[i] = x + y;	break;
			case '-' : ans[i] = x - y;	break;
			case '*' : ans[i] = x * y;	break;
			case '/' : ans[i] = x / y;	break;
		}

		i++;
	}

	for(j=0;j<i;j++){
		printf("%d\n", ans[j]);
	}

	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int v_x, v_y, p;
    cin >> v_x >> v_y >> p;
    int x, y, c, xf = 0, xl = v_x, yf = 0, yl = v_y, ans;
 
    for(int i = 0; i < p; i++)
    {
        cin >> x >> y >> c;
 
        if(c == 1)
            xf = max(x, xf);
 
        else if(c == 2)
            xl = min(x, xl);
 
        else if(c == 3)
            yf = max(y, yf);
 
        else if(c == 4)
            yl = min(y, yl);
    }
    ans = (xl - xf) * (yl - yf);
    if(xf >= xl || yf >= yl)
        ans = 0;
    cout<<ans<<endl;
 
}

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


int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double result;
  double g;
  double f;
  double theta;
  g = (h*30 + m*0.5);
  f = m * 6 ;
  theta = (f-g)* M_PI /180;
  result = sqrt(a * a + b * b -2*a*b*cos(theta));

  cout << fixed;
  cout << setprecision(20) << result ;
}


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



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

Measured memory_bytes: 2560
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
	string s;
	int count = 0;
	cin >> s;

	const string val = "CODEFESTIVAL2016"; 
    for (int i = 0; i < val.length(); i++) {
		if (s[i] != val[i])
			count++;
	}
	cout << count;
	return 0;
}

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


string solve(int arr[], int n){

    int g = arr[0];
    int countEven = arr[0]%2 == 0;
    int MAX = 0;
    for(int i=1; i<n; i++){
        g = __gcd(g, arr[i]);
        if(arr[i]%2 == 0)
            countEven++;
        if(arr[i] > MAX)
            MAX = arr[i];
    }

    if(g > 1){
        return "not coprime";
    }
    if(countEven >= 2){
        return "setwise coprime";
    }

    // Build sieve
    // Now the array can be either pairwise or setwise
    // If any 2 of the array element has same prime factors
    // then not pairwise coprime

    unordered_map<int, int> m;
    for(int i=0; i<n; i++)
        m[arr[i]]++;

    vector<bool> sieve(MAX+1, true);

    for(int i=2; i<=MAX; i++){
        if(sieve[i]){
            int cnt = 0;
            for(int j=i; j<=MAX; j+=i){
                sieve[j] = false;
                if(m.find(j) != m.end())
                    cnt += m[j];
            }
            if(cnt > 1)
                return "setwise coprime";
        }
    }
    return "pairwise coprime";
}

int main()
{
 int n;
 cin>>n;
 int arr[n];
 for(int i=0; i<n; i++)
    cin>>arr[i];
 string ans = solve(arr, n);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 7400
use proconio::{fastout, input};

use num::integer::gcd;

#[fastout]
fn main() {
    input! {
        k: u64
    }
    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    println!("{}", ans);
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n,s; cin >> n >> s;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  auto f = [](int x,int y){
    return x + y;
  };
  SegmentTree<int> seg(a,0,f);
  int ans = n+1;
  for(int i = 0; i < n; i++){
    auto f = [&](int mid){
      return seg.getval(i,mid+1) >= s;
    };

    int left = -1,right = n;
    while(right - left > 1){
      int mid = (left + right) / 2;

      if(f(mid)) right = mid;
      else left = mid;
    }
    if(right == n) continue;
    ans = min(ans,right - i + 1);
    //cout << right << " " << right - i + 1 << endl;
  }
  if(ans == n+1) ans = 0; 
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef struct Cell {
    int key;
    struct Cell* prev;
    struct Cell* next;
} Cell;

Cell* newCell (int key) {
    Cell *cell = malloc(sizeof(Cell));
    cell->key = key;
    cell->prev = NULL;
    cell->next = NULL;
    return cell;
}

Cell* tail, *head, *deleted;

void init() {
    tail = head = deleted = NULL;
}

void insert(int x) {
    if (tail == NULL) {
      tail = head = newCell(x);
    } else {
      tail->prev = newCell(x);
      tail->prev->next = tail;
      tail = tail->prev;
    }
}

void deleteLast() {
   if (head == NULL) return;
   deleted = head;
   if (head->prev == NULL) {
       tail = head = NULL;
       free(deleted);
       return;
   }
   
   head = head->prev;
   head->next = NULL;
   free(deleted);
}

void deleteFirst() {
    if (tail == NULL) return;
    deleted = tail;
    
    if (tail->next == NULL) {
        tail = head = NULL;
        free(deleted);
        return;
    }
    
    tail->next->prev = NULL;
    tail = tail->next;
}


void dump() {
    Cell* tmp = tail;
    int n = 0;
    while (tmp != NULL) {
        if (n!=0) printf(" ");
        printf("%d", tmp->key);
        tmp = tmp->next;
        n++;
    }
    printf("\n");
}

void delete(int x) {
    Cell* tmp = tail;
  
    while (tmp != NULL) {
        if (tmp->key != x) {
            tmp = tmp->next;
            continue;
        }
        

        if (tmp == tail) {
            deleteFirst();
            break;
        } else if (tmp == head) {
            deleteLast();
            break;
        }
        
        deleted = tmp;
        Cell* prev = tmp->prev;
        Cell* next = tmp->next;
        prev->next = next;
        next->prev = prev;
        free(deleted);
        break;
    }
}


void test() {
    init();
    insert(5); // 5
    insert(2); // 2 5
    insert(3); // 3 2 5
    insert(1); // 1 3 2 5
    delete(3); // 1 2 5
    insert(6); // 6 1 2 5
    delete(5); // 1 2 5
    deleteFirst(); // 1 2 
    deleteLast(); // 1
    dump();
}

int main(void){
    // test();return 0;
    int n, x;
    char op[15];
    
    init();
    
    scanf("%d", &n);
    while (n--) {
      scanf("%s", &op);

      if (strcmp(op, "insert") == 0) {
          scanf("%d", &x);
          insert(x);
      } else if (strcmp(op, "delete") == 0) {
          scanf("%d", &x);
          delete(x);
      } else if (strcmp(op, "deleteLast") == 0) {
          deleteLast();
      } else {
          deleteFirst();
      }
    }
    
    dump();
}



Measured memory_bytes: 33060
n = int(input())
a = list(map(int, input().split()))
a.sort()

l = [0]*(a[-1] + 1)

for i in range(n):
  l[a[i]] += 1

ans = 0
for i in range(n):
  if l[a[i]] == 1:
    ans += 1
  for j in range(a[i], a[-1] + 1, a[i]):
    l[j] = 2

print(ans)

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

int main(){
    int W,H,x,y,r;
    -100 <= x,y <= 100;
    0 < W,H,r <= 100;
    cin >> W >> H >> x >> y >> r;
    if(0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll ans = 0;
    stack<ll> s;
    REP(i, S.length()) {
        ll n = S[i] - '0';
        if (!s.empty() && s.top() != n) {
            ans += 2;
            s.pop();
        }
        else
            s.push(n);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1232
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ld x;
    cin >> x;
    ld num = 100;

    for(ld i = 1; i <= 10000; i++){
        num += floor(num / 100.0);
        if(num >= x){
            cout << i << endl;
            return 0;
        }
    } 
}


Measured memory_bytes: 3792
#include<stdio.h>
int map[1001][1001];
int dp[1001][1001];
int main(void)
{
	int h,w,n;
	int i,j;
	int x,y;

	scanf("%d %d %d",&h,&w,&n);
	while(h!=0 && w!=0 && n!=0){
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				scanf("%d",&map[i][j]);
				dp[i][j]=0;
			}
		}
		dp[1][1]=n-1;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(dp[i][j]%2==0){
					dp[i+1][j]+=dp[i][j]/2;
					dp[i][j+1]+=dp[i][j]/2;
				}
				else if(dp[i][j]%2!=0){
					if(map[i][j]==1){
						dp[i][j+1]+=dp[i][j]/2+1;
						dp[i+1][j]+=dp[i][j]/2;
					}
					else if(map[i][j]==0){
						dp[i+1][j]+=dp[i][j]/2+1;
						dp[i][j+1]+=dp[i][j]/2;
					}
				}
			}
		}
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(dp[i][j]%2!=0){
					if(map[i][j]==1){
						map[i][j]=0;
					}
					else {
						map[i][j]=1;
					}
				}
			}
		}
		x=1;
		y=1;
		while(x<=h && y<=w){
			if(map[x][y]==1){
				y++;
			}
			else if(map[x][y]==0){
				x++;
			}
		}
		printf("%d %d\n",x,y);
		scanf("%d %d %d",&h,&w,&n);
	}
	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> mat(N, vector<int>(N, 0));
    rep(i, 0, N) {
        int id, deg;
        cin >> id >> deg;
        id--;
        rep(j, 0, deg) {
            int u;
            cin >> u;
            u--;
            mat[id][u] = 1;
        }
    }

    rep(i, 0, N) rep(j, 0, N) {
        cout << mat[i][j] << (j < N - 1 ? " " : "\n");
    }
}



Measured memory_bytes: 3220