akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

//
// a[1] a[2] a[3] a[4] a[5]
// a[1] a[5]
// a[2] a[4]
func reverse(s string, a, b int) string {
	n := b - a + 1
	t := []rune(s)
	for i := 0; i < n/2; i++ {
		t[i+a], t[b-i] = t[b-i], t[i+a]
	}
	return string(t)
}

func main() {
	var s string
	var q int
	fmt.Scan(&s, &q)
	var op, p string
	var a, b int
	for i := 0; i < q; i++ {
		fmt.Scan(&op, &a, &b)
		if op == "replace" {
			fmt.Scan(&p)
		}

		if op == "print" {
			fmt.Println(s[a : b+1])
		} else if op == "reverse" {
			s = reverse(s, a, b)
		} else if op == "replace" {
			t := []rune(s)
			for i, c := range p {
				t[a+i] = c
			}
			s = string(t)
		}
	}
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
vector<int> x,y;
int tox,toy,n,i=0,szx,szy,cntt=0;
string s;
bool canx[20000],cany[20000],tmp[20000];
const int base=8020;
int main ()
{
	ios::sync_with_stdio(false);
	init(canx);init(cany);
	cin>>s;
	cin>>tox>>toy;
	tox+=base;toy+=base;
	n=s.size();
	while(i<n&&s[i]=='F'){
		++i;
		--tox;
	}
	for (i;i<n;){
		int cntf=0;
		while(i<n&&s[i]=='T'){
			++cntt;++i;
		}
		while(i<n&&s[i]=='F'){
			++cntf;++i;
		}
		if (cntt%2==0) x.pb(cntf);
		else y.pb(cntf);
	}
	szx=x.size();szy=y.size();
	canx[base]=1;cany[base]=1;
	for (int i=0;i<szx;++i){
		init(tmp);
		for (int j=0;j<16050;++j){
			if (canx[j]) tmp[j-x[i]]=tmp[j+x[i]]=1;
		}
		for (int j=0;j<16050;++j) canx[j]=tmp[j];
	}
	for (int i=0;i<szy;++i){
		init(tmp);
		for (int j=0;j<16050;++j){
			if (cany[j]) tmp[j-y[i]]=tmp[j+y[i]]=1;
		}
		for (int j=0;j<16050;++j) cany[j]=tmp[j];
	}
	if (canx[tox]&&cany[toy]) cout<<"Yes";
	else cout<<"No";
	return 0; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int x, n; cin >> x >> n;
  set<int> s;

  rep(i, n) {
    int p; cin >> p;
    s.em(p);
  }

  int ans = -1, mn = MOD;
  rep2(i, -1, 101) {
    if (s.count(i)) continue;

    if (mn > abs(i - x)) {
      mn = abs(i - x);
      ans = i;
    }
  }

  cout << ans << endl;
  
  return (0);
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    
    if(A.at(i) % 2 == 0){
      if((A.at(i) % 3 == 0) ||
         (A.at(i) % 5 == 0)){
      }else{
        cout << "DENIED";
        return 0;
      }
    }
    
  }

  cout << "APPROVED";
  return 0;
}


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

using namespace std;

template<typename Weight>
struct Dinic {
    struct Edge {
        int src, dst, rev;
        Weight weight;
        Edge(int f, int t, Weight cap, int rev = 0) :
            src(f), dst(t), rev(rev), weight(cap) {}
    };

    int n;
    vector<vector<Edge>> adj;
    static const Weight INF = numeric_limits<Weight>::max();

    Dinic(int _n) : n(_n), adj(n) {}

    void add_edge(const int src, const int dst, const Weight cap = INF) {
        adj[src].emplace_back(Edge(src, dst, cap, adj[dst].size()));
        adj[dst].emplace_back(Edge(dst, src, 0, adj[src].size() - 1));
    }

    Weight MaximumFlow(const int s, const int t) {
        Weight flow = 0;
        while(true) {
            vector<int> level(n, -1), iter(n);
            Bfs(s, level);
            if(level[t] == -1) break;
            for (Weight f = 0; (f = Dfs(s, t, INF, level, iter)) > 0; )
                flow += f;
        }
        return flow;
    }

    void Bfs(const int s, vector<int> &level){
        queue<int> que;
        for (level[s] = 0, que.push(s); !que.empty(); ) {
            const int v = que.front(); que.pop();
            for (auto &e : adj[v])
                if(0 < e.weight && level[e.dst] == -1){
                    level[e.dst] = level[v] + 1;
                    que.push(e.dst);
                }
        }
    }

    Weight Dfs(int v, int t, Weight flow, vector<int> &level, vector<int> &iter) {
        if(v == t) return flow;
        for ( ; iter[v] < (int)adj[v].size(); ++iter[v]) {
            Edge &e = adj[v][iter[v]];

            if(0 < e.weight && level[v] < level[e.dst]){
                Weight d = Dfs(e.dst, t, min(flow, e.weight), level, iter);
                if(0 < d){
                    e.weight -= d;
                    adj[e.dst][e.rev].weight += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

int Solve() {
    int h, w;
    cin >> h >> w;

    vector<string> hasu(h);
    for (auto &&x : hasu) cin >> x;

    const int s = h + w, t = h + w + 1;
    Dinic<int> g(h + w + 2);

    pair<int, int> ss, tt;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (hasu[i][j] == 'o') {
                g.add_edge(i, h + j, 1);
                g.add_edge(h + j, i, 1);
            }
            else if (hasu[i][j] == 'S') {
                g.add_edge(s, i, 1000);
                g.add_edge(s, h + j, 1000);
                ss = make_pair(i, j);
            }
            else if (hasu[i][j] == 'T') {
                g.add_edge(i, t, 1000);
                g.add_edge(h + j, t, 1000);
                tt = make_pair(i, j);
            }
        }
    }

    // if (ss.first == tt.first || ss.second == tt.second) return -1;

    int res = g.MaximumFlow(s, t);
    return (res < 1000 ? res : -1);
}

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

    cout << Solve() << endl;

    return 0;
}


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

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

    int a[6];
    for (int i=1; i<=5; i++){
        cin>>a[i];
    }
    int ans = -1;
    for (int i=1; i<=5; i++){
        if (a[i]==0) ans = i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3532
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>
#include<map>
using namespace std;

int main(){
    int n;cin >> n;
    map<string,int>tmp;
    string s[100];
    int flag = 1;
    for(int i = 0;i < n;i++){
        cin >> s[i];
        string t = s[i];
        tmp[t]++;
        if(tmp[t] >= 2)flag = 0;
    }
    for(int i = 0;i < n;i++){
        if(flag == 0)break;
        string t = s[i];
        if(i>=1){
            string tm = s[i-1];
            if(t[0] != tm[tm.length()-1]){
                flag = 0;
                break;
            }
        }
    }

    if(flag == 0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3628
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[chr(97+int(i)) for i in range(n)]

Ans=["a"]
if n>=2:
  for _ in range(n-1):
    Ans2=[]
    for a in Ans:
      s=set()
      for aa in a:
        s.add(aa)
      ss=len(s)
      for i in range(ss+1):
        Ans2.append(a+A[i])
    Ans=Ans2
Ans.sort()
for ans in Ans:
  print(ans)

Measured memory_bytes: 12976
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_063
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var ss = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                ss[i] = int.Parse(Console.ReadLine());
                sum += ss[i];
            }
            Array.Sort(ss);
            if (sum % 10 == 0)
            {
                for (int i = 0; i < n; i++)
                {
                    if (ss[i] % 10 == 0) continue;

                    Console.WriteLine(sum - ss[i]);
                    return;
                }
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(sum);
            }
        }
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  int a, b, ans;
  
  cin >> a >> b;
  ans = a + b > a - b ? a + b : a - b;
  ans = ans > a * b ? ans : a * b;
  cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
r, g, b, n = gets.chomp.split(' ').map(&:to_i)

answer = (0..n).map { |i|
  (0..n).select { |j|
    tmp = n - r * i - g * j
    tmp >= 0 && tmp % b == 0
  }.length
}.inject(&:+)
puts(answer)


Measured memory_bytes: 26124
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	std::sort(s.begin(), s.end());
	int j=0;
      if(s[j]!=s[j+2]){
		if(s[j]==s[j+1] && s[j+2]==s[j+3])
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
      }
      else
      {
      	cout<<"No"<<endl;
      }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef unsigned long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
ll x[200010],s[200010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();ll X=gi();
	for(int i=1;i<=n;++i)x[i]=gi(),s[i]=s[i-1]+x[i];
	ll ans=9e18,res;
	for(int i=1;i<=n;++i){
		res=1ll*i*X+5*(s[n]-s[n-i]);
		int l=n-i-i,r=n-i;
		for(int j=5;r>0;j+=2,l-=i,r-=i)res+=1ll*j*(s[r]-s[std::max(0,l)]);
		ans=std::min(ans,res);
	}
	printf("%llu\n",ans+1ll*n*X);
	return 0;
}


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

using namespace std;

int n, m;

int main()
{
    cin >> n >> m;
    int x = 1;
    for (int i = 1; i <= m; i++)
        x = x * 2;
    cout << (1900 * m + 100 * (n - m)) * x;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

class inverse {
    public:
    inverse(int n, int mod);
    ~inverse();
    long long get_inv(int x);
    long long get_fact(int x);
    long long get_invfact(int x);
    long long get_comb(int x, int y);
    
    private:
    int mod;
    long long* inv;
    long long* fact;
    long long* invfact;
};

inverse::inverse(int n, int mod) : mod(mod) {
    inv = (long long *)malloc(sizeof(long long) * (n + 1));
    fact = (long long *)malloc(sizeof(long long) * (n + 1));
    invfact = (long long *)malloc(sizeof(long long) * (n + 1));
    inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    fact[0] = invfact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    for (int i = 1; i <= n; i++) invfact[i] = invfact[i - 1] * inv[i] % mod;
}

inverse::~inverse() {
    free(inv);
    free(fact);
    free(invfact);
}

long long inverse::get_inv(int x) {
    return inv[x];
}

long long inverse::get_fact(int x) {
    return fact[x];
}

long long inverse::get_invfact(int x) {
    return invfact[x];
}

long long inverse::get_comb(int x, int y) {
    return fact[x] * invfact[y] % mod * invfact[x - y] % mod;
}


const int mod = 1000000007;
int n;
int s[200];
long long dp[100001];

int get(int x) {
    int l, r, m;
    
    l = -1, r = n, m = (l + r) / 2;
    
    while (r - l > 1) {
        if (s[m] <= x) {
            r = m;
            m = (l + r) / 2;
        } else {
            l = m;
            m = (l + r) / 2;
        }
    }
    
    return r;
}

int main() {
    int x, i, j;
    long long ans = 0;
    
    scanf("%d %d", &n, &x);
    
    for (i = 0; i < n; i++) scanf("%d", &s[i]);
    
    sort(s, s + n);
    reverse(s, s + n);
    
    inverse inv(n, mod);
    
    dp[x] = inv.get_fact(n) * inv.get_invfact(n - get(x)) % mod;
    
    for (i = x; i >= 0; i--) {
        int p;
        
        if (dp[i] == 0) continue;
        
        p = get(i);
        
        if (p == n) ans += dp[i] * i % mod;
        
        for (j = p; j < n; j++) {
            int y = i % s[j];
            int q = get(y);
            
            dp[y] += dp[i] * inv.get_fact(n - p - 1) % mod * inv.get_invfact(n - q) % mod;
            if (dp[y] >= mod) dp[y] -= mod;
        }
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.push_back(INF);
    sort(all(a));
    Int ng = 0;
    Int ok = 2e5 + 1;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            cnt += n - (lower_bound(all(a), mid - a[i]) - a.begin());
        }
        if (cnt <= m) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    // dump(ok);
    // cout << m << " " << tmp << endl;
    Int cnt = 0;
    for (Int i = 0; i < n; i++) {
        cnt += n - (lower_bound(all(a), ok - a[i]) - a.begin());
    }
    vector<Int> b(n + 1, 0);
    for (Int i = 0; i < n; i++) {
        b[i + 1] = b[i] + a[n - i - 1];
    }
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        Int index = lower_bound(all(a), ok - a[i]) - a.begin();
        res += b[n - index] + (n - index) * a[i];
    }
    if (cnt == m) {
        dump(res);
    } else {
        dump(res + ng * (m - cnt));
    }
    return 0;
}

Measured memory_bytes: 1808
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll cnt = 0;
    for (ll i=1;i<n;i++){
        if(n%i==0){
            cnt+= n/i - 1;
        }else{
            cnt+= n/i;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int arr[n][3];
    for (int i = 0; i < n; ++i) cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    int dp[n][3];
    for (int j = 0; j < 3; ++j) dp[0][j] = arr[0][j];
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
            dp[i][j] = arr[i][j] + max(dp[i-1][(j+2)%3], dp[i-1][(j+1)%3]);
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << '\n';
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    int N; cin >> N;
    vector<vector<int>> counts(26, vector<int>(N));
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        for (auto c : s) {
            counts[c - 'a'][i]++;
        }
    }

    string ans = "";
    for (int i = 0; i < 26; i++) {
        int count = -1;
        for (int j = 0; j < N; j++) {
            if (0 <= counts[i][j]) {
                if (count == -1) {
                    count = counts[i][j];
                }
                else {
                    count = min(count, counts[i][j]);
                }
            }
        }

        for (int k = 0; k < count; k++) {
            char x = i + 'a';
            ans += x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    s = input()
    n = len(s)
    k = int(input())
    # dp[使った回数][左端からの距離][左端]
    dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]

    if n == 1:
        print(1)
        return
    dp2 = dp[0][1]
    for i in range(n-1):
        if s[i] == s[i+1]:
            dp2[i] = 2
    if k > 0:
        for cnt in range(1, k+1):
            dp2 = dp[cnt][1]
            for i in range(n-1):
                dp2[i] = 2

    for cnt in range(k):
        dp2 = dp[cnt]
        for d in range(2, n):
            dp3 = dp2[d]
            for left in range(n-d):
                right = left+d
                plus = (s[left] == s[right])*2
                dp3[left] = max(
                    dp3[left], dp2[d-1][left],
                    dp2[d-1][left+1], dp2[d-2][left+1]+plus)
                dp[cnt+1][d][left] = max(
                    dp[cnt+1][d][left], dp3[left], dp2[d-2][left+1]+2)
    dp2 = dp[k]
    for d in range(2, n):
        dp3 = dp2[d]
        for left in range(n-d):
            right = left+d
            plus = (s[left] == s[right])*2
            dp3[left] = max(
                dp3[left], dp2[d-1][left], dp2[d-1][left+1], dp2[d-2][left+1]+plus)
    print(dp[-1][-1][0])


main()


Measured memory_bytes: 154076
import java.io.*;
import java.lang.Math;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    double r=Double.parseDouble(br.readLine());

    double l=2*Math.PI*r;
    double s=Math.pow(r,2)*Math.PI;

    System.out.println(String.format("%.6f",s)+" "+String.format("%.6f",l));
  }
}


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

using namespace std;

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

    int count;

    if (N % 2 == 0)
    {
        count = N / 2;
    }
    else
    {
        count = N / 2 + 1;
    }

    double rate = (double)count / N;

    cout << rate << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = Integer.MAX_VALUE;
        int n = s.length()-2;
        for(int i = 0; i < n; i++){
            int si = Integer.parseInt(s.substring(i,i+3));
            ans = Math.min(ans,Math.abs(753-si));
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 22612
#include <stdio.h>

char a, b, c, d, e, f, g, h, i = 0;


int main(void) {

  scanf("%c%c%c\n", &a, &b, &c);
  scanf("%c%c%c\n", &d, &e, &f);
  scanf("%c%c%c", &g, &h, &i);

  printf("%c%c%c\n", a, e, i);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int s[n], t[m];
    rep(i, n) scanf("%d", &s[i]);
    rep(i, m) scanf("%d", &t[i]);
    lint mod = 1e9 + 7;
    lint dp[n+1][m+1];
    rep(i, n+1)rep(j, m+1) dp[i][j] = 0;
    dp[0][0] = 1;
    lint dpsum[n+2][m+2];
    rep(i, n+2)rep(j, m+2) dpsum[i][j] = (i==1 || j==1 ? 1 : 0);
    lint ans = 1;
    For(i, 1, n+1)For(j, 1, m+1){
        if(s[i-1] == t[j-1]) dp[i][j] = dpsum[i][j] % mod;
        ans = (ans + dp[i][j]) % mod;
        dpsum[i+1][j+1] = (dpsum[i+1][j] + dpsum[i][j+1] - dpsum[i][j] + mod + dp[i][j]) % mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 62848
//Coalbert Ramirez
//ARC 97C - K-th Substring
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=a;i<n;++i)

string s;
int k, sz;
vector<string> a;

int main(){
  cin >> s >> k;
  sz = s.size();
  FOR(i,0,sz) FOR(j,0,k) if (i+j < sz) a.push_back(s.substr(i,j+1));
  sort(a.begin(), a.end());
  unique(a.begin(), a.end());
  cout << a[k-1] << "\n";
  return 0;
}

Measured memory_bytes: 1660
import collections
N = int(input())
A = sorted(list(map(int, input().split())))
ans = 1

AA = collections.Counter(A)
cc = [0]*(max(A)+1)

for i in AA.keys():
    cc[i] = AA[i]
#len(cc)-1にしておくと例えばN=2 A= 0 0のときに不具合が出てくるそれがWAの理由
for i in range(len(cc)):
    ans =  max(ans, sum(cc[i:i+3]))

print(ans)

Measured memory_bytes: 14548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll k,a,b;
    cin>>k>>a>>b;

    ll ans = 0;
    if(a+1 >= b){
        ans = 1+k;
    }
    else if(a-1 <= k){
       k-=(a-1);
       ll n = (k/2);
       ans = n*b - (n-1)*a;
       if(k%2)
            ans++; 
    }
    cout<<ans; 
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> C(H);
    REP(i, H) {
        C[i].resize(W);
        string str;
        cin >> str;
        REP(j, W) {
            C[i][j] = (str[j] == '#') ? 1 : 0;
        }
    }
    
    int hnum = 1 << H;
    int wnum = 1 << W;
    int ans = 0;
    FOR(i, 0, hnum) FOR(j, 0, wnum) {
        int cnt = 0;
        FOR(k, 0, H) {
            FOR(l, 0, W) {
                if (C[k][l] == 1) {
                    if ((i & (1 << k)) && (j & (1 << l))) cnt++;
                }
            }
        }
        if (cnt == K) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[100005];
ll lis(ll n) {
    ll INF = 1e9;
    vector<ll> d(n+1, INF);
    d[0] = -INF;

    for (ll i = 0; i < n; i++) {
        ll j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (d[j-1] <= a[i] && a[i] <= d[j])
            d[j] = a[i];
    }

    ll ans = 0;
    for (ll i = 0; i <= n; i++) {
        if (d[i] < INF)
            ans = i;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i]*=(-1);
    }
    cout<<lis(n);
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
	int n,m,sum=0;
	cin>>n>>m;
	vector<int>x(m),y(m-1);
	for(int i=0;i<m;i++){
		cin>>x[i];
	}
	if(n>m){
		cout<<0<<endl;
	}
	else{
	sort (x.begin(),x.end());
	for(int i=0;i<m;i++){
		if(i==m-1)break;
		y[i]=x[i+1]-x[i];	
	}
	sort(y.begin(),y.end());
	for(int i=0;i<m-n;i++){
		sum+=y[i];
	}
	cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
void shuffle(int *array,int n);
void cut(int *array,int n,int k);
main(){
    int N,M;
    int cards[200];
    scanf("%d%d",&N,&M);
    for(int i = 0;i < N*2;i++){
        cards[i] = i+1;
    }
    for(int i = 0;i < M;i++){
        int n;
        scanf("%d",&n);
        if(n == 0){
            shuffle(cards,N*2);
        }else{
            cut(cards,N*2,n);
        }
    }
    for(int i = 0;i < N*2;i++){
        printf("%d\n",cards[i]);
    }
}
void shuffle(int *array,int n){
    int tmp[200];
    for(int i = 0;i < n;i++){
        tmp[i] = array[i];
    }
    for(int i = 0;i < n/2;i++){
        array[i*2] = tmp[i];
        array[i*2+1] = tmp[i+n/2];
    }
}
void cut(int *array,int n,int k){
    int tmp[200];
    for(int i = 0;i < n;i++){
        tmp[i] = array[i];
    }
    for(int i = 0;i < n-k;i++){
        array[i] = tmp[i+k];
    }
    for(int i = n-k;i < n;i++){
        array[i] = tmp[i-n+k];
    }
}

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

int main(){
  string s;
  int q;
  cin >> s >> q;
  vector<string> a(2, "");
  int f=0;
  rep(i, q){
    int t;
    cin >> t;
    if(t == 1) f = 1 - f;
    else{
      int f_;
      char c;
      cin >> f_ >> c;
      a[(f+f_-1)%2] += c;
    }
  }
  reverse(a[f].begin(), a[f].end());
  if(f == 1) reverse(s.begin(), s.end());
  cout << a[f] << s << a[1-f] << endl;
  return 0;
}


Measured memory_bytes: 3884
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();

    if ((N + 1) / 2 >= K) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23124
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
def inv_gcd(a, b):
    a = (a + b) % b
    if a == 0:
        return (b, 0)
    s, t = b, a
    m0, m1 = 0, 1
 
    while t:
        u = s // t
        s -= t * u
        m0 -= m1 * u
 
        tmp = s
        s = t
        t = tmp
        tmp = m0
        m0 = m1
        m1 = tmp
    
    if m0 < 0:
        m0 += b // s
    return (s, m0)
 
 
def crt(r, m):
    n = len(r)
    r0, m0 = 0, 1
 
    for i in range(n):
        r1, m1 = (r[i] + m[i]) % m[i], m[i]
 
        if m0 < m1:
            m0, m1 = m1, m0
            r0, r1 = r1, r0
        
        if m0 % m1 == 0:
            if r0 % m1 != r1:
                return (0, 0)
            continue
        
        g, im = inv_gcd(m0, m1)
 
        u1 = m1 // g
        if (r1 - r0) % g:
            return (0, 0)
        
        x = (r1 - r0) // g % u1 * im % u1
 
        r0 += x * m0
        m0 *= u1
        if (r0 < 0):
            r0 += m0
        
    return (r0, m0)


def divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.sort()
  return divisors


# print(divisors(z))

z=int(input())


ans = z-1 if z%2 else 2*z-1
for i in divisors(2*z):
  y=2*z//i
  if y == 1:
    continue
  a=[0,-1]
  b=[i,y]
  rem, mod = crt(a, b)
  #print(rem)
  #print(mod)
  if rem == mod == 0:
      continue
  ans = min(ans, rem)

print(ans if z-1 else 1)

Measured memory_bytes: 69864
fun readInts() = readLine()!!.split(" ").map(String::toInt)

const val P = 1000000007L

data class FiniteField(val x: Long) {
  operator fun plus(o: FiniteField) = FiniteField((x + o.x) % P)
  operator fun plus(o: Int) = this + FiniteField(o.toLong())
  operator fun minus(o: FiniteField) = FiniteField((x + P - o.x) % P)
  operator fun minus(o: Int) = this - FiniteField(o.toLong())
  operator fun times(o: FiniteField) = FiniteField((x * o.x) % P)
  operator fun times(o: Int) = this * FiniteField(o.toLong())
}

fun pow2(p: Int): FiniteField {
  if (p == 0) return FiniteField(1L)
  val x = pow2(p / 2)
  return if (p % 2 == 0) x * x else x * x * 2
}

data class Edge(val v1: Int, val v2: Int, val w: Long, val id: Int)

// Union-Find Set.
class UFSet(n: Int) {
  private var ranks = IntArray(n, { 1 })
  private var prevs = IntArray(n, { it })

  // Returns a root of a tree which x belongs to.
  fun find(x: Int): Int {
    if (x != prevs[x]) prevs[x] = find(prevs[x])
    return prevs[x]
  }

  // Merges a set which x belongs to and a set which y belongs to.
  fun union(x: Int, y: Int) {
    val xRoot = find(x)
    val yRoot = find(y)
    when {
      ranks[xRoot] > ranks[yRoot] -> prevs[yRoot] = prevs[xRoot]
      ranks[xRoot] < ranks[yRoot] -> prevs[xRoot] = prevs[yRoot]
      prevs[xRoot] != prevs[yRoot] -> {
        prevs[yRoot] = prevs[xRoot]
        ranks[xRoot]++
      }
    }
  }
}

fun makeMST(n: Int, e: Edge, edges: Array<Edge>): Long {
  val ufSet = UFSet(n)
  var totalW = 0L
  ufSet.union(e.v1, e.v2)
  totalW += e.w
  for (e in edges) {
    if (ufSet.find(e.v1) == ufSet.find(e.v2)) continue
    ufSet.union(e.v1, e.v2)
    totalW += e.w
  }
  return totalW
}

fun main(args: Array<String>) {
  val (n, m) = readInts()
  val x = readLine()!!.toLong()
  val edges = Array(m, {
    val (uRaw, vRaw, w) = readInts()
    Edge(uRaw - 1, vRaw - 1, w.toLong(), it)
  })
  edges.sortWith(java.util.Comparator { e1, e2 -> java.lang.Long.compare(e1.w, e2.w) })
  val mstCosts = edges.map { makeMST(n, it, edges) }

  fun countEdges(w: Long): Int {
    return mstCosts.count { it <= w }
  }

  fun countColorings(w: Long): FiniteField {
    val numEdges = countEdges(w)
    if (numEdges == 0) return pow2(m)
    return pow2(m - numEdges) * 2
  }

  val ans = countColorings(x - 1) - countColorings(x)
  println(ans.x)
}


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

int main() {
  int n;
  cin >> n;
  vector<string> S(n);
  for (int i = 0; i<n; i++) cin >> S[i];
  long long  M = 0, A=0, R=0, C=0, H=0;
  for (int i = 0; i < n; i++) {
    if (S[i][0] == 'M') M++;
    if(S[i][0] == 'A') A++;
    if(S[i][0] == 'R') R++;
    if(S[i][0] == 'C') C++;
    if(S[i][0] == 'H') H++;
  }
  long long cnt = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + R * C * H + A * C * H;
  cout << cnt << endl;
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int n = 0;
	
	for( int i=0; i < 4; i++ ) {
		n += (s[i] == '+') ? 1:-1;
	}
	cout << n << endl;
}


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

int main() {
  string s, t;
  int a, b;
  cin >> s >> t >> a >> b;
  string x;
  cin >> x;
  if (x == s) cout << a - 1 << ' ' << b << endl;
  else cout << a << ' ' << b - 1 << endl;
}

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

using namespace std;

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

    int q;
    cin>>q;

    set<int> Set;
    while(q--)
    {
        int op,x;
        cin>>op>>x;

        if(!op)
        {
            Set.insert(x);
            cout<<Set.size()<<endl;
        }else if(op==1)
        {
            cout<<(Set.find(x)!=Set.end())<<endl;
        }else
        {
            Set.erase(x);
        }
    }

    return 0;
}



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

int main(){
	long long n;
	cin>>n;
	long long minmove = n-1;
	for(long long i=1; i*i<=n; i++){
		if(n%i==0){
			minmove = min(minmove,(i-1)+(n/i-1));
		}
	}
	cout<<minmove;
}

Measured memory_bytes: 3636
import java.util.*;
    import java.io.*;

    public class Main {

    void solve(InputReader in, PrintWriter out) {
        char[] arr = in.next().toCharArray();
        int N = arr.length;
        for (int i = 0, j = (N-1)/2 - 1; i < j; ++i, --j) {
            if (arr[i] != arr[j]) {
                out.println("No");
                return;
            }
        }

        for (int i = N/2 + 1, j = N - 1; i < j; ++i, --j) {
            
            if (arr[i] != arr[j]) {
                out.println("No");
                return;
            }
        }

        for (int i = 0, j = N - 1; i < j; ++i, --j) {
            if (arr[i] != arr[j]) {
                out.println("No");
                return;
            }
        }

        out.println("Yes");
    }

    

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Main solver = new Main();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader(InputStream is) {
        in = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
        try {
            while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        }

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

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


Measured memory_bytes: 21972
A,B,C,D,E,F = map(int,input().split())

nou = [0,100*A]
for a in range(31):
    for b in range(31):
        for c in range(3001):
            if a==0 and b==0:
                continue
            if F<(100*A*a+100*B*b+C*c):
                continue
            if E*(A*a+B*b)<C*c:
                continue
            #abcが決まればdはEとFの上限を超えないギリギリを責めればいい
            d = max(0, (F-(100*A*a+100*B*b+C*c))//D)#Fの条件
            d = min(d,(E*(A*a+B*b)-C*c)//D)

            if nou[0]*((100*A*a+100*B*b)+(C*c+D*d)) < (C*c+D*d)*nou[1]:
                nou = [C*c+D*d,((100*A*a+100*B*b)+(C*c+D*d)),a,b,c,d]

print(nou[1],nou[0])

Measured memory_bytes: 73768
N, K = map(int, input().split())
p = list(map(int, input().split()))

m = [(e + 1) / 2 for e in p]

t = sum(m[0:K])
result = t
for i in range(N - K):
    t += m[i + K] - m[i]
    if t > result:
        result = t
print(result)


Measured memory_bytes: 25060
inputstr = input().split()
#*1000
QHSD = [[250,int(inputstr[0])],[500,int(inputstr[1])],[1000,int(inputstr[2])],[2000,int(inputstr[3])]]
N = int(input()) * 1000

QHSDs = sorted(QHSD, key=lambda x: x[1]/x[0])

amari = N
ans = 0
for row in QHSDs:
    ans += (amari // row[0]) * row[1]
    amari %= row[0]
    
print(ans)

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

#define rep(i,n) for(int i=0 ; i < n ; i++)

int calc(string c,int a,int b)
{
	if(c == "+") return a+b;
	if(c == "-") return a-b;
	if(c == "*") return a*b;
}

int main()
{
	int a[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] && a[0] && a[1] && a[2] && a[3])
	{
		sort(a,a+4);
		bool flag = true;
		string ope[3] = {"+","-","*"};
		do
		{
			rep(i,3)
			{
				rep(j,3)
				{
					rep(k,3)
					{
						int h = calc(ope[i],a[0],a[1]);
						int h2 = calc(ope[j],a[1],a[2]);
						int h3 = calc(ope[k],a[2],a[3]);
						if(calc(ope[j],h,h3) == 10 && flag)
						{
							cout << "(("<< a[0] << " "+ope[i] << " " << a[1] << ") "+ope[j] << " (" << a[2] << " "+ope[k] << " " << a[3] << "))" << endl;
							flag = false;
						}
						if(calc(ope[k],calc(ope[j],h,a[2]),a[3]) == 10 && flag)
						{
							cout << "(((" << a[0] << " "+ope[i] << " " << a[1] << ") "+ope[j] << " " << a[2] << ") "+ope[k] << " " << a[3] << ")" << endl;
							flag = false;
						}
						if(calc(ope[k],calc(ope[i],a[0],h2),a[3]) == 10 && flag)
						{
							cout << "((" << a[0] << " "+ope[i] << " (" << a[1] << " "+ope[j] << " " << a[2] << ")) "+ope[k] << " " << a[3] <<")" << endl; 
							flag = false;
						}
					}

				}
			}
		}while(next_permutation(a,a+4));

		if(flag) cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
h, w = gets.chomp.split(' ').map(&:to_i)
board = h.times.map { gets.chomp.chars }
INF = 1_000_000_000
memo = Array.new(h) { Array.new(w) { INF } }

W = '.'
B = '#'
DS = [[-1, 0], [0, -1], [1, 0], [0, 1]]

memo[0][0] = 1

def fill(x, y, board, memo)
  v = DS.map { |dx, dy | [x + dx, y + dy] }.select do |x1, y1|
    x1 >= 0 && y1 >= 0
  end.map do |x1, y1|
    memo.fetch(x1, [])[y1] || INF
  end.min
  if (v + 1) < memo[x][y]
    memo[x][y] = v + 1
  end
end

def get_next(x, y, board, memo)
  DS.map { |dx, dy| [x + dx, y + dy] }.select do |i, j|
    next false if board.fetch(i, [])[j] != W
    next false unless i >= 0 && j >= 0 && i < board.length && j <= board[0].length
    memo[x][y] < memo[i][j]
  end
end

list = [[0, 0]]
while point = list.shift
  x, y = point
  next if board[x][y] != W

  fill(x, y, board, memo)
  list += get_next(x, y, board, memo)
  list.uniq!
end

goal_count = memo[h - 1][w - 1]
if goal_count == INF
  puts '-1'
  exit
end

b_count = board.inject(0) { |s, l| s + l.count(B) }
puts (h * w) - goal_count - b_count


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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    long long res = 0;
    for (int c = 1; c < n-1; c++) {
        long long tmp = 0;
        for (int k = 0; (k+1)*c <=n-1; k++) {
            int A = n-1 - k*c;
            int B = A - c;
            if ((n-1)%c == 0 && 2*k > (n-1)/c - 1) {
                break;
            }
            if (B <= 0) break;
            tmp += 0ll + a[A] + a[k*c];
            res = max(res, tmp);
        }
    }
    cout << res;
}

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


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

using ll = long long;

int main() {
    const int target = 753;
    string s;
    cin >> s;
    int diff = 10000;
    rep(i, s.size() - 2) {
        int num = atoi(s.substr(i, 3).c_str());
        int tdiff = abs(target - num);
        if(diff > tdiff)
            diff = tdiff;
    }
        cout << diff << endl;
    return 0;
}


Measured memory_bytes: 256
def main() -> None:
    n, k = map(int, input().split())

    check = [0] * n
    for _ in range(k):
        _ = input()
        having = tuple(map(int, input().split()))
        for idx in having:
            check[idx-1] += 1
    print(check.count(0))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
s = input()
cnt = 0
flg = 0
ans = 0
for i in range(len(s)-1):
  if s[i] == "A":
    if flg == 0:
      cnt += 1
    else:
      cnt = 1
  elif s[i:i+2] == "BC":
    ans += cnt
    flg = 1
  elif flg == 1:
    flg = 0
    continue
  else:
    cnt = 0
print(ans)

Measured memory_bytes: 3500
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
ll N, M, L;
ll ans = 0;
ll INF = 1145141919191919;

vector<vector<pair<ll, ll> > > G;
 
vector<ll > dijkstra(ll start){
    //準備
    vector<bool > used(N, false);
    vector<ll > dist(N, INF);
    priority_queue<pair<ll, ll > , vector<pair<ll, ll > >, greater<pair<ll, ll > > > que;
    //初期化
    que.push(make_pair(0, start));
 
    while(!que.empty()){
        //距離
        ll d = 0;
        //次の頂点
        ll t_v = 0;
        d = que.top().first;
        t_v = que.top().second;
        //topから削除
        que.pop();
        //探査済みなら処理しない
        if(used[t_v] == true) continue;
        //探査済みにする
        used[t_v] = true;
        //キューの上には既に最小距離が来ているので
        dist[t_v] = d;
        
        for(ll i = 0; i < G[t_v].size(); i++){
            //大きいときは更新しない
            ll to = G[t_v][i].first;
            ll cost = d+G[t_v][i].second;
            if(dist[to] <= cost) continue;
            //累積距離と次の頂点
            que.push(make_pair(cost, to));
            //仮dist
            dist[to] = cost;
        }

        if(t_v-1 < 0 || dist[t_v-1] <= d) continue;
        que.push(make_pair(d, t_v-1));
        dist[t_v-1] = d;
        

    }   
    
    return dist;
 
} 
 
int main() {
    //頂点数
    cin >> N >> M;

    G.assign(N, vector<pair<ll, ll > >());
 
    for(ll i = 0; i < M; i++){   
        ll u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(make_pair(v, w));
    }

    vector<ll > dist = dijkstra(0);

    if(dist[N-1] == INF){
        cout << -1 << endl;
    }else{
        cout << dist[N-1] << endl;
    }
    

}

Measured memory_bytes: 6908
import scala.io.{StdIn => in}

object Main extends App {
  val out = new java.io.PrintWriter(System.out)
  val Array(a, b, k) = in.readLine.split(" ").map(_.toInt)

  val ans = ((a to b).take(k) ++: (a to b).takeRight(k)).toArray.distinct
  ans.foreach(out.println)
  out.flush
}

Measured memory_bytes: 25416
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
ll abs(ll x){return x<0?-x:x;}
inline void check_min(ll a,ll &b){if(a<b)b=a;}
const int N=201000;
const ll INF=9223300000000000000ll;
ll f[N];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",f+i),f[i]+=f[i-1];
	ll ans=INF;
	for(int i=1;i<n;i++)
		check_min(abs(f[n]-f[i]*2ll),ans);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
int rd()
{
	int num = 0;char c = getchar();bool flag = true;
	while(c < '0'||c > '9') {if(c == '-') flag = false;c = getchar();}
	while(c >= '0' && c <= '9') num = num*10+c-48,c = getchar();
	if(flag) return num;else return -num;
}
char s[201000];
int main()
{
	scanf("%s",s+1);
	int i = 1,n = strlen(s+1),cnt = 0;
	while(s[i] == 'W') i++;
	ll ans = 0;
	for(;i <= n;i++) if(s[i] == 'W') ans += cnt;
	else cnt++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#define RESIDENCE	4
#define FLOOR		3
#define ROOM		10

int main(){
	int array[RESIDENCE][FLOOR][ROOM]={};
	int n;
	std::cin>>n;

	for(int i=0;i<n;i++){
		int data[4];
		for(int j=0;j<4;j++){
			std::cin>>data[j];
		}
		array[data[0]-1][data[1]-1][data[2]-1]+=data[3];
	}
	for(int i=0;i<RESIDENCE;i++){
		if(i!=0){
			std::cout<<"####################"<<std::endl;
		}
		for(int j=0;j<FLOOR;j++){
			for(int k=0;k<ROOM;k++){
				std::cout<<" "<<array[i][j][k];
			}
			std::cout<<std::endl;
		}
	}
}

Measured memory_bytes: 1164
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S, T := nextLine(), nextLine()
	fmt.Println(T + S)
}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size(),sub,ans=650;
  int a,b,c;
  for(int i=0;i<n-2;i++){
    a=s.at(i)-48,b=s.at(i+1)-48,c=s.at(i+2)-48;
    sub=abs(a*100+b*10+c-753);
    ans=min(ans,sub);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int rotateX(int x1, int y1, int x2, int y2)
{
    int x = x2 + y1 - y2;
    return x;
}

int rotateY(int x1, int y1, int x2, int y2)
{
    int y = y2 - 1 * (x1 - x2);
    return y;
}

int main(void)
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;

    x3 = rotateX(x1, y1, x2, y2);
    y3 = rotateY(x1, y1, x2, y2);

    x4 = rotateX(x2, y2, x3, y3);
    y4 = rotateY(x2, y2, x3, y3);

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

    return 0;
}

Measured memory_bytes: 256
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var threeDigit = parseInt(parts[0] + parts[1] + parts[2]);
console.log(threeDigit % 4 == 0 ? "YES" : "NO");

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

int main(){
  int k,s;
  cin >> k >> s;

  int count=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z=s-(x+y);
      if(z>=0&&z<=k) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256