akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    print('ABC' if input()=='ARC' else 'ARC')

main()



Measured memory_bytes: 9724
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N;
void change(int A,int B,vint ablechange){
	if(ablechange.size()==1){
		printf("%d %d ",A,B);
		return;
	}
	else{
		rep(i,ablechange.size()){
			int keta=ablechange[i];
			int Aprime=A^(1<<keta);
			if(B!=Aprime){
				rep(j,ablechange.size()){
					if(j==i) continue;
					int keta2=ablechange[j];
					if(((Aprime>>keta2)&1)!=((B>>keta2)&1)){
						int Bprime=Aprime^(1<<keta2);
						vint ablechangenew;
						rep(k,ablechange.size()) if(ablechange[k]!=keta2) ablechangenew.push_back(ablechange[k]);
						change(A,Aprime,ablechangenew);
						change(Bprime,B,ablechangenew);
						break;
					}
				}
				break;
			}
			else continue;
		}
	}
}
int main(){
	int A,B;
	scan(N);scan(A);scan(B);
	int difnum=0;
	rep(i,N){
		if(((A>>i)&1)!=((B>>i)&1)){
			difnum++;
		}
	}
	if(difnum%2==1){
		prin("YES");
		vint allchange;
		rep(i,N) allchange.push_back(i);
		change(A,B,allchange);
		kaigyo;
	}
	else{
		prin("NO");
	}
	return 0;
}


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

int main(){
    int n,x;
    cin>>n>>x;
    int minM = 1e9;
    rep(i,n){
        int m;
        cin>>m;
        x -= m;
        if(minM>m) minM=m;
    }
    
    cout << x/minM+n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int binpow(int a,int b,int mod)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*1LL*a)%mod;
        a=(a*1LL*a)%mod;
        b>>=1;
    }
    return ans;
}
const ll P=2000005;
ll fact[P],inv[P];
void preprocess()
{
    fact[0]=1;
    rep(i,1,P)
    fact[i]=(i*fact[i-1])%M;
    inv[P-1]=binpow(fact[P-1],M-2,M);
    sep(i,P-2,0)
        inv[i]=(inv[i+1]*(i+1))%M;
}
ll C(ll n,ll r)
{
    return (((fact[n]*inv[r])%M)*inv[n-r])%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    preprocess();
    ll x,y;
    cin>>x>>y;
    ll k=(2*x-y);
    if(k%3 or k<0)
    {
        cout<<0<<"\n";
        return 0;
    }
    k/=3;
    x-=2*k;
    if(x<0)
    {
        cout<<0<<"\n";
        return 0;
    }
    cout<<C(x+k,k);
}


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

int a[3];

int main () {
	for (int i = 0; i < 3; i++) scanf("%d", &a[i]);
	sort(a, a + 3);

	bool flag = false;
	if ((a[0] == a[1]) && (a[1] < a[2])) flag = true;
	if ((a[0] < a[1]) && (a[1] == a[2])) flag = true;
	if (flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
dic = {}
for _ in range(n):
  s = input()
  if dic.get(s) == None:
    dic[s] = 1
  else:
    dic[s] += 1

m = max(dic.values())
l = []
for v in dic.items():
  if v[1] == m:
    l.append(v[0])
sortl = sorted(l)
for i in range(len(sortl)):
  print(sortl[i])

Measured memory_bytes: 32984
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
long long mod=1e9+7;
long long c[8]={1,1,2,3,5,8,13,21};
int main(){
	int h,w,k;
	cin>>h>>w>>k;
	long long dp[101][8]={};
	dp[0][0]=1;
	for(int i=1;i<=h;i++){
		for(int j=0;j<w;j++){
			if(j==0){
				dp[i][0]+=dp[i-1][0]*c[w-1];
				if(w>=2){
					dp[i][0]+=dp[i-1][1]*c[w-2];
				}
			}else if(j==w-1){
				dp[i][w-1]+=dp[i-1][w-1]*c[w-1];
				if(w>=2){
					dp[i][w-1]+=dp[i-1][w-2]*c[w-2];
				}
			}else{
				dp[i][j]+=dp[i-1][j]*c[j]*c[w-j-1];
				dp[i][j]+=dp[i-1][j-1]*c[j-1]*c[w-j-1];
				dp[i][j]+=dp[i-1][j+1]*c[j]*c[w-j-2];
			}
			dp[i][j]%=mod;
		}
	}
	cout<<dp[h][k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    n: usize,
    k: usize,
    );
    let p = 1_000_000_007;

    let mut ans = 0;
    for i in k..=n + 1 {
        ans += (n + 2) * i - i * (i + 1) + 1;
    }
    println!("{}", ans % p);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
static const int INF = (1 << 21);
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i = 0; i < N; i++){
        cin >> h.at(i);
    }
    
    
    
    vector<int> dp(N+1);
    dp.at(0) = INF;
    dp.at(1) = 0;
    
    for(int i = 2; i <= N; i++){
        if(i-3 >= 0){
            dp.at(i) = min(dp.at(i-1) + abs(h.at(i-1)-h.at(i-2)), dp.at(i-2) + abs(h.at(i-1)-h.at(i-3)));
        }
        else{
            dp.at(i) = dp.at(i-1) + abs(h.at(i-1)-h.at(i-2));
        }
    }
    cout << dp.at(N) << endl;
    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    for(int i=0; i<k; i++){
      cout<<s.at(i);
    }
    cout<<"..."<<endl;
  }
  return 0;
}

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

// #define int long long
#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 SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#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 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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,a,b; cin>>n>>a>>b;
  string s; cin>>s;
  ll c=a+b;
  ll sum=0, bsum=0;
  rep(i,n){
    if(s[i]=='c'){
      cout<<"No"<<endl;
    }else{
      if(s[i]=='a'){
        if(sum<c){
          sum++;
          cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
      }else{
        if(sum<c&&bsum<b){
          sum++,bsum++;
          cout<<"Yes"<<endl;
        }else{
          cout<<"No"<<endl;
        }
      }
    }
  }
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
 
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll h,n;
    cin>>h>>n;ll s=0;
    ll a[100005];
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<n;i++)
    {s+=a[i];}
    if(s>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}












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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X,Y;
vector<int> E[2020];

int D[2020];
int ret[2020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>Y;
	FOR(i,N-1) {
		E[i].push_back(i+1);
		E[i+1].push_back(i);
	}
	E[X-1].push_back(Y-1);
	E[Y-1].push_back(X-1);
	
	FOR(i,N) {
		FOR(j,N) D[j]=2020;
		queue<int> Q;
		D[i]=0;
		Q.push(i);
		while(Q.size()) {
			x=Q.front();
			Q.pop();
			if(i<x) ret[D[x]]++;
			FORR(e,E[x]) if(D[e]==2020) {
				D[e]=D[x]+1;
				Q.push(e);
			}
		}
	}
	
	for(i=1;i<=N-1;i++) cout<<ret[i]<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
  int k,x;
  cin >> k >> x;
  int a = x-k+1;
  int b = x+k-1;
  for(int i = a;i <= b;++i){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <climits>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

int main() {
	int n, i, j;
	vector<pair<int, int>> pos;
	pair<int, int> temp;
	double l;
	double x;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> temp.first >> temp.second;
		pos.push_back(temp);
	}

	l = 0;
	for (i = 0; i < n- 1; i++) {
		for (j = i + 1; j < n; j++) {
			l += (double)sqrt(pow(pos[i].first - pos[j].first, 2) + pow(pos[i].second - pos[j].second, 2));
		}
	}
	
	x = l * 2 / (double) n;

	cout<< fixed << setprecision(9);
	cout  << x <<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
// #include <cctype>

using namespace std;

int main()
{   
    vector<int> sequence;
    int n;
    cin >> n;

    sequence.resize(n);

    int i = 0;
    while (i < n)
    {
        cin >> sequence[i];
        i++;
    }

    for (int i = 0; i < n; i++)
        cout << (i? " ": "") << sequence[i];
    cout << endl;

    for (int i = 1; i < n; i++)
    {
        int temp = sequence[i];

        int j = i-1;
        while (j >= 0 && temp < sequence[j])
        {
            sequence[j+1] = sequence[j];    
            j--;
        }
        sequence[j+1] = temp;

        for (int i = 0; i < n; i++)
            cout << (i? " ": "") << sequence[i];
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int k, a, b;
	cin >> k >> a >> b;
	int y = 0;
	int bis = 1;
	int ans = 0;
	 if((a-1)<=k)
	  {
	  	k-=(a-1);
	  	if((b-a)>2)
	  	{
	  		ans=a+(k/2)*(b-a)+(k%2==1);
	  	}
	  	else
	  		ans=a+k;
	  }
	  //else we can't apply operation 2||3 we have to apply operation 1 only ...
	  else
	  	ans=1+k;
	cout << ans << en;


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
char a[21],c[21];
int b=0,i;
scanf("%s",a);
for(i=0;a[i]!='\0';i++)
{
    b++;
}
for(i=0;i<b;i++)
{
    c[i]=a[b-i-1];
}
c[b]='\0';
printf("%s\n",c);
return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <stdlib.h>

int main(){
	long N, i, Ai;
	long *B;

	scanf("%ld", &N);
	B = malloc(N * sizeof(long));

	for(i=0; i<N-1; i++){
		scanf("%ld", &Ai);
		B[Ai-1]++;
	}

	for(i=0; i<N; i++){
		printf("%ld\n",B[i]);
	}


	return 0;
}


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

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b;
        return 1;
    }
    
    return 0;
    
}


int main(void){
    
    string S;
    cin >> S;

  
    int DP[S.size()+1][3];
    memset(DP, 0, sizeof(DP));
    DP[1][0] = 1;
    DP[2][1] = 1;
    
    for(int i = 0; i <= S.size();i++){
        if(i >= 1 && S[i-1] != S[i]) chmax(DP[i+1][1],DP[i][1]+1);
        if((i >= 2 && S[i-2] != S[i] )|| S[i-1] != S[i+1]) chmax(DP[i+2][2],DP[i][2]+1);
        chmax(DP[i+2][2],DP[i][1]+1);
        chmax(DP[i+1][1],DP[i][2]+1);
    }
    
    cout <<max(DP[S.size()][1],DP[S.size()][2]) <<endl;
    
    
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k) {cout << k; return 0;}
    else k -= a;
    if(b >= k) {cout << a; return 0;}
    else k-= b;
    if(c >= k){cout << a - k; return 0;}
    else cout << a - c;
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
  long N;
  cin>>N;
  long a[N];
  for(long i=0;i<N;i++){
    cin>>a[i];
  }
  long cnt=0;
  long num=1;
  for(int i=0;i<N;i++){
    if(a[i]==num){
      num++;
      cnt++;
    }
  }
  if(cnt==0){
    cout<<(-1);
    return 0;
  }
  cout<<(N-cnt);
  return 0;
}
  

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> D, long long M, std::vector<long long> T) {
    map<ll, ll> problemcnt;
    rep(i, N) { problemcnt[D[i]]++; }
    rep(i, M) {
        problemcnt[T[i]]--;
        if (problemcnt[T[i]] < 0) {
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> D(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &D[i]);
    }
    long long M;
    scanf("%lld", &M);
    std::vector<long long> T(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &T[i]);
    }
    solve(N, std::move(D), M, std::move(T));
    return 0;
}


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

/*vector<int> p(n);
cin >> p[i]*/

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

    if(n[0] == '7' || n[1]  == '7' || n[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(){
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N;
  cin >> N;
  vvi a(2, vi(N));
  rep(i, 2) rep(j, N) cin >> a[i][j];

  vvi s(2, vi(N, 0));
  s[0][0] = a[0][0];
  rep(i, 1) rep(j, N - 1) {
    if (j == 0) s[i + 1][j] = s[i][j] + a[i + 1][j];
    s[i][j + 1] = s[i][j] + a[i][j + 1];
    s[i + 1][j + 1] = max(s[i + 1][j], s[i][j + 1]) + a[i + 1][j + 1];
  }
  int res = (N > 1) ? s[1][N - 1] : a[0][0] + a[1][0];

  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ()
{
	int x,y; cin >> x >> y;
	int p = x;
	for (int i = 0;i <= x;i++)
	{
		if ((i * 2) + (p * 4) == y)
		{
			cout << "Yes";
			return 0;
		}
		--p;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stdlib.h>
using namespace std;
typedef long long int ll;
#define INF (1e9)
#define distance(x1,y1,x2,y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
#define rep(i,N) for(ll i=0;i<N;i++)
using vvl=vector<vector<ll>>;
using vl=vector<ll>;
using vs=vector<string>;
using vvs=vector<vector<string>>;

bool func(vl s,vl t){
    return s[1]<t[1];
}

/*void printvl(vl v){
    rep(i,v.size()){
        cout<<i<<": "<<v[i]<<endl;}
}

void printvl2(vvl v){
    rep(i,v.size()){
        cout<<i<<": "<<v[i][0]<<" ,"<<v[i][1]<<endl;}
}*/

int H,W;

ll ans(vs v){
    rep(i,H){
        rep(j,W){
            if(v[i][j]=='#'){
                if(i>0){
                    if(v[i-1][j]=='#'){
                        continue;
                    }
                }
                if(i<H-1){
                    if(v[i+1][j]=='#'){
                        continue;
                    }
                }
                if(j>0){
                    if(v[i][j-1]=='#'){
                        continue;
                    }
                }
                if(j<W-1){
                    if(v[i][j+1]=='#'){
                        continue;
                    }                    
                } 
                cout<<"No"<<endl;
                return 0;
            }
        }
    } 
        
    cout<<"Yes"<<endl;
    return 1;
}
    

int main(){
    cin>>H>>W;
    vs v(H);
    rep(i,H){
        cin>>v[i];
    }
    ans(v);    
    return 0;}

Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

const ll MOD = 1e9 + 7;

struct SegTree{
	int n;
	vvi T;

	SegTree(vi& B){
		n = isize(B);
		T = vvi(4*n + 10);
		build(B, 1, 0, n-1);
	}

	void build(vi& B, int v, int tl, int tr){
		if (tl == tr){
			T[v] = {B[tl]};
		}else{
			int mid = (tl + tr)/2;
			build(B, 2*v, tl, mid);
			build(B, 2*v+1, mid+1, tr);
			vi new_v = vi();
			merge(all(T[2*v]), all(T[2*v+1]), back_inserter(new_v));
			T[v] = new_v;
		}
	}

	int qry(int l, int r, int x, int v, int tl, int tr){
		if (l > tr or r < tl) return 0;
		if (l <= tl and tr <= r){
			auto pt = lower_bound(all(T[v]), x+1);
			return distance(pt, T[v].end());
		}
		int mid = (tl + tr)/2;
		int L = qry(l, r, x, 2*v, tl, mid);
		int R = qry(l, r, x, 2*v+1, mid+1, tr);
		return L + R;
	}

};

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n, q; cin >> n >> q;
	vi A = vi();
	rep(i, n){
		int x; cin >> x;
		A.pb(x);
	}
	vi B = vi(n);
	umap<int, int> last = umap<int, int>();
	for(int i = isize(A)-1; i >= 0; i--){
		int val = A[i];
		if (last.find(val) == last.end()){
			B[i] = INF;
		}else{
			B[i] = last[val];
		}
		last[val] = i; 
	}
	SegTree ST = SegTree(B);
	rep(i, q){
		int l, r; cin >> l >> r;
		l--, r--;
		int ans = ST.qry(l, r, r, 1, 0, isize(B)-1);
		cout << ans << "\n";
	}
}

Measured memory_bytes: 140064
#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 n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
            continue;
        }
        while (x > 0)
        {
            if (x % 10 == 3)
            {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,m,i,j,a[55],b[55],c[55],d[55];
    cin>>n>>m;
    for(i=0; i<n; i++)
        cin>>a[i]>>b[i];
    for(i=0; i<m; i++)
        cin>>c[i]>>d[i];
    for(i=0; i<n; i++)
    {
        int l=0x3f3f3f3f,index=0;
        for(j=0; j<m; j++)
        {
            int ll;
            ll=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(ll<l) l=ll,index=j;
        }
        cout<<index+1<<endl;;
    }
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long[] nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        long[] a = new long[m];
        long[] b = new long[m];
        for (long i = 0; i < m; i++)
        {
            long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
            a[i] = tmp[0];
            b[i] = tmp[1];
        }


        var dic = new Dictionary<long, long>() { };
        for (int i = 0; i < m; i++)
        {
            if (a[i] == 1)
            {
                dic.Add(b[i], 1);
            }
        }
        for (int i = 0; i < m; i++)
        {
            if (b[i] == n)
            {
                if (dic.ContainsKey(a[i]))
                {
                    dic[a[i]]++;
                }
            }
        }

        string ans = "POSSIBLE";
        var count = dic.Where(val => val.Value == 2).Count();
        if (count == 0)
        {
            ans = "IMPOSSIBLE";
        }

        Console.WriteLine(ans);
    }
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int h,w;
char c[60][60];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>c[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(c[i][j]=='.'){
                int f = 0;
                if(c[i-1][j-1]=='#')f++;
                if(c[i-1][j]=='#')f++;
                if(c[i-1][j+1]=='#')f++;
                if(c[i][j-1]=='#')f++;
                if(c[i][j+1]=='#')f++;
                if(c[i+1][j-1]=='#')f++;
                if(c[i+1][j]=='#')f++;
                if(c[i+1][j+1]=='#')f++;
                cout<<f;
            }
            else cout<<c[i][j];
        }
        cout<<newl;
    }
}


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

int main() {
  double x1,y1,x2,y2,ans = 0;
  cin >> x1 >> y1 >> x2 >> y2;
  ans = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
  ans = sqrt(ans);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

bool gem[21][21];
int dx(char c)
{
  switch(c)
  {
    case 'N': case 'S': return 0;
    case 'E': return 1;
    case 'W': return -1;
  }
  return 0;
}
int dy(char c)
{
  switch(c)
  {
    case 'E': case 'W': return 0;
    case 'N': return 1;
    case 'S': return -1;
  }
  return 0;
}
int main()
{
loop:
  memset(gem, 0, sizeof gem);
  int n, m, x, y, t;
  char c;
  cin >> n;
  if(!n)
    return 0;
  for(int i = 0; i < n; i++)
  {
    cin >> x >> y;
    gem[x][y] = true;
  }
  x = 10; y = 10;
  if(gem[10][10])
  {
    gem[10][10] = false;
    n--;
  }
  cin >> m;
  for(int i = 0; i < m; i++)
  {
    cin >> c >> t;
    for(int j = 0; j < t; j++)
    {
      x += dx(c);
      y += dy(c);
      if(gem[x][y])
      {
        gem[x][y] = false;
        n--;
      }
    }
  }
  cout << (!n ? "Yes" : "No") << endl;
  goto loop;
}

Measured memory_bytes: 1152
import sys, collections, heapq
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()

def solve():
    F = sys.stdin
    N, Q = map(int, line_input(F))
    event = []
    for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 97740
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	ll ans = 0ll;
	std::cin >> n;
	for(i=1; i<n; ++i){
		ans += (n-1)/i;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main()
{
  int N;
  int A;
  
  cin >> N >> A;
  
  if(N / 500 == 0)
  {
    cout << "Yes" << endl;
  }
  else if(N % 500 <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline

n=int(input())
A=[]

A1=0
B1=0

for i in range(n):
    a,b=map(int,input().split())
    
    A1+=a
    B1+=b
    
    A.append((a,2*i))
    A.append((b,2*i+1))


ANS=min(A1,B1)

A.sort()
INVIND=[-1]*(2*n)

for ind,(a,i) in enumerate(A):
    INVIND[i]=ind

S=[0]

for a,i in A:
    S.append(S[-1]+a)


for i in range(n):
    if INVIND[i*2]<n and INVIND[i*2+1]<n:
        ANS=min(ANS,S[n])

    elif INVIND[i*2]<n-1 and INVIND[i*2+1]>=n-1:
        ANS=min(ANS,A[INVIND[i*2+1]][0]+S[n-1])

    elif INVIND[i*2]>=n-1 and INVIND[i*2+1]<n-1:
        ANS=min(ANS,A[INVIND[i*2]][0]+S[n-1])

    else:
        ANS=min(ANS,S[n-2]+A[INVIND[i*2]][0]+A[INVIND[i*2+1]][0])

    #print(i,ANS)

print(ANS)


Measured memory_bytes: 48224
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int m;
  cin>>m;

  Int ans=0;
  vector<Int> vs;
  for(Int i=0;i<m;i++){
    Int d,c;
    cin>>d>>c;

    Int x=d,y=0;
    while(c){
      if(c&1){
        ans+=y;
        vs.emplace_back(x);
      }
      x=x+x;
      y=y+y+1;
      if(x>=10) x=(x/10)+(x%10),y++;
      c>>=1;
    }
  }
  Int res=vs[0];
  for(Int i=1;i<(Int)vs.size();i++){
    res+=vs[i];
    ans++;
    if(res>=10) res=(res/10)+(res%10),ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << endl;
    return 0;
}

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

int main() {
    long n, m; cin >> n >> m;
    long count = 0;

    if (m >= 2 * n) {
        count += n;
        /*n = 0;*/
        m -= 2 * n;
        cout << count + m / 4 << endl;
    }
    else {
        count += m / 2;
        n -= m / 2;
        m -= (m / 2) * 2;
        cout << count << endl;
    }
}


    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 3;
 
int main(){
    fast;
    ll a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3);
    return 0;
}

Measured memory_bytes: 4204
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int n , a , b , c = 0;
    cin >> n >> a >> b;
    long long int x[n];
    for ( int i = 0 ; i < n ; i++ ) cin >> x[i];
    for ( int i = 0 ; i < n - 1 ; i++ ) {
        if ( ( x[i + 1] - x[i] ) * a < b ) c += ( x[i + 1] - x[i] ) * a;
        else c += b;
    }
    cout << c;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

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

    int n;
    cin >> n;
    set<char> set;
    char c;
    rep(i, n){
        cin >> c;
        set.insert(c);
    }

    if(set.size() == 3){
        cout << "Three" << endl;
    }else if(set.size() == 4){
        cout << "Four" << endl;
    }

    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

set<ll> dp[200005];

ll N, K, C;

int main() {
  scanf("%lld %lld %lld", &N, &K, &C);

  string S;
  cin >> S;

  vector<ll> list1(K);
  vector<ll> list2(K);

  ll count1 = 0;
  for (ll i = 0; i < N;) {
    char ch = S[i];
    if (ch == 'o') {
      list1[count1] = i;
      i += C;
      count1++;

      if (count1 == K) {
        break;
      }
    }
    i++;
  }

  ll count2 = K - 1;

  for (ll i = N - 1; i >= 0;) {
    char ch = S[i];
    if (ch == 'o') {
      list2[count2] = i;
      i -= C;
      count2--;
      if (count2 < 0) {
        break;
      }
    }
    i--;
  }

  for (ll i = 0; i < K; i++) {
    // cout << list1[i] << "," << list2[i] << endl;

    if (list1[i] == list2[i]) {
      cout << (list1[i] + 1) << endl;
    }
  }

  // ooxxxoxxxoo
}


Measured memory_bytes: 15876
# 000~999で決め打ちして数える
# TLEになるんだけどこれそんなに重いか？？？？？

n = int(input())
s = input()
ans = 0

for i in range(0, 1000):
    t = format(i, "0>3")
    idx = 0
    for c in s:
        if c == t[idx]:
            idx += 1
        if idx == 3:
            ans += 1
            break

print(ans)


Measured memory_bytes: 42560
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    sc.nextLine()
    val tmp = sc.nextLine()
    val s = tmp.split(" ")(0)
    val t = tmp.split(" ")(1)

    var str = ""
    for (i <- 0 until n) {
      str += s(i)
      str += t(i)
    }
    println(str.mkString(""))
  }
}


Measured memory_bytes: 27328
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
Bs = []
for i in range(Q):
    Bs.append(list(map(int, input().split(' '))))
    
    
A_list = [0]*(10**5+1)
for i in A:
    A_list[i] += 1
    
sum_value = sum(A)
for B in Bs:
    b, c = B
    sum_value += A_list[b]*c
    sum_value -= A_list[b]*b
    
    A_list[c] += A_list[b]
    A_list[b] = 0
    print(sum_value)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

constexpr int INF = 1 << 30;

struct Edge {
    int from;	//出発点
    int to;		//到達点
    int cost;	//移動コスト
};

vector<int> to[2505];
vector<int> reverse_to[2505];
bool ok[2505];
bool reachableFrom1[2505];
bool reachableFromN[2505];

void dfs(int v)
{
	if (reachableFrom1[v])
	{
		return;
	}
	reachableFrom1[v] = true;

	for(const auto& u : to[v])
	{
		dfs(u);
	}
}

void dfs_reverse(int v)
{
	if (reachableFromN[v])
	{
		return;
	}
	reachableFromN[v] = true;

	for(const auto& u : reverse_to[v])
	{
		dfs_reverse(u);
	}
}


void solve()
{
	fill(ok, ok + 2505, false);
	fill(reachableFrom1, reachableFrom1 + 2505, false);
	fill(reachableFromN, reachableFromN + 2505, false);

	int n, m, p;
	cin >> n >> m >> p;

	vector<Edge> edges;
	vector<int> dist(n, INF);
	dist[0] = 0;

	for(int i = 0; i < m; ++i)
	{
		Edge edge;
		cin >> edge.from >> edge.to >> edge.cost;
		edge.from--;
		edge.to--;
		edge.cost -= p;
		edge.cost *= -1; // コストを反転させて最短経路問題を解けば、最長経路になる

		edges.emplace_back(edge);

		to[edge.from].emplace_back(edge.to);
		reverse_to[edge.to].emplace_back(edge.from);
	}

	dfs(0);
	dfs_reverse(n - 1);
	for(int i = 0; i < n; ++i)
	{
		ok[i] = reachableFrom1[i] & reachableFromN[i];
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			Edge e = edges[j];
			if(!ok[e.to]) continue;

			if (dist[e.to] > dist[e.from] + e.cost)
			{
				dist[e.to] = dist[e.from] + e.cost;
				if (i == n - 1)
				{
					cout << -1;
					return;
				}
			}
		}
	}
	cout << max(dist[n - 1] * -1, 0);	
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  while(~scanf("%d",&n)){
    int cnt = 0;
    REP(a,10)REP(b,10)REP(c,10){
      int d = n-a-b-c;
      if(0<=d && d<10)++cnt;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
list1 = input().split(" ")
N = int(list1[0])
D = int(list1[1])
count1 = 0
for i in range(N):
  list2 = input().split(" ")
  x = int(list2[0])
  y = int(list2[1])
  d = (x**2 + y**2)**(1/2)
  if d <= D:
    count1 += 1
  else:
    pass
print(count1)  

Measured memory_bytes: 9492
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
typedef vector<int> vi;
typedef vector<vector<int>> vi2;
int main(void)
{
    int N;
    cin >> N;
    vi a;
    int tmp;
    bool *f;
    f = new bool[N];
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    for (int i = 0; i < N; i++)
    {
        f[i] = false;
    }
    f[0] = true;
    int count = 0;
    int i = 0;
    int c = 0;
    while (1)
    {
        if (f[1] == true || c >= N)
        {
            break;
        }
        else if (f[i] == true)
        {
            f[a[i] - 1] = true;
            f[i] = false;
            count++;
        }
        i = a[i] - 1;
        c++;
    }
    if (f[1] == true)
    {
        cout << count << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 892
n=int(input())
a=list(map(int,input().split()))
d={}

for x in range(n):
  if a[x] not in d:
    d[a[x]]=0
  d[a[x]]+=1
  
ans=0
for y in d:
  if d[y]>y:
    ans+=d[y]-y
  elif d[y]<y:
    ans+=d[y]
    
print(ans)

Measured memory_bytes: 21672
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000


int nC2(int n);

int main()
{
    int N, M;
    cin >> N >> M;
    
    string ret;
    for (int i=0; i<N; i++) {
        ret.push_back('x');
    }
    
    int s,c;
    char n;
    int err = 0;
    for (int i=0; i<M; i++) {
        cin >> s >> c;
        n = '0' + c;
        s--;                // ret[s]として使えるようにした
        
        if(ret[s] == 'x' || ret[s] == n){
            ret[s] = n;
        } else {
            err = 1;
            break;
        }
    }
    
    if(N != 1 && ret[0] == '0') err = 1;
    if(N != 1 && ret[0] == 'x') ret[0] = '1';
    if(N ==1 && ret[0] == 'x') ret[0] = '0';
    
    if(err){
        cout << -1 << endl;
        return 0;
    }
    
    for (int i=1; i<N; i++) {
        if(ret[i] == 'x') {
            ret[i] = '0';
        }
    }
    
    cout << ret << endl;
    
    
    return 0;
}

int nC2(int n)
{
    if(n <= 1) return 0;
    else return n*(n-1)/2;
}


Measured memory_bytes: 256