akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
static Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		long x=sc.nextLong();
		long n=(long)x/11;
		long m=x%11;
		long result=0;
		if(m==0){
			result=2*n;
		}
		else{
			if(m<=6){
			result=2*n+1;
			}
		else{
			result=2*n+2;
			}
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 9808
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	var count = 0
	for i := 0; i < n; i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		if isPrime(x) {
			count++
		}
	}
	fmt.Println(count)
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	} else if x == 2 {
		return true
	} else if x%2 == 0 {
		return false
	} else {
		y := int(math.Sqrt(float64(x)))
		for i := 3; i <= y; i++ {
			if x%i == 0 {
				return false
			}
		}
		return true
	}
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	v, err := strconv.Atoi(sc.Text())
	return v, err
}



Measured memory_bytes: 1192
package main

import "fmt"

const (
	yes = "Yes"
	no  = "No"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d\n", &a, &b, &c)

	switch {
	case a == b+c || b == a+c || c == a+b:
		fmt.Println(yes)
	default:
		fmt.Println(no)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> mu(1, 0);
  if (s[0] == 'R') mu[0]++;
  else mu[0]--;
  
  int c = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i-1]) {
      if (s[i] == 'R') mu[c]++;
      else mu[c]--;
    }
    else {
      c++;
      if (s[i] == 'R') mu.push_back(1);
      else mu.push_back(-1);
    }
  }
  int N = mu.size();
  int h = 0;
  for (int x : mu) {
    if (x > 0) h += (x - 1);
    else h += (-1 - x);
  }
  
  for (int i = 0; i < k; i++) {
    if (h==n-1) break;
    else if (h == n - 2) h++;
    else h += 2;
  }
  cout<<h<<endl;
}

Measured memory_bytes: 1020
n, m = gets.chomp.split(" ").map(&:to_i)
divisor = []

i = 1
while i * i <= m
    if m % i == 0 then
        divisor << i
        tmp = m / i
        divisor << tmp if tmp != i
    end
    i += 1
end

divisor.sort!

ans = 0
divisor.each do |i|
    ans = i > ans ? i : ans if i * n <= m
end
puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define M 20 + 5
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define dep(i, l, r) for(int i = r; i >= l; --i)
int n, q, l, a, b, ans, x[N], f[N][M];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int main(){
    n = read();
    rep(i, 1, n) x[i] = read();
    l = read(); 
    rep(i, 1, n){
        int pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x;
        if(x[pos] < x[i] + l) f[i][0] = n + 1;
        else f[i][0] = pos - 1;
    }
    rep(j, 1, M - 5) rep(i, 1, n) if(f[i][j - 1]) f[i][j] = f[f[i][j - 1]][j - 1];
    q = read();
    while(q--){
        a = read(), b = read(), ans = 0; if(a > b) swap(a, b);
        dep(i, 0, M - 5) if(f[a][i] < b && f[a][i]) a = f[a][i], ans += (1 << i);
        if(a < b) ++ans;
        printf("%d\n", ans);
    }
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  if ((b - a) % 2 != 0) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << (a + b) / 2 << endl;
}


Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10000000)

def visit_tree(now, num):
    visited[now] = num
    for i in range(len(tree[now])):
        if not visited[tree[now][i]]:
            visit_tree(tree[now][i], num)

n, m = map(int, input().split())
tree = [[] for _ in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    tree[x - 1].append(y - 1)
    tree[y - 1].append(x - 1)

visited = [0 for _ in range(n)]
num = 0
for i in range(n):
    if not visited[i]:
        num += 1
        visit_tree(i, num)

print(num)

Measured memory_bytes: 109500
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long t,n,count=0,x,y;
cin>>t>>n;
for(int i=0;i<t;i++){
   cin>>x>>y;
   double d=sqrt(x*x+y*y);
   if(d<=n)
    count++;
}
cout<<count<<endl;


    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int n,c,x,y,i;
multiset<int>S;
main()
{
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>c>>x;
    if(c==1)cout<<S.count(x)<<endl;
    else if(c==0)S.insert(x),cout<<S.size()<<endl;
    else if(c==2)S.erase(x);
    else
    {
      cin>>y;
      auto a=S.lower_bound(x),b=S.upper_bound(y);
      for(auto it=a;it!=b;it++)cout<<*it<<endl;
    }
  }
}


Measured memory_bytes: 12304
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char a[20];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf("%s", a);
    int n = strlen(a);
    int f = 0;
    if (n%2 == 0) {
        f = 1;
        for (int i = 0; i < n; i+=2)
            if (a[i] != 'h' || a[i+1] != 'i')
                f = 0;
    }
    printf(f ? "Yes\n" : "No\n");

    return 0;
}


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  
  char A=toupper(a.at(0));
  char B=toupper(b.at(0));
  char C=toupper(c.at(0));
  
  cout << A << B << C << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool include3(int n) {
    while (n) {
        if (n % 10 == 3) return true;
        n /= 10;
    }
    return false;
}

void call(int n) {
    for (int i = 1; i<= n; i++) {
        if (i % 3 == 0 || include3(i)) cout << ' ' << i;
    }
    cout << endl;
}

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


Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

# define int long long

int n, p;
string s;

ll cnt[10010];

int mod_pow(int x, int n) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % p;
        x = (x * x) % p;
        n >>= 1;
    }
    return res;
}

int mod_inverse(int x) {
    return mod_pow(x, p-2);
}

ll solve() {
    if (p == 2) {
        ll res = 0;
        for (int i = 0; i < n; i++) {
            int c = (int)(s[i] - '0');
            if (c % 2 == 0)
                res += i+1;
        }
        return res;
    }
    if (p == 5) {
        ll res = 0;
        for (int i = 0; i < n; i++) {
            int c = (int)(s[i] - '0');
            if (c == 0 || c == 5)
                res += i+1;
        }
        return res;
    }
    ll res = 0;
    int a = 0;
    int t = 1;
    for (int i = 0; i < n; i++) {
        int c = (int)(s[i] - '0');
        if (c % p == 0) res++;
        int r = (p - c % p) % p;
        int x = r * mod_inverse(10);
        x += p - a;
        x %= p;
        x *= mod_inverse(t);
        x %= p;
        res += cnt[x];
        int y = (p - a) % p;
        y *= mod_inverse(t);
        y %= p;
        cnt[y]++;
        a *= 10;
        a += c;
        a %= p;
        t *= 10;
        t %= p;
    }
    return res;
}

void input() {
    cin >> n >> p >> s;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3488
use std::io::{stdin, BufRead, BufReader};

fn main() {
    let input = BufReader::new(stdin());
    for line in input.lines() {
        let mut v: Vec<u32> = line.unwrap()
            .split_whitespace()
            .filter_map(|x| x.parse::<u32>().ok())
            .collect();
        v.sort();
        println!("{} {}", lcm(v[1], v[0]), gcd(v[1], v[0]));
    }
}

fn lcm(a: u32, b: u32) -> u32 {
    let m = a % b;
    return match m {
        0 => b,
        _ => lcm(b, m),
    };
}

fn gcd(a: u32, b: u32) -> u64 {
    let l = lcm(a, b) as u64;
    let a = a as u64;
    let b = b as u64;
    return (a * b) / l;
}



Measured memory_bytes: 5024
#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>;


vector<int> p;
bool check() {
    int n = p.size();
    rep(i, n-1) {
        if ( ! (p[i] <= p[i+1]) ) {
            return false;
        }
    }
    return true;
}

void solve() {
    int n;
    cin >> n;
    rep(i, n) {
        int t;
        cin >> t;
        p.push_back(t);
    }

    rep(i, n) {
        rep(j, n) {
            swap(p[i], p[j]);
            if (check()) {
                cout << "YES" << endl;
                return;
            }
            swap(p[i], p[j]);
        }
    }

    cout << "NO" << endl;
}

int main() {
    solve();
    return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());

    std::vector<long long> reminders(13, 0);
    reminders[0] = 1;

    int pos = 1;
    const int mod = 1000000007;

    for (auto c : s) {
        std::vector<long long> new_reminders(13, 0);
        if (c == '?') {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 13; j++) {
                    new_reminders[(i * pos + j) % 13] += reminders[j];
                    new_reminders[(i * pos + j) % 13] %= mod;
                }
            }
        } else {
            int i = c - '0';
            for (int j = 0; j < 13; j++) {
                new_reminders[(i * pos + j) % 13] += reminders[j];
                new_reminders[(i * pos + j) % 13] %= mod;
            }
        }

        pos *= 10;
        pos %= 13;
        reminders = new_reminders;
    }

    std::cout << reminders[5] << std::endl;
}


Measured memory_bytes: 512
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a.sort()
ct = Counter(a)
st = set()
ans = 0
x = max(a)
for i in range(n):
    if a[i] in st:
        continue
    if ct[a[i]]>1:
        st.add(a[i])
    for j in range(2,x//a[i]+1):
        st.add(a[i]*j)
for i in range(n):
    if not a[i] in st:
        ans += 1
print(ans)

Measured memory_bytes: 92936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main(){
    string s; cin>>s;
    int flag=0,cnt=0;
    for(int i=1; i<s.size(); i++){
      if(flag&&s[i-1]==s[i]){
        flag=0;
      }else if(s[i-1]==s[i]){
        flag=1;
      }
      if(flag){
        cnt++;
      }
    }
    cout<<cnt<<endl;
}


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

ll sol(ll x, ll y) {
	ll X = x, Y = y;
	while (x) {
		swap(x, y);
		x %= y;
	}
	return X / y * Y;
}

int main() {
	ll N, t, ans;
	cin >> N;
	cin >> ans;
	for (int i = 1;i < N;i++) {
		cin >> t;
		ans = sol(ans, t);
		//cout << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#include <algorithm>

long xxx(long x)
{
	for (long i = 0; i < 64; ++i) {
		if (x < (1 << i)) {
			return (1 << i) - x;
		}
	}
	return 0;
}

int main()
{
	long N;
	std::multiset<long, std::greater<long> > A;
	int n = 0;

	std::cin >> N;
	for (long i = 0; i < N; ++i) {
		long j;
		std::cin >> j;
		A.insert(j);
	}

	while (A.size() >= 2) {
		auto it = A.begin();
		long v = *it;
		A.erase(it);
		long u = xxx(v);
		auto jt = A.find(u);
		if (jt != A.end()) {
			A.erase(jt);
			++n;
			continue;
		}
	}

	std::cout << n << "\n";
}

Measured memory_bytes: 9600
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;


int n;
char s[3];
double a[12];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	scanf("%d", &n);
	char h;
	double ans = 0.0;
	for(int i = 0; i < n; i++) {
		scanf("%lf%c%s", &a[i], &h, s);
		if(s[0] == 'J') ans += a[i];
		else ans += 380000.0  * a[i];
	}
	printf("%lf", ans);
	return 0;
}
/**/

Measured memory_bytes: 256
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

use std::collections::VecDeque;
use std::cmp;

fn main() {
    let mut s: VecDeque<char> = get_line().chars().collect();

    let xy: Vec<i64> = reads();

    let mut xp = 0;
    while let Some(c) = s.pop_front() {
        if c != 'F' {
            break;
        }

        xp += 1;
    }

    let mut xs = vec![];
    let mut ys = vec![];

    let mut f = true;
    let mut acc = 0;
    while let Some(c) = s.pop_front() {
        if c == 'F' {
            acc += 1;
        }
        else {
            if f && acc != 0 {
                ys.push(acc);
            }
            else if acc != 0 {
                xs.push(acc);
            }

            acc = 0;
            f = !f;
        }
    }
    if f && acc != 0 {
        ys.push(acc);
    }
    else if acc != 0 {
        xs.push(acc);
    }

    let base = 9000;
    let l = cmp::max(xs.len(), ys.len());
    let mut ts = vec![vec![false; 2 * base]; l];

    let resx = 
    if xs.len() > 0 {
        ts[0][base + xp + xs[0]] = true;
        ts[0][base + xp - xs[0]] = true;

        for (i, &x) in xs.iter().enumerate() {
            if i == 0 {
                continue;
            }

            for j in 0..(2 * base) {
                if ts[i - 1][j] {
                    if 2 * base > x + j {
                        ts[i][x + j] = true;
                    }
                    if j >= x {
                        ts[i][j - x] = true;
                    }
                }
            }
        }

        ts[xs.len() - 1][(base as i64 + xy[0]) as usize]
    }
    else {
        xp as i64 == xy[0]
    };
    

    ts = vec![vec![false; 2 * base]; l];

    let resy = 
    if ys.len() > 0 {
        ts[0][base + ys[0]] = true;
        ts[0][base - ys[0]] = true;

        for (i, &y) in ys.iter().enumerate() {
            if i == 0 {
                continue;
            }

            for j in 0..(2 * base) {
                if ts[i - 1][j] {
                    if 2 * base > y + j {
                        ts[i][y + j] = true;
                    }
                    if j >= y {
                        ts[i][j - y] = true;
                    }
                }
            }
        }

        ts[ys.len() - 1][(base as i64 + xy[1]) as usize]
    }
    else {
        xy[1] == 0
    };

    println!("{}",
    if resx && resy {
        "Yes"
    }
    else {
        "No"
    });
}

Measured memory_bytes: 135420
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int r, d, x;
  cin >> r >> d >> x;
  for (int i=0; i<10; ++i) {
    x = r*x-d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	string S,an;
	cin >> S;
	rep(i, S.size()) {
		if (S.at(i) == 'B'&&an.empty()) {
			
		}
		else if (S.at(i) == 'B') {
			an.erase(an.size() - 1);
		}
		else {
			an += S.at(i);
		}
	}
	
		cout<< an<<endl;
	


	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc085/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());

    ll cnt = 0;
    int amax = a[0];
    int itr = 0;
    while(h > 0){
        if(itr < n && b[itr] > amax){
            h -= b[itr];
            itr++; cnt++;
        }else{
            cnt += h/amax;
            if(h % amax != 0) cnt++;
            break;
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
d,x=[ int(it) for it in input().split() ]
al=[]
for i in range(n):
  al.append(int(input()))
s = 0
s += x
for i in range(d):
  nichi = i+1
  for a in al:
    if (nichi-1)%a==0:
      s+=1
print (s)
#print (n,d,x,al)
  

Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def bs(f, mi, ma):
    mm = -1
    while ma > mi:
        mm = (ma+mi) // 2
        if f(mm):
            mi = mm + 1
        else:
            ma = mm
    if f(mm):
        return mm + 1
    return mm

def main():
    n,m,v,p = LI()
    a = sorted(LI())
    pi = n-p
    pv = a[pi]

    def f(i):
        t = a[i] + m
        if pv > t:
            return True
        mv = m*v-m
        for j in range(n):
            if j == i:
                continue
            aj = a[j]
            if j > pi:
                mv -= m
            elif aj <= t:
                mv -= min(m, t - aj)
            else:
                mv -= m
        return mv > 0

    r = bs(f,0,n-1)

    return n - r


print(main())





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

int n;
int num[100001][4];

int main(){
    cin>>n;
    for(int qq=1;qq<=n;qq++){
        cin>>num[qq][1]>>num[qq][2]>>num[qq][3];
    }
    for(int qq=2;qq<=n;qq++){
        num[qq][1]=num[qq][1]+max(num[qq-1][2],num[qq-1][3]);
        num[qq][2]=num[qq][2]+max(num[qq-1][1],num[qq-1][3]);
        num[qq][3]=num[qq][3]+max(num[qq-1][2],num[qq-1][1]);
    }
    cout<<max(num[n][1],max(num[n][2],num[n][3]));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define double long double
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b,int M){a%=M;int r=1;while(b>0){if(b&1)r=r*a%M;a=a*a%M;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5  ;

signed main(){
	int n , k;
	cin >> n >> k; 

	n = n%k ;
	int mn = min( n , k-n) ;
	cout << mn; 
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n,q; cin>>n>>q;
    string s; cin>>s;

    vector<ll> sum(n+1,0);
    for(int i=1;i<n;i++){
        sum[i+1]=sum[i];
        if(s[i-1]=='A'&&s[i]=='C') sum[i+1]++;
    }
    rep(i,q){
        int l,r; cin>>l>>r;
        cout<<sum[r]-sum[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4312
import collections
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
l = IL()
setl = set(l)

if len(setl) <= K:
	print(0)
else:
	cl = collections.Counter(l)
	ans = 0
	for i in cl.most_common()[K:]:
		ans += i[1]
	print(ans)

Measured memory_bytes: 59200
#include <stdio.h>
#define MAX 25
#define NULL -1
typedef struct
{
	int p,l,r;
}Node;

Node T[MAX];
int n;

int getdepth(int i,int depth)
{
	if(T[i].p==NULL)//?????¶??? 
	{} 
	else
	{
		depth++;
		depth=getdepth(T[i].p,depth);
	}
	return depth;	
}

int getheight(int i)
{
	int h1=0,h2=0;
	if(T[i].l!=NULL)
	{
		h1++;
		h1=h1+getheight(T[i].l);
	}
	if(T[i].r!=NULL)
	{
		h2++;
		h2=h2+getheight(T[i].r);
	}
	return h1>h2?h1:h2;	
}

int getdegree(int i)
{
	if(T[i].l==NULL&&T[i].r==NULL)	
	return 0;
	else if(T[i].l!=NULL&&T[i].r!=NULL)
	return 2;
	else
	return 1;
}

int getsibling(int i)
{
	int p=T[i].p;
	if(p==NULL||T[p].l==NULL||T[p].r==NULL)
	return -1;
	if(T[p].l==i)
	return T[p].r;
	else
	return T[p].l;
}

void print(int i)
{
	printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,T[i].p,getsibling(i),getdegree(i));
	printf("depth = %d, height = %d, ",getdepth(i,0),getheight(i));
	if(T[i].p==-1)
	printf("root\n");
	else if(T[i].l==-1&&T[i].r==-1)	
	printf("leaf\n");
	else
	printf("internal node\n");
}
int main(int argc, char *argv[])
{
	int i,node,left,right;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	T[i].p=NULL;
	for(i=0;i<n;i++)
	{
	scanf("%d%d%d",&node,&left,&right);
	T[node].l=left;
	T[node].r=right;
	if(left!=NULL)
	T[left].p=node;
	if(right!=NULL)
	T[right].p=node;
	}	
	for(i=0;i<n;i++)
	print(i);
	return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int ans=1000000;
    for(int i=-100;i<=100;i++){
        int sum=0;
        for(int j=0;j<N;j++){
            sum+=(a[j]+i)*(a[j]+i);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
 
int n,m;
int a[50], b[50];
bool graph[50][50];
bool visited[50];

void dfs(int v){
  if(visited[v]) return;
  visited[v]=true;
  rep(i,n){
    if(graph[v][i]) dfs(i);
  }
}


signed main()
{
  cin>>n>>m;
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }

  int ans=0;
  rep(i,m){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    rep(j,n) visited[j]=false;
    dfs(0);
    bool flg=false;
    rep(j,n) if(!visited[j]) flg=true;
    if(flg) ans++;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;

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

        int g[][] = new int[201][201];
        for(int i=1; i<=200; i++){
            for(int j = i; j<=200; j++){
                int gcdij = gcd(i, j);
                g[i][j] = gcdij;
                g[j][i] = gcdij;
            }
        }
        long sum = 0;
        for(int i=1; i<=N; i++){
            for(int j=1; j<=N; j++){
                int gcdij = g[i][j];
                for(int  k= 1; k<=N; k++){
                    sum += g[gcdij][k];
                }
            }
        }
        System.out.println(sum);

    }

    public static int gcd(int i, int j){
        while(i != 0){
            int res = j % i;
            j = i;
            i = res;
        }
        return j;
    }
}

Measured memory_bytes: 35960
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
#define pb push_back
#define X first
#define Y second
typedef pair <double,double>P;

double dis(P a,P b){
	//2点間距離
	return sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y));
}



int main(){
	
	int n;
	while(cin>>n,n){
		vector<P>V;
		for(int i=0;i<n;i++){
			double x,y;
			scanf("%lf,%lf",&x,&y);
			V.pb(P(x,y));
		}
		int ans=1;
		
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(dis(V[i],V[j])<=2.0){
					double rad=acos(dis(V[i],V[j])/2.0);
					double cta=0;
					if(dis(V[i],V[j])>0){
						cta=acos(fabs(V[i].X-V[j].X)/dis(V[i],V[j]));
					}
					
					double x=V[i].X+cos(rad+cta),y=V[i].Y+sin(rad+cta);
					int tmp=0;
					for(int i=0;i<n;i++){
						if(dis(V[i],P(x,y))<=1)tmp++;
					}
					ans=max(ans,tmp);
					
					x=V[i].X+cos(rad-cta);
					y=V[i].Y+sin(rad-cta);
					tmp=0;
					for(int i=0;i<n;i++){
						if(dis(V[i],P(x,y))<=1)tmp++;
					}
					ans=max(ans,tmp);
					
					
				}
			}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


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

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

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

  ll ans1=0;
  ll ans2=0;
  for(int i=1; i<=sqrt(n); i++){
    for(int j=i; j<=n; j++){
      if(i*j>=n) break;
      if(i==j) ans1++;
      else ans2++;
    }
  }

  ll ans = ans1 + ans2*2;
  cout << ans;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>

using namespace std;

vector<int> inv (vector<int> v) {
  int n = (int) v.size();
  vector<int> ans (n);
  for (int i = 0; i < n; i++) {
    ans[v[i]] = i;
  }
  return ans;
}

vector<int> operator* (vector<int> p, vector<int> q) {
  int n = (int) p.size();
  vector<int> ans (n);
  for (int i = 0; i < n; i++) {
    ans[i] = p[q[i]];
  }
  return ans;
}

ostream& operator<< (ostream &out, vector<int> p) {
  for (int i = 0; i < (int) p.size(); i++) {
    cout << p[i] + 1 << " ";
  }
  return out;
}

vector<int> id (int n) {
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    ans.push_back(i);
  }
  return ans;
}

vector<int> exp (vector<int> p, int k) {
  if (k == 0) return id(p.size());
  if (k % 2 == 0) {
    auto half = exp(p, k / 2);
    return half * half;
  }
  return p * exp(p, k - 1);
}

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

  vector<int> p (n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }

  vector<int> q (n);
  for (int i = 0; i < n; i++) {
    cin >> q[i];
    q[i]--;
  }

  vector<int> ip = inv(p);
  vector<int> iq = inv(q);
  
  k--;
  if (k < 6) {
    if (k == 0) cout << p << endl;
    if (k == 1) cout << q << endl;
    if (k == 2) cout << q * ip << endl;
    if (k == 3) cout << q * ip * iq << endl;
    if (k == 4) cout << q * ip * iq * p * iq << endl;
    if (k == 5) cout << q * ip * iq * p * p * iq << endl;
    return 0;
  }

  int pc = k / 6;
  vector<int> pref = q * ip * iq;
  pref = pref * exp(p * q * ip * iq, pc - 1);
  k %= 6;

  if (k >= 1) pref = pref * p;
  if (k >= 3) pref = pref * q;
  if (k >= 4) pref = pref * ip;
  
  vector<int> ipref = inv(pref);
  if (k == 0) cout << pref * p * ipref << endl;
  if (k == 1) cout << pref * q * ipref << endl;
  if (k == 2) cout << pref * q * ip * ipref << endl;
  if (k == 3) cout << pref * ip * ipref << endl;
  if (k == 4) cout << pref * iq * ipref << endl;
  if (k == 5) cout << pref * iq * p * ipref << endl;
}


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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

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

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> x(N);
    vector<long long> y(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }
    vector<long long> count(N);
    for (long long i = 0; i < N; i++)
    {
        count[i] = x[i] + y[i];
    }
    vector<long long> count2(N);
    for (long long i = 0; i < N; i++)
    {
        count2[i] = x[i] - y[i];
    }
    sort(count.begin(), count.end());
    long long ans = count[N-1] - count[0];
    sort(count2.begin(), count2.end());
    long long preans = count2[N-1] - count2[0];
    if (preans > ans)
    {
        ans = preans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9536
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt()){
int a, b = 0;
a = sc.nextInt();
b = sc.nextInt();
System.out.println(String.format("%d", a+b).length());
}
}
}

Measured memory_bytes: 12000
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
for i in range(1,n):
  ans += A[i//2]
print(ans)

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

using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
const int inf_int=1e8;
const ll inf_ll=1e16;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double dbl;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;

const int MAXN = 3e5+10;
const int LOG = 20;
const int mod =998244353;


ll bin_pow(ll a,int n){
    ll res = 1;
    while(n){
        if(n&1){
            res = (res * a)%mod;
        }
        a = (a*a)%mod;
        n>>=1;
    }
    return res;
}
ll rev(ll x){
    return bin_pow(x,mod-2);
}

ll fac[MAXN];
ll rev_fac[MAXN];

ll A,B;
void precalc(){
    fac[0] = 1;
    rev_fac[0] = 1;
    for(int i=1;i<MAXN;++i){
        fac[i]  =(fac[i-1] * i)%mod;
        rev_fac[i] = rev(fac[i]);
    }

}

ll C(int n,int k){
    return ( (fac[n] * rev_fac[k])%mod * rev_fac[n-k] )%mod;
}

void solve(){
    int n;
    cin >> n;

    cin >> A >> B;
    ll k;
    cin >> k;
    if(k==0){
        cout <<1;
        return;
    }
    precalc();

    ll ans = 0;

    for(int m=0;m<=n;++m){
        //m total green and red
        dout << m<< " : "<<endl;
        if(m * A > k)
            continue;
        ll x = (k - m * A);
        if(x%B!=0)
            continue;
        dout <<"x "<< x<<endl;
        x = x / B;
        if(x<0 || x>n){
            continue;
        }

        ll cur = (C(n,m)  * C(n,x))%mod;
        ans+=cur;
        if(ans>=mod)
            ans-=mod;
    }
    cout << ans<<"\n";

}

signed main()
{
        #ifdef taow
           freopen("input.txt","r",stdin);
         //   freopen("output.txt","w",stdout);
        #else
        #endif // taow
        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
        cout.setf(ios::fixed);
        cout.precision(20);



        int t = 1;
        while(t--)
            solve();
}


Measured memory_bytes: 4992
import Control.Applicative
import Data.Char (toLower)

main :: IO ()
main = solve <$> f <*> getLine >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String -> String
solve [n, k] s = as ++ (toLower b) : bs
  where
    (as, b:bs) = splitAt (k-1) s


Measured memory_bytes: 508
#include<stdio.h>
int prt[100010];
bool vit[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&prt[i]);
	}
	int u=1,cnt=0;
	while(1){
		if(u==2){
			printf("%d\n",cnt);
			return 0;
		}
		if(vit[u]){
			printf("-1\n");
			return 0;
		}
		vit[u]=true;
		cnt++;
		u=prt[u];
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



int main() {
	ll n;
	cin >> n;
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
		s[i] -= i + 1;
	}
	sort(ALL(s));
	ll ans = 0;
	REP(i, n) {
		ans += abs(s[i] - s[n / 2]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let x: i64 = read();
    let y: i64 = read();

    // let xv: Vec<bool> = vec![false; 16000];
    // let yv: Vec<bool> = vec![false; 16000];

    let mut cnt = 0;
    let mut xflag = true;
    let mut xset: Vec<usize> = vec![];
    let mut yset: Vec<usize> = vec![];
    let mut head = 0;

    while head < s.len() + 1 {
        if head == s.len() || s[head] == 'T' {
            if xflag {
                xset.push(cnt);
            } else {
                yset.push(cnt);
            }
            cnt = 0;
            xflag = !xflag;
        } else {
            cnt += 1;
        }
        head += 1;
    }

    // first
    let xf = xset.remove(0);
    let mut xv = vec![vec![false; 16005]; xset.len() + 1];
    let mut yv = vec![vec![false; 16005]; yset.len() + 1];
    let sp: usize = 8002;
    xv[0][sp + xf] = true;
    yv[0][sp] = true;

    for i in 0..xset.len() {
        let xsi = xset[i];
        for j in 0..xv[i].len() {
            let xvi = xv[i][j];
            if xvi {
                xv[i + 1][j + xsi] = true;
                xv[i + 1][j - xsi] = true;
            }
        }
    }
    for i in 0..yset.len() {
        let ysi = yset[i];
        for j in 0..yv[i].len() {
            let yvi = yv[i][j];
            if yvi {
                yv[i + 1][j + ysi] = true;
                yv[i + 1][j - ysi] = true;
            }
        }
    }

    if xv[xset.len()][(sp + x as usize) as usize] && yv[yset.len()][(sp + y as usize) as usize] {
        println!("Yes");
    } else {
        println!("No")
    }
    // println!("{}", xv[xset.len()].iter().filter(|&x| *x == true).count());
    // println!("{}", yv[yset.len()].iter().filter(|&x| *x == true).count());

    // println!("{:?}", prt.len());
    // println!("{:?}", yv[0].split_off(4));
}


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

public class Main {
	public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> al = new ArrayList<Integer>();
		String str;
		while ((str = br.readLine()) != null) {
			if (str.length() == 0) {
				break;
			}
			al.add(Integer.parseInt(str));
		}
		int[] result = new int[al.size()];
		for (int i = 0; i < al.size(); i++) {
			if (al.get(i) <= 36) {
				result[i] = check(al.get(i));
			} else {
				result[i] = 0;
			}
		}
		
		for(int i=0;i<result.length;i++){
			System.out.println(result[i]);
		}
		
	}

	private static int check(int no) {
		int cnt = 0;
		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				for (int k = 0; k <= 9; k++) {
					for (int l = 0; l <= 9; l++) {
						if ((i + j + k + l) == no) {
							cnt++;
						}
					}
				}
			}
		}
		return cnt;
	}
	
}

Measured memory_bytes: 24172
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
  
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
  
typedef pair< int , int > Pi;
typedef pair< bool, Pi > Pii;
  
typedef long long int64;
 
int uf[40000], buffer[40000], loger[400000];
int siz;
int Find(int a){
  return(uf[a] < 0 ? a : Find(uf[a]));
}
void Union(int a,int b, bool flag = false){
  if((a = Find(a)) != (b = Find(b))){
    if(flag) loger[siz++] = a,loger[siz++] = b;
    if(uf[a] > uf[b]) swap( a, b);
    uf[a] += uf[b], uf[b] = a;
  }
}

const int SQR = 200;
set< Pi > T; // 変化があった辺
set< Pi > S; // 存在する辺
 
int main(){
  int n, Q;
  int x[40000], y[40000], z[40000];
 
  scanf("%d %d", &n, &Q);
  for(int i = 0; i < Q; i++){
    scanf("%d %d %d", &x[i], &y[i], &z[i]);
  }
  for(int i = 0; i * SQR < Q; i++){
    T.clear();
    for(int j = 0; j < n; ++j) uf[j] = buffer[j] = -1;
    int begin = i * SQR, end = min( (i + 1) * SQR, Q);
    for(int j = begin; j < end; j++){
      if(x[j] != 3){
        T.insert( make_pair( y[j], z[j]));
        if(x[j] == 1) S.insert( make_pair( y[j], z[j]));
        else if(x[j] == 2) S.erase( make_pair( y[j], z[j]));
      }
    }
    ForEach( it, S){
      if(T.find(*it) == T.end()){ // 以前に追加されていて変化がない辺を結合
        Union( it -> first, it -> second);
      }
    }
    for(int j = 0; j < n; ++j) buffer[j] = uf[j];

    for(int j = begin; j < end; ++j){
      if(x[j] == 3){
        set< Pi > u;
        for(int k = begin; k - begin < j % SQR; k++){ // それ以前
          if(x[k] == 1) u.insert( make_pair( y[k], z[k]));
          else if(x[k] == 2) u.erase( make_pair( y[k], z[k]));
        }
        for(int k = end - 1; k - begin > j % SQR; k--){ // それ以後
          if(x[k] == 1) u.erase( make_pair( y[k], z[k]));
          else if(x[k] == 2) u.insert( make_pair( y[k], z[k]));    
        }
        siz = 0;
        ForEach( it, u) Union( it -> first, it -> second, true);
        puts(Find(y[j]) == Find(z[j]) ? "YES" : "NO");
        for(int k = 0; k < siz; k++) uf[loger[k]] = buffer[loger[k]];
      }
    }
  }
}

Measured memory_bytes: 3496
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

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

int main(){

        int n,res = 0;
        string str;

        cin >> str;
        cin >> n;

        rep(i,n){
                string s;
                cin >> s;
                s += s;
                if(s.find(str) != string::npos) res++;
        }

        cout << res << endl;
        return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
const ll MAX = 400005;
ll par[MAX];
ll ran[MAX];
void init(ll n){
    rep(i,n){
        par[i] = i;
        ran[i] = 0;
    }
}
ll find(ll x){
    if(x == par[x])return x;
    else return par[x] = find(par[x]);
}
void unite(ll x,ll y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(ran[x] < ran[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(ran[x] == ran[y])ran[x]++;
    }
}
bool same(ll x,ll y){
    return find(x) == find(y);
}
int main(){
    ll N,M;
    cin >> N>>M;
    vector<ll> a(M);
    vector<ll> b(M);
    rep(i,M){
        cin >> a[i] >> b[i];a[i]--;b[i]--;
    }
    ll ans = 0;
    rep(i,M){
        init(N);
        rep(j,M){
            if(i != j){
                unite(a[j],b[j]);
            }
        }
        if(!(same(a[i],b[i])))ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612