akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
ll nxt[200005]={0},rnxt[200005]={0};
ll dpl[200005]={0},dpr[200005]={0};
const ll inf=1744174417441744;
int main(){
  ll n,k,c;
  cin>>n>>k>>c;
  c++;
  string s;
  cin>>s;
  vector<ll> vec;
  vec.push_back(-inf);
  for(int i=0;i<n;i++){
    if(s[i]=='o') vec.push_back(i+1);
  }
  ll vs=vec.size()-1;
  vec.push_back(inf);
  for(int i=1;i<=vs;i++){
    ll pos=lower_bound(vec.begin(),vec.end(),vec[i]+c)-vec.begin();
    nxt[i]=pos;
    ll p2=upper_bound(vec.begin(),vec.end(),vec[i]-c)-vec.begin();
    p2--;
    rnxt[i]=p2;
  }
  for(int i=1;i<=vs;i++) dpl[i]=1;
  for(int i=1;i<=vs;i++){
    dpl[nxt[i]]=max(dpl[nxt[i]],dpl[i]+1);
    dpl[i+1]=max(dpl[i+1],dpl[i]);
  }
  for(int i=1;i<=vs;i++) dpr[i]=1;
  for(int i=vs;i>0;i--){
    dpr[rnxt[i]]=max(dpr[rnxt[i]],dpr[i]+1);
    dpr[i-1]=max(dpr[i-1],dpr[i]);
  }
  dpl[vs+1]=0;
  dpr[0]=0;
  for(int i=1;i<=vs;i++){
    if(dpl[i-1]+dpr[i+1]<k){
      cout<<vec[i]<<endl;
    }
  }
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> X(M);
  for (int i = 0; i < M; i++) cin >> X[i];
  sort(X.begin(), X.end());

  vector<int64_t> D(M - 1);
  for (int i = 0; i + 1 < M; i++) {
    D[i] = X[i + 1] - X[i];
  }
  sort(D.rbegin(), D.rend());
  int64_t answer = X[M - 1] - X[0];

  for (int i = 0; i < min(M - 1, N - 1); i++) {
    answer -= D[i];
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define dbg(x)                cout <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	ll n; scn(n);
	vec num;
	ara_read(num, n);
	vec suffix(n+1,0),prefix(n+1,0);
	loop(i,1,n){
		suffix[i]=__gcd(suffix[i-1],num[i-1]);
	}
	for(ll i=n-1; i>=0; i--){
		prefix[i]=__gcd(prefix[i+1],num[i]);
	}
	ll ans=0;
	for(int i=0; i< n; i++){
		ans=max(ans,__gcd(suffix[i],prefix[i+1]));
	}
	printf("%lld\n",ans);
    return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, k;
    cin >> n >> k;
    set<int> st;
    rep(i, k){
        int d;
        cin >> d;
        st.insert(d);
    }
    int ans = n;
    while(1){
        int tmp = ans;
        bool flag = true;
        while(tmp > 0){
            if(st.count(tmp % 10)){
                flag = false;
                break;
            }
            tmp /= 10;
        }
        if(flag){
            cout << ans << endl;
            break;
        }
        ++ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll n;
  scanf("%lld", &n);
  if(n >= 65 && n <= 90) printf("1\n");
  else if(n >= 97 && n <= 122) printf("2\n");
  else printf("0\n");
  return 0;
}


Measured memory_bytes: 2608
N = int(input())

h = list(map(int, input().split()))

ans = 0

while True:
    if not any(h):
        break
    flag = False
    for i, e in enumerate(h):
        if e != 0:
            flag = True
            h[i] -= 1
            if i == len(h) - 1:
                ans += 1
        else:
            if flag == True:
                ans += 1
                flag = False
    
print(ans)

Measured memory_bytes: 3060
import sys
H, W = map(int, input().split())
grid = [list('.' + input() + '.') for _ in range(H)]
grid = [['.' for _ in range(W + 2)]] + grid + [['.' for _ in range(W + 2)]]

for i, row in enumerate(grid[1: -1]):
    for j, s in enumerate(row[1: -1]):
        if s == '.':
            continue
        if grid[i + 1][j] == '#' or  grid[i +1][j + 2] == '#' or grid[i][j + 1] == '#' or  grid[i +2][j + 1] == '#':
            continue
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        double W = cin.nextDouble();
        double H = cin.nextDouble();
        double x = cin.nextDouble();
        double y = cin.nextDouble();

        if (W == 2 * x && H == 2 * y)
        {
            Console.WriteLine("{0:F10} {1}", W * H / 2, 1);
            return;
        }
        Console.WriteLine("{0:F10} {1}", W * H / 2, 0);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> H;

int main () {
  cin >> N;
  H.resize(N);
  rep(i,N) cin >> H[i];

  bool ok = true;
  int m = H[0];
  rep(i,N) {
    m = max(m, H[i]);
    if(m - H[i] > 1) {
      ok = false;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include "string.h"
using namespace std;
int m[107][107];
int main(int argc, char *argv[]) {
	int n,u,k,v;
	cin>>n;
	memset(m, 0, sizeof(m));
	for(int i=1;i<=n;i++)
	{
		cin>>u>>k;
		for(int j=1;j<=k;j++)
		{
			cin>>v;
			m[u][v]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			
			cout<<m[i][j];
			if(j!=n)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

 
int main() {
	string s1;
	deque<char> s;
	long long q, c = 0;
	cin >> s1 >> q;
	for(int i = 0; i < s1.size(); ++i) s.push_back(s1[i]);
	for(int i = 0; i < q; ++i){
		char a;
		int k, f;
		cin >> k;
		if(k == 1) c++;
		else{
			cin >> f >> a;
			if(f == 1 && !(c % 2) || f == 2 && c % 2) s.push_front(a);
			else s.push_back(a);
		}
	}
	if(c % 2) reverse(s.begin(), s.end());
	for(char i:s) cout << i; 
}


Measured memory_bytes: 896
mod=10**9+7
n,k=map(int,input().split())
l=[0]*(k+1)
for i in range(k):
    num=(k-i)
    if k//num==1:
        l[num]=1
    else:
        ret=pow(k//num,n,mod)
        for j in range(2,k//num+1):
            ret-=l[num*j]
            ret%=mod
        l[num]=(ret)%mod
ans=0
for i in range(k+1):
    ans+=(l[i]*i)%mod
print(ans%mod)


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

int pr(int x, int y) {
    int res = 1;
    x = x % mod;
    while (y > 0){
        if (y & 1)
            res = (res*x) % mod;
        y >>= 1;
        x = (x*x) % mod;  
    }
    return res;
}

int fact[500002];
 
int ncr(int n, int r){
    int ret = (fact[n] * pr(fact[r], mod - 2)) % mod;
    return (ret * pr(fact[n-r], mod - 2)) % mod;
}

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

    fact[0] = 1;
    for(int i = 1; i <= 5e5 + 2; i++)
        fact[i] = (fact[i - 1] * i) % mod;

    int n, m;
    cin >> n >> m;
    if(m < n){
        cout << "0\n";
        return 0;
    }

    int ans = 1;
    for(int i = 0; i < n; i++){
        ans = (ans * (m - i)) % mod;
    }
    ans = (ans * ans) % mod;
    int tem = ans;
    
    for(int i = 1; i <= n; i++){
        tem = (tem * pr(m - i + 1, mod - 2)) % mod;
        if(i&1)
            ans -= (tem * ncr(n, i)) % mod;
        else
            ans += (tem * ncr(n, i)) % mod;
        ans %= mod;
    }
    cout << (ans + mod) % mod << '\n';
}

Measured memory_bytes: 7540
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 10100
using namespace std;
int mi[100];
int n,m;
struct keep
{
	int k,p;
	int u[11];
}g[101];
int ans;
int main()
{
	mi[0]=1;for(int i=1;i<=11;i++)mi[i]=2*mi[i-1];
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&g[i].k);
		for(int j=1;j<=g[i].k;j++)scanf("%d",&g[i].u[j]),g[i].u[j]--;
	}
	for(int i=1;i<=m;i++)cin>>g[i].p;
	for(int p=0;p<=mi[n]-1;p++)
	{
		int y=0;
		for(int i=1;i<=m;i++)
		{
			int cnt=0;
			for(int j=1;j<=g[i].k;j++)
				if(mi[g[i].u[j]]&p)cnt++;
			if(cnt%2==g[i].p)y++;
		}
		if(y==m)ans++;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
n, m = map(int,input().split())

s, c = list(), list()
for i in range(m):
    si, ci = input().split()
    s.append(int(si))
    c.append(ci)

ans = -1
for i in range(1000):
    num = str(i)
    if len(str(num)) != n:
        continue

    cond = True
    for si, ci in zip(s, c):
        if num[si-1] != ci:
            cond = False
            break
    if not cond:
        continue
    
    ans = i
    break

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x; i <= y; ++ i)
#define repd(i,x,y) for(register int i = x; i >= y; -- i)
typedef long long ll;
using namespace std;
template<typename T>inline bool chkmax(T&x,T y) { return x < y ? x = y,1 : 0; }
template<typename T>inline bool chkmin(T&x,T y) { return x > y ? x = y,1 : 0; }
template<typename T>inline void read(T&x)
{
	char c;int sign = 1;x = 0;
	do { c = getchar(); if(c == '-') sign = -1; }while(!isdigit(c));
	do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
	x *= sign;
}

const int N = 2e5 + 50;
ll l,a[N];int n;
ll ans,s1[N],s2[N];

int main()
{
	read(l); read(n);
	rep(i,1,n) read(a[i]);
	sort(a + 1,a + 1 + n);
	if(n == 1)
	{
		cout << max(a[1],l - a[1]);
		return 0;
	}
	rep(i,1,n) s1[i] = s1[i-1] + a[i];
	rep(i,1,n) s2[i] = s2[i-1] + l-a[i];
	ans = l - a[2] + max(l - (a[2]-a[1]),a[2]-a[1]);
	chkmax(ans,a[n-1] + max(l - (a[n]-a[n-1]),a[n]-a[n-1]));
	rep(i,2,n-1)
	{
		int t = min(i - 1,n - i);

		if(i - 1 < n - i)
			chkmax(ans,2 * ((s1[i] - s1[i-1-t]) + (s2[i+t+1] - s2[i])) + max(a[i+1]-a[i]-(l-a[i+1]+a[i]),-min(l - a[i+1],a[i])));
		else if(i - 1 > n - i)
			chkmax(ans,2 * ((s1[i-1] - s1[i-2-t]) + (s2[i+t] - s2[i-1])) + max(a[i]-a[i-1]-(l-a[i]+a[i-1]),-min(l-a[i],a[i-1])));
		chkmax(ans,2 * ((s1[i-1] - s1[i-t-1]) + (s2[i+t] - s2[i])) + max(a[i],l - a[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
s = list(input())
k = int(input())

z = ord("z")
a = ord("a")
for i in range(len(s)-1):
    if s[i] == "a":
        continue
    if z - ord(s[i]) + 1 <= k:
        k -= z - ord(s[i]) + 1
        s[i] = "a"

if k > 0:
    k = k%26
    x = z - ord(s[-1]) +1
    if k >= x:
        k -= z - ord(s[-1]) + 1
        s[-1] = chr(a + k)
    else:
        s[-1] = chr(ord(s[-1])+k)
    
print("".join(s))

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

const double EPS = 1e-8;

struct Point{
    double x, y, c;
};

vector<pair<double, double>> intersection(double x1, double y1, double r1, double x2, double y2, double r2){
    /*
    if (r1 < r2){
        swap(x1, x2);
        swap(y1, y2);
        swap(r1, r2);
    }
    */

    double ab = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

    if (-EPS < r1 - r2 - ab || ab - (r1 + r2) > -EPS)
        return {};
    
    double ad = (r1 * r1 - r2 * r2 + ab * ab) / (2 * ab);
    double x0 = x1 + (x2 - x1) * ad / ab;
    double y0 = y1 + (y2 - y1) * ad / ab;
    double n_x = -(y2 - y1), n_y = x2 - x1;
    double norm = sqrt((n_x * n_x) + (n_y * n_y));
    double cd = sqrt((r1 * r1) - (ad * ad));

    return {{x0 + n_x * cd / norm, y0 + n_y * cd / norm}, {x0 - n_x * cd / norm, y0 - n_y * cd / norm}};
}

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

    int n, k;
    cin >> n >> k;

    vector<Point> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].x >> a[i].y >> a[i].c;

    auto C = [&](double mid){
        vector<double> r(n);
        for (int i = 0; i < n; i++)
            r[i] = mid / a[i].c;

        vector<pair<double, double>> center;
        for (int i = 0; i < n; i++){
            center.push_back({a[i].x, a[i].y});
            for (int j = i + 1; j < n; j++){
                auto v = intersection(a[i].x, a[i].y, r[i], a[j].x, a[j].y, r[j]);

                for (auto k: v)
                    center.push_back(k);
            }
        }
        
        for (auto c: center){
            int cnt = 0;
            for (auto i: a){
                if (mid - i.c * sqrt((c.first - i.x) * (c.first - i.x) + (c.second - i.y) * (c.second - i.y))  > -EPS)
                    cnt += 1;
            }

            if (cnt >= k)
                return true;
        }

        return false;

    };

    double lb = 0.0, ub = 1e9;
    for (int i = 0; i < 100; i++){
        double mid = (lb + ub) / 2;
        if (C(mid))
            ub = mid;
        else
            lb = mid;
    }

    cout << ub << '\n';
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string t;
    cin >> t;
    rep(i, 0, 7){
        if(s[i] == t){
            cout << 7 - i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    cout<<(1.0-1.0*(N/2)/N)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int c;
  cin >>c;
  while(c--){
    vector<int> edge(3);
    for(int i=0; i<3; i++) cin >>edge[i];
    for(int i=0; i<3; i++) edge[i] = edge[i]*edge[i];
    sort(edge.begin(),edge.end());
    if(edge[2] == edge[1]+edge[0]) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
use std::io::Read;
use std::collections::HashSet;

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

    let answer = solve(&buf);

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

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

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut set: HashSet<String> = HashSet::new();
    for _ in 0..n {
        set.insert(iterator.next().unwrap().to_string());
    }
    return format!("{}", set.len());
}


Measured memory_bytes: 17452
#include <iostream>
#include <complex>

using namespace std;

const int MAXN = 310;
const int MOD = 998244353;

typedef complex<int> Point;

long long cross(Point a, Point b)
{
	return a.real() * b.imag() - a.imag() * b.real();
}

int add(long long a, long long b)
{
	return (a + b + MOD) % MOD;
}

int mul(long long a, long long b)
{
	return (a * b) % MOD;
}

Point a[MAXN];
int pw[MAXN];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		a[i] = Point(x, y);
	}
	pw[0] = 1;
	for (int i = 0; i < n; i++)
		pw[i + 1] = mul(pw[i], 2);
	int res = 0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			int cnt = 0;
			for (int k = j + 1; k < n; k++)
				if (cross(a[k] - a[i], a[j] - a[i]) != 0)
				{
					cnt++;
					res = add(res, pw[n - j - 1 - cnt]);
				}
		}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
    string s;
    cin >> s;

    ll len = s.size();
    vector<ll> con;
    REP(i, len - 1){
        if (s[i] == 'R' && s[i + 1] == 'L') con.push_back(i + 1);
    }
    con.push_back(len);
    vector<ll> ans(len, 0);
    ll j = 0;
    REP(i, len){
        if (s[i] == 'R'){
            if (i > con[j]) j++;
            ll tmp = con[j] - i;
            if (tmp % 2 == 0) ans[con[j]]++;
            else ans[con[j] - 1]++;
        }else{
            if (i >= con[j]) j++;
            ll tmp = i - con[j - 1];
            if (tmp % 2 == 0) ans[con[j - 1]]++;
            else ans[con[j - 1] - 1]++;
        }
        
    }
    REP(i, len) cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1912
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;

char s[MAXN];

int main(void)
{
	int n;
	scanf("%d%s",&n,s+1);
	
	int l=1, r=n, ans=0;
	while(l<r)
	{
		while(l<r && s[l]=='R') ++l;
		while(l<r && s[r]=='W') --r;
		if(l>=r) break;
		swap(s[l], s[r]);
		++ans;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4004
/* ex6_2 melo */
#include <stdio.h>
#include<string.h> //文字列関数
#define SIZE 101 //文字列の大きさを定義
int main(void){
    char sente[SIZE];//文字列を用意
    int length;//整数の箱を用意
    fgets(sente,SIZE,stdin);//入力を文字列に代入（改行を含む）
    length=strlen(sente);//改行を含む文字列の長さを代入
    if (sente[length-1]=='\n') {//改行を削除
        sente[length-1]='\0';//NULLに変換
    }
    printf("%c%d%c\n",sente[0],(int)strlen(sente)-2,sente[(int)strlen(sente)-1]);//１文字目,文字列の長さ-2,最後の文字を出力
    return 0;//正常終了
}

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

int main(){
 double w,h,x,y;  cin>>  w >> h>>x>>y ;
 double ans;
  ans=w*h/2;
  
  cout << fixed << setprecision(10);
  cout<<ans<<endl;
  if(x==w/2&&y==h/2)
    cout<<1<<endl;
  else
    cout<<0<<endl;
}

Measured memory_bytes: 256
M_D = list(map(int,input().split()))
answer=0
for m in range(1,M_D[0]+1):
    for d in range(1,M_D[1]+1):
        d1 = d%10
        d10 = d//10

        if d1*d10==m and d1>=2 and d10>=2:
            #print(d1,d10)
            answer+=1
print(answer)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    int num = 1;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        num *= (i + 1);
    }
    vector<int> order(n);
    double sum = 0;
    for (int i = 0; i < n; i++) order[i] = i;
    do {
        for (int i = 0; i < (n - 1); i++) {
            sum += sqrt(pow((x[order[i]] - x[order[i + 1]]), 2) + pow((y[order[i]] - y[order[i + 1]]), 2));
        }
    } while (next_permutation(order.begin(), order.end()));
    //cout << (sum / num) << '\n';
    printf("%.10f\n", (sum / num));
    return 0;
}

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

ll gcd(ll a, ll b){
	if (a == 0) return b;
	return gcd(b  %a, a);
}

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

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

	string s1,s2;
	ll len1,i,cnt =0;

	cin >> s1 >> s2;
	len1 = s1.size();

	for(i=0;i<len1;i++)
	{
		if(s1[i] != s2[i])
			cnt++;
	}

	cout << cnt << endl;


}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline void rd(int &x)
{
	x=0;char k=getchar();int s=1;
	while(k>'9'||k<'0'){if(k=='-')s=-1;k=getchar();}
	while(k<='9'&&k>='0')x=x*10+k-48,k=getchar();x*=s;
}
const int N=5e5+10;
int n,m,ans;
char a[100];
int main()
{
	scanf("%s",a);
	for(int i=0;i<strlen(a);i++)if(a[i]=='x')ans++;
	if(ans<=7)printf("YES");else printf("NO");
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

def main():

    isprime = [1 for i in range(60000)]
    primes = []
    for i in range(2, 55556):
        if isprime[i] == 1:
            if i % 5 == 1:
                primes.append(i)
            for j in range(1, 55556//i + 1):
                isprime[j * i] = 0


    n = getN()
    print(*primes[:n])




if __name__ == "__main__":
    main()

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a<=c && b<=d){
    if(b-c>0) cout << b-c << endl;
    else cout << 0 << endl;
  }else if(a<=c && d<=b){
    if(d-c>0) cout << d-c << endl;
    else cout << 0 << endl;
  }else if(c<=a && b<=d){
    if(b-a>0) cout << b-a << endl;
    else cout << 0 << endl;
  }else{
    if(d-a>0) cout << d-a << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static int n, k;
	static int[][] arr;
	static int[] memo;
	static boolean f = false;
	static boolean t = false;
	static int OO = (int) 1e18;
	static ArrayList<Integer>[] adjList;
	static boolean[] vis;

	static int dp(int u) {

		if (memo[u] != -1)
			return memo[u];
		int ans = 0;

		for (int nxt : adjList[u])
			ans = Math.max(dp(nxt) + 1, ans);
		return memo[u] = ans;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);

		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());
		adjList = new ArrayList[n];
		for (int i = 0; i < n; i++)
			adjList[i] = new ArrayList<Integer>();

		while (k-- > 0) {
			st = new StringTokenizer(br.readLine());
			adjList[Integer.parseInt(st.nextToken()) - 1].add(Integer.parseInt(st.nextToken()) - 1);

		}

		memo = new int[n + 1];
		Arrays.fill(memo, -1);
		int max = -1;
		for (int i = 0; i < n; i++)
			max = Math.max(max, dp(i));
		pw.println(max);

		pw.close();
	}
}


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

int main() {
    string s;
    cin>>s;
    cout << (s=="ABC"? "ARC":"ABC") <<endl;

}

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


int main(){
    int A,B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++)
    {
        if(i%10 == i/10000 && (i/10)%10 == (i/1000)%10) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;
struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}

const int MAX_N = 112345;
mint dp[MAX_N][2];

int main2() {

  REP(i, MAX_N) REP(j, 2) dp[i][j] = 0;

  string L; cin >> L;
  int N = L.size();

  dp[0][0] = 1;

  for (int i = 0; i < N; i++) {
    if (L[i] == '1') {
      dp[i+1][0] += mint(2) * dp[i][0];
      dp[i+1][1] += dp[i][0];
      dp[i+1][1] += mint(3) * dp[i][1];
    } else {
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += mint(3) * dp[i][1];
    }
  }
  mint ans = dp[N][0] + dp[N][1];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
char s[100];
char s1[100];
char s2[100];
int main(){
char c,c1,c2;
scanf("%s %s %s",&s,&s1,&s2);
c=s[0];
c1=s1[0];
c2=s2[0];
printf("%c%c%c",c,c1,c2);


}

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

int n,m,k;
vector<ll> ra,rb;

bool isOK(int i,int j){
  if(ra[i]+rb[j]<=k) return true;
  else return false;
}

int nibutan(int i){
  int ok=-1, ng=m+1;
  while(ng-ok>1){
    int middle=(ok+ng)/2;
    if(isOK(i,middle)) ok=middle;
    else ng=middle;
  }
  return i+ok;
}

main(){
  cin>>n>>m>>k;
  ra.resize(n+1);
  rb.resize(m+1);
  ra[0]=0;rb[0]=0;
  rep(i,n){
    int a;
    cin>>a;
    ra[i+1]=ra[i]+a;
  }
  rep(i,m){
    int b;
    cin>>b;
    rb[i+1]=rb[i]+b;
  }
  int ans=0;
  for(int i=0; i<=n; i++){
    if(ra[i]>k) continue;
    int now = nibutan(i);
    ans=max(ans,now);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 6376
import sys

s = input()
t = input()

s = sorted(s)
t = sorted(t)[::-1]

N = len(s)
M = len(t)

if N < M:
    if s == t[:N]:
        print('Yes')
        sys.exit()
N = min(N, M)
i = 0
while i < N and s[i] == t[i]:
    i += 1
if i < N and s[i] < t[i]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9020
s=input()

for bit in range(2**3):
    ans=int(s[0])
    sign=[]
    for g in range(3):
        if (bit>>g)&1:
            sign.append("+")
        else:
            sign.append("-")
    for l in range(3):
        if sign[l]=="+":
            ans+=int(s[l+1])
        else:
            ans-=int(s[l+1])
    if ans==7:
        break

str_ans=s[0]
for i in range(3):
    str_ans+=sign[i]
    str_ans+=s[i+1]
str_ans+="=7"
print(str_ans)

Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	char a;
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (a == 'Y') {
			cout << " Four" << endl;
			return 0;
		}
	}
	cout << " Three" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int dp[100001]={1};
int a[100001];
int main(){
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	rb(i,1,m){
		int ai;
		cin>>ai;
		a[ai]=1; 
	}
	rb(i,1,n){
		if(a[i]) continue;
		if(i==1){
			dp[i]=dp[i-1];
		}
		else{
			dp[i]=dp[i-1]+dp[i-2];
		}
		dp[i]%=MOD;
	}
	cout<<dp[n];
	return 0;
}

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

using namespace std;

unsigned int n;

void maxify(int* A, unsigned int i){
  unsigned int l, r, lar, temp;
  l = 2*i;
  r = 2*i+1;
  if(l<=n/*sizeof(A)/sizeof(unsigned int)*/ && A[l]>A[i]) lar=l;
  else lar=i;
  if(r<=n/*sizeof(A)/sizeof(unsigned int)*/ && A[r]>A[lar]) lar=r;
  if(lar!=i){
    temp=A[i];
    A[i]=A[lar];
    A[lar]=temp;
    maxify(&A[0], lar);
  }
}

void buildmax(int* A){
  for(unsigned int i=n/2/*sizeof(A)/sizeof(unsigned int)*/;i>=1;i--) maxify(A,i);
}
  
int main(){
  int x;
  vector<int> A;

  A.push_back(0);
  cin >> n;
  for(unsigned int i=1;i<=n;i++){
    cin >> x;
    A.push_back(x);
  }
  buildmax(&A.front());
  for(unsigned int i=1;i<=n;i++) cout << " " << A[i];
  cout << endl;

  return 0;
}
  

Measured memory_bytes: 4860
import java.util.Scanner
import java.util.ArrayList

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    var nowB : Int
    var nowA : Int
    var total : Long = 0
    var previousB : Int
    var arraylist_A = ArrayList<Int>()
    for(i in 0 until N+1){
        arraylist_A.add(sc.nextInt())
    }
    nowB = sc.nextInt()
    nowA = arraylist_A.elementAt(0)
    if(nowB >= nowA){
        total += nowA
        nowB -= nowA
    }else{
        total += nowB
        nowB = 0
    }
    previousB = nowB
    for(i in 1 until N){
        nowB = sc.nextInt()
        nowA = arraylist_A.elementAt(i)
        if(previousB >= nowA){
            total += nowA
            nowA = 0
        }else{
            total += previousB
            nowA -= previousB
        }
        if(nowB >= nowA){
            total += nowA
            nowB -= nowA
        }else{
            total += nowB
            nowB = 0
        }
        previousB = nowB
    }
    nowA = arraylist_A.elementAt(N)
    if(nowA >= previousB){
        total += previousB
    }else{
        total += nowA
    }
    println(total)
}

Measured memory_bytes: 73512
import heapq

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N,K = map(int,input().split())
A = [int(i) for i in input().split()]
B = [-int(i) for i in A ]
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
heapq.heapify(A)
heapq.heapify(B)
ans = 0
m = 1
while True:
    if N - m < K - 1 :
        break
    else:
        a = heapq.heappop(A)
        b = heapq.heappop(B)
        c = cmb(N-m,K-1,mod)
        ans += (-b) * c
        ans -= a * c
        m += 1
        ans = ans % mod
print(ans)


Measured memory_bytes: 25304
import java.util.Arrays;
import java.util.Scanner;

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

		int[] KISU=new int[100001];
		int[] GUSU=new int[100001];

		for(int i=0; i<=100000; i++) {
			KISU[i]=0;
			GUSU[i]=0;
		}

		for(int i=0; i<N; i++) {
			if(i%2==0) {
				KISU[sc.nextInt()]++;
			}
			else if(i%2==1) {
				GUSU[sc.nextInt()]++;
			}
		}

		int K_MAX=0;
		int G_MAX=0;
		int K_NUM=0;
		int G_NUM=0;
		int K_2nd=0;
		int G_2nd=0;
		int K_2nu=0;
		int G_2nu=0;

		for(int i=0; i<=100000; i++) {
			if(K_MAX<KISU[i]) {
				K_MAX=KISU[i];
				K_NUM=i;
			}

			if(G_MAX<GUSU[i]) {
				G_MAX=GUSU[i];
				G_NUM=i;
			}
		}

		Arrays.sort(KISU);
		Arrays.sort(GUSU);
		K_2nd=KISU[99999];
		G_2nd=GUSU[99999];

		if(K_NUM!=G_NUM) {
			System.out.println(N-K_MAX-G_MAX);
		}
		else if(K_NUM==G_NUM) {
			int[][] mat=new int[2][2];
			mat[0][0]=K_MAX;
			mat[0][1]=K_2nd;
			mat[1][0]=G_MAX;
			mat[1][1]=G_2nd;

			System.out.println(Math.min(N-mat[0][0]-mat[1][1], N-mat[0][1]-mat[1][0]));
		}
	}
}




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

stack<long> st;

void topologicalSort(vector<long> graph[], bool visited[], long u) {
	visited[u] = true;
	for(long i=0; i<graph[u].size(); i++) {
		if(!visited[graph[u][i]]) {
			topologicalSort(graph, visited, graph[u][i]);
		}
	}
	st.push(u);
}

int main() {
	// your code goes here
	long n, m;
	cin >> n >> m;
	vector<long> graph[n];
	for(long i=0; i<m; i++) {
		long u, v;
		cin >> u >> v;
		graph[u-1].push_back(v-1);
	}
	bool visited[n] = {false};
	for(long i=0; i<n; i++) {
		if(!visited[i]) {
			topologicalSort(graph, visited, i);
		}
	}
	long levels[n] = {0};
	while(!st.empty()) {
		int u = st.top();
		st.pop();
		for(long i=0; i<graph[u].size(); i++) {
			levels[graph[u][i]] = max(levels[graph[u][i]], levels[u]+1);
		}
	}
	long maximum = 0;
	for(long i=0; i<n; i++) {
		maximum = max(maximum, levels[i]);
	}
	cout << maximum << endl;
	return 0;
}

Measured memory_bytes: 8704
n=int(input())
a=[]
for i in range(n):
    s=list(str(input()))
    s.sort()
    a.append(s)
a.sort()

ans=''
for j in range(len(a[0])):
    for i in range(1,n):
        if a[0][j] not in a[i]:
            break
    else:
        ans+=a[0][j]
b=list(set(ans))
#print(b)
#print(a)
ANS=[]
for i in range(len(b)):
    c=[]
    for j in range(n):
        c.append(a[j].count(b[i]))
    ANS.append(min(c)*b[i])
ANS.sort()
ANS=''.join(map(str,ANS))
print(ANS)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	
	final static int INF = 100;
	static int time = 0;
	
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] Graph = new int[n + 1][n];
		int[] depth = new int[n + 1];
		int[] f = new int[n + 1];
		
		for(int i = 0; i < n; i++){
			String[] str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			for(int j = 0; j < y; j++){
				Graph[x][j] = Integer.parseInt(str[j + 2]);
			}
		}
		
		for(int i = 1; i <= n; i++){
			if(depth[i] == 0){
				search(Graph, depth, f, i);
			}
		}
		
		for(int i = 1; i <= n; i++){
			System.out.println(i + " " + depth[i] + " " + f[i]);
		}
	}
	
	public static void search(int[][] Graph, int[] depth, int[] f, int x){
		depth[x] = ++time;
		for(int i = 0; i < Graph[x].length && Graph[x][i] > 0; i++){
			if(depth[Graph[x][i]] == 0){
				search(Graph, depth, f, Graph[x][i]);
			}
		}
		f[x] = ++time;
	}
}

Measured memory_bytes: 24616
if __name__=='__main__':
    N = int(input())
    A = [ int(_) for _ in input().split(' ') ]
    print(' '.join(map(str,A)))
    for i in range(1, N):
        key = A[i]
        j = i-1
        while j >= 0 and A[j] > key:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = key
        print(' '.join(map(str,A)))


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <queue>

#define fi first
#define se second
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k, q;
	cin >> n >> k >> q;
	vi diff (n);
	diff[0] += k;

	while (q--) {
	  int foo;
	  cin >> foo;
	  foo--;
	  diff[0]--;
    diff[foo]++;
	  if (foo + 1 < n) {
      diff[foo + 1]--;
    }
  }

  int tot = 0;
  FOR (i, 0, n) {
    tot += diff[i];
    cout << (tot > 0 ? "Yes" : "No") << '\n';
  }
	return 0;
}

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

const int MAX_N = 1e5 + 1;

int cnt[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, L, R;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> L >> R;
        cnt[L]++, cnt[R + 1]--;
    }
    for (int i = 1; i <= N; i++) {
        cnt[i] += cnt[i - 1];
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (cnt[i] == M) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nkc = readln.split.to!(int[]);
    auto N = nkc[0];
    auto K = nkc[1];
    auto C = nkc[2];
    auto S = readln.chomp;
    foreach (_; 0..N) S ~= 'x';
    auto left = new int[](N);
    int last = -1;
    foreach (i; 0..N) {
        left[i] = last;
        if (S[i] == 'o') last = i;
    }

    auto DP1 = new int[](N*2+1);
    foreach (i; 0..N*2) {
        DP1[i+1] = max(DP1[i+1], DP1[i]);
        if (S[i] == 'o') DP1[i+C+1] = max(DP1[i+C+1], DP1[i] + 1);
    }
    auto DP2 = new int[][](2, N*2+1);
    foreach_reverse (i; 0..N*2) {
        if (i-1 >= 0) DP2[0][i-1] = max(DP2[0][i-1], DP2[0][i], DP2[1][i]);
        if (i-C-1 >= 0 && S[i-C-1] == 'o') DP2[1][i-C-1] = max(DP2[1][i-C-1], DP2[0][i]+1, DP2[1][i] + 1);
    }
    foreach (i; 0..N) {
        if (S[i] == 'x') continue;
        if (left[i] == -1) {
            if (DP2[0][i] < K) writeln(i+1);
        } else if (left[i] + C >= i) {
            auto l = left[i];
            if (DP2[1][l] + DP1[l] < K && DP2[0][i] + DP1[i] < K && DP1[i] + DP2[1][i] >= K) writeln(i+1);
        } else {
            if (DP2[0][i] + DP1[i] < K && DP1[i] + DP2[1][i] >= K) writeln(i+1);
        }
    }
}

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t.at(i);
  }
  
  map<string, int> p;
  for (int i = 0; i < n; i++) {
    if (p.count(s.at(i))) {
      p.at(s.at(i))++;
    }
    else {
      p[s.at(i)] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    if (p.count(t.at(i))) {
      p.at(t.at(i))--;
    }
    else {
      p[t.at(i)] = -1;
    }
  }
  int x = 0;
  for (int i = 0; i < s.size(); i++) {
    if (x < p.at(s.at(i))) {
      x = p.at(s.at(i));
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int p = 1000000007;
int log2_p_MAX = 32;
// 1/a (mod p) = a^(p-2) (mod p)
long felmer(long a)
{
  // a^(2^i) mod p
  long rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  long res = 1;
  long expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
int main()
{
  int x,y,n,i;
  long long res=1;
  cin >> x >> y;
  if((x+y)%3>0 || x-2*y>0 || y-2*x>0){
    cout << "0" << endl;
    return 0;
  }
  n=(x+y)/3;
  x=min(x,y)-n;
  y=n-x;
  for(i=1;i<=x;i++){
    res*=n+1-i;
    res%=p;
    res*=felmer(i);
    res%=p;
  }
  cout << res << endl;
  return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    char c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
            cout << c[i][j];
        }
        cout << endl;
        for(int j=0;j<w;j++){
            cout << c[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int ans = thousands(total);
        System.out.println(ans);
    }

    // N = 1900;
    public static int thousands(int N) {
        int total = 0;
        for (total = 1000; total < N; total = total + 1000) {
        }
        return total - N;
    }

}



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


void solve(long long X, long long Y){
  long long count = 0;

  for(long long i = X; i <= Y; i*=2) count++;
  cout << count<< endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


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

int dp[5005][5005];

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

    for(int i=n-1;i>=0;i--){
        for(int j=n-1;j>=0;j--){
            if(s[i]==s[j]) dp[i][j] = min(dp[i+1][j+1]+1,abs(i-j));
        }
    }


    /*
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) cout << dp[i][j] << " ";
        cout << endl;
    }
    */

    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans = max(ans,dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 101336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int h, w, k;
    cin >> h >> w >> k;
    auto item = make_vec<int>(h, w);
    rep(i, k) {
        int r, c, v;
        cin >> r >> c >> v;
        r--; c--;
        item[r][c] = v;
    }

    auto dp = make_vec<ll>(4, h+1, w+1);

    rep(i, h) rep(j, w) {
        rep(t, 4) chmax(dp[0][i+1][j], dp[t][i][j] + (t <= 2) * item[i][j]);
        rep(t, 4) chmax(dp[t][i][j+1], dp[t][i][j]);
        if (!item[i][j]) continue;
        rep(t, 3) chmax(dp[t+1][i][j+1], dp[t][i][j] + item[i][j]);
    }

    ll ans = 0;

    rep(t, 4) chmax(ans, dp[t][h-1][w-1] + item[h-1][w-1] * (t <= 2));
    cout << ans << '\n';
}


Measured memory_bytes: 390140
#include<iostream>
using namespace std;
int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if((a<=b&&a+w>=b)||(a>=b&&b+w>=a))
        cout << 0 << endl;
    else if(a<b) cout << b-a-w << endl;
    else if(b<a) cout << a-b-w << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        using (var reader = new StreamReader("../TextFile1.txt")) {
            var count = 1; string str;
            while((str=Debugger.ReadBlock(reader))!= null) {
                System.Diagnostics.Debug.WriteLine("----------" + count++ + "----------");
                System.Diagnostics.Debug.WriteLine(process(new StringReader(str)));
            }
        }
        System.Diagnostics.Debug.WriteLine("-----END DEBUG-----");
#endif

#if !DEBUG
        String ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }




    static string process(TextReader input) {
        var s     = input.ReadLine();
        var spl   = s.Split(' ');
        long L     = long.Parse(spl[0]);
        long R     = long.Parse(spl[1]);

        long r = 0;

        long min = long.MaxValue;

        for(long i=L; i<=R; i++) {
            for(long j=i+1; j<=R; j++) {
                long modI = i % 2019;
                long modJ = j % 2019;
                if (modI == 0 || modJ == 0) return "0";
                long mod = (modI * modJ) % 2019;
                if (mod < min) min = mod;
            }
        }
        return min.ToString();
    }

    static long calc(long l, long r) {
        return (l * r) % 2019;
    }
}

static class Debugger
{
    public static string ReadBlock(StreamReader reader) {
        var text = "";
        while (true) {
            var str = reader.ReadLine();
            if (str == null) break;
            if (str.Trim() == "" && text != "") break;
            if (str.Trim() != "") text += str + Environment.NewLine;
        }
        if (text == "") return null;
        return text;
    }
}

Measured memory_bytes: 13140