akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>

int n, ans;
double x[10], y[10], sum;
bool b[10];

double dis(int a, int b){
	return sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
}

void dfs(int k, int las, double cnt){
	if(k == n){
		ans++;
		sum += cnt;
		return;
	}
	for(int i = 1; i <= n; i++)
		if(!b[i]){
			b[i] = 1;
			dfs(k + 1, i, cnt + dis(las, i));
			b[i] = 0;
		}
}

int main(){
	
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lf%lf", &x[i], &y[i]);
		
	for(int i = 1; i <= n; i++){
		b[i] = 1;
		dfs(1, i, 0.0);
		b[i] = 0;
	}
	printf("%.9lf\n", sum / ans);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);

if(a <= b&&b <= c)
printf("%d %d %d\n",a,b,c);

else if(a <= c&&c <= b)
printf("%d %d %d\n",a,c,b);

else if(b <= a&&a <= c)
printf("%d %d %d\n",b,a,c);

else if(b <= c&&c <= a)
printf("%d %d %d\n",b,c,a);

else if(c <= a&&a <= b)
printf("%d %d %d\n",c,a,b);

else if(c <= b&&b <= a)
printf("%d %d %d\n",c,b,a);


return 0;

}

Measured memory_bytes: 596
#include<cstdio>
#include <vector>
#include <utility>
#include <functional>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	ull A[N];
	for (int i = 0; i < N; ++i){
		scanf("%llu", A + i);
	}
	sort(A, A + N);
	vector<pair<ull, unsigned> > B;
	for (int i = 0; i < M; ++i){
		unsigned tmp1;
		ull tmp2;
		scanf("%u %llu", &tmp1, &tmp2);
		B.push_back(make_pair(tmp2, tmp1));
	}
	sort(B.begin() , B.end(), greater<pair<ull, unsigned> >());
	unsigned a_now = 0, b_now = 0;
	while(a_now < N && B[b_now].first > A[a_now]){
		unsigned i = 0;
		while(i < B[b_now].second && a_now < N && B[b_now].first > A[a_now]){
			A[a_now++] = B[b_now].first;
			i++;
		}
		if(i < B[b_now].second) break;
		b_now++;
	}
	ull ans = 0;
	for (int i = 0; i < N; ++i){
		ans += A[i];
	}
	printf("%llu\n", ans);
	return 0;
}

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

template <typename T>
using lim = numeric_limits<T>;

const int MAXN = 101;
string arr[MAXN];

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

	string s; cin >> s;
	string ans = "";
	for (char c: s){
		if (c != 'B') ans.append(1,c);
		else ans = ans.substr(0,ans.size()-1);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

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

    cout << max(min(b, d) - max(a, c), 0) << endl;

    return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
k = int(input())
while((not b>a) and k):
	b*=2
	k-=1
while((not c>b) and k):
	c*=2
	k-=1
if(a<b and b<c):
	print('Yes')
else:
	print('No')
 

Measured memory_bytes: 9200
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main() {
	int N; cin >> N;
	vector<string>W(N);
	map<string, int>cnt;
	for (int i = 0; i < N; i++) {
		string tmp; cin >> tmp;
		W[i] = tmp;
		cnt[tmp]++;
	}
	for (int i = 0; i < N - 1; i++) {
		if (W[i].back() != W[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
		if (cnt[W[i]] >= 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    long long x;
    cin>>x;
    long long qian=100,sum=0;
    while(qian<x){
    	sum++;
    	qian+=(qian/100);
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,m,val[100005],sol;
vector<int> gr[100005];

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>val[i];
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        bool ok=1;
        for(int j=0;j<gr[i].size();j++)
        {
            if(val[gr[i][j]]>=val[i])
            {
                ok=0;
                break;
            }
        }
        sol+=ok;

    }
    cout<<sol;

}


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

using namespace std;
#define BUF (100005)

long long  N;
long long  A[BUF],B[BUF],C[BUF];


int main(void){
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
	for(int i=0;i<N;i++) cin >> C[i];

	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);
	long long ans = 0;

	for(int i=0;i<N;i++){
		int anum,cnum;
		long long *ite = lower_bound(A, A+N, B[i]);
		int index = ite - A;
		if(index==N) anum = N;
		else anum = ite - A ;
		
		ite = upper_bound(C,C+N, B[i]);
		index = ite - C;
		if(index==N) cnum = N;
		else cnum = ite - C;
	//	cout << anum << N-cnum  << "\n";
		ans += (long long)anum*(long long )(N-cnum);
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2560
/*
 * @Author: BilyHurington
 * @Date: 2020-05-23 19:57:55
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-05-23 20:41:35
 */ 
#include<bits/stdc++.h>
using namespace std;
int T;
long long cost[10];
long long n;
map<long long,long long> mp;
long long dfs(long long x){
    if(!x) return 0;
    if(mp.count(x)) return mp[x];
    long long tmp[6]={x/2,x/2+1,x/3,x/3+1,x/5,x/5+1},t[6]={2,2,3,3,5,5};
    long long ans=1e18;
    for(int i=0;i<6;i++) if(tmp[i]<x) ans=min(ans,dfs(tmp[i])+(long long)min((double)abs(tmp[i]-x)*cost[0],abs(tmp[i]*t[i]-x)*(double)cost[0]+cost[t[i]]));
    return mp[x]=ans;
}
int main(){
    scanf("%d",&T);
    while(T--){
        mp.clear();
        scanf("%lld %lld %lld %lld %lld",&n,&cost[2],&cost[3],&cost[5],&cost[0]);
        printf("%lld\n",dfs(n));
    }
    return 0;
}

Measured memory_bytes: 4936
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n,k;
  cin>>n>>k;
  vector<bool> ans(n,false);
  rep(i,k){
    int d;
    cin>>d;
    int a;
    rep(j,d){
      cin>>a;
      ans.at(a-1)="true";
    }
  }
  int sum=0;
  rep(i,n){
    if(!ans.at(i))
      sum++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3632
sx,sy,tx,ty=map(int,input().split())
ans='R'*(tx-sx)+'U'*(ty-sy)+'L'*(tx-sx)+'D'*(ty-sy)
ans+='D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'+'U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R'
print(ans)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>

using namespace std;

typedef unsigned long long ull;

int main()
{

  ios::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
  
  int N, K;
  cin >> N >> K;
  for (int i = K - N + 1; i <= K + N - 1; i++)	cout << i << " ";
  cout << endl;
  
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int S, W;
    cin >> S >> W;

    cout << (S > W ? "safe" : "unsafe") << endl;

    return 0;
}



Measured memory_bytes: 3128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	cout << (f - 30) / 2 << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll res = 0;
    while (true)
    {
        string s_copy(s.begin(), s.end());
        REP(i, s.length() - 1)
        {
            if (s[i] != s[i + 1])
            {
                s_copy.erase(s_copy.begin() + i);
                s_copy.erase(s_copy.begin() + i);
                res += 2;
                break;
            }
        }
        if (s == s_copy || s_copy.length() == 0)
        {
            break;
        }
        else
        {
            s = s_copy;
        }
        // dump(s);
        // dump(s_copy);
    }
    cout << res << endl;
    return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
int cnt[100001];
int ans = 0;

int main(){
    cin >> n;
    rep(i,n) {
        int a;
        cin >> a;
        if (a > n) {
            ans++;
            continue;
        }
        cnt[a]++;
    }
    for (int i = 1; i <= n; i++) {
        if (cnt[i] >= i) {
            ans += cnt[i] - i;
        } else {
            ans += cnt[i];
        }
    }
    cout << ans << endl;
}
































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

int main() {
    string s;
    cin >> s;
    
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        cnt += s[i] - '0';
    }
    if (cnt % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3756
/**
            ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀
            <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋>

    ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟
    ♔♕♖♗♘♙                             ♚♛♜♝♞♟
                ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙
**/

#include <bits/stdc++.h>

#define sz(s) s.size()
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 5;

int fl, sum;
long long dp[ 3 ][ 3 ], nw[ 3 ][ 3 ];
int mod = 998244353;

inline long long pw( int a, int b )
{
    long long res = 1;
    while( b-- )
        res *= a, res %= mod;
    return res % mod;
}

main()
{
    string s;
    cin >> s;
    for( int i = 1; i < sz(s); i++ )
    {
        if( s[i] != s[0] )
        {
            fl = 1;
            break;
        }
    }
    if( !fl )
    {
        puts("1");
        return 0;
    }
    if( sz( s ) == 2 )
    {
        cout << 2;
        return 0;
    }
    fl = 0;
    if( sz( s ) == 3 )
    {
        if( s[0] == s[2] )
            cout << 7;
        else if( s[0] != s[ 1 ] and s[ 0 ] != s[ 2 ] and s[ 1 ] != s[ 2 ] )
            cout << 3;
        else
            cout << 6;
        return 0;
    }

    dp[ 0 ][ 0 ] = 1;
    dp[ 1 ][ 1 ] = 1;
    dp[ 2 ][ 2 ] = 1;

    for( int i = 0; i < sz(s); i++ )
        sum += s[ i ] - 'a';

    sum %= 3;

    fl = 0;
    for( int i = 1; i < sz(s); i++ )
    {
        memset( nw, 0, sizeof( nw ) );
        if( s[i] == s[i - 1] )
            fl = 1;
        for( int j = 0; j < 3; j++ )
            for( int k = 0; k < 3; k++ )
                for( int f = 0; f < 3; f++ )
                    if( k != f )
                    {
                        nw[ ( j + f ) % 3 ][ f ] += dp[ j ][ k ];
                        nw[ ( j + f ) % 3 ][ f ] %= mod;
                    }

        swap( dp, nw );
    }

    long long ans = pw( 3, sz(s) - 1 );

    for( int i = 0; i < 3; i++ )
        ans -= dp[ sum ][ i ];

    ans += ( fl ? 0 : 1 );

    ans %= mod;

    if( ans < 0 ) ans += mod;

    cout << ans;
}







Measured memory_bytes: 644
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int m1 = H1 * 60 + M1;
    int m2 = H2 * 60 + M2;

    cout << m2 - m1 - K << endl;

    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
long long int a,b,k;
int main(){
  cin >> a >> b  >> k;
  if(a+2*k>=b+1){
    for(int i=a;i<=b;i++){
      cout << i << endl;
    }
    return 0;
  }
  for(int i=a;i<a+k;i++){
    cout << i << endl;
  }
  for(int i=b-k+1;i<=b;i++){
    cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
if N % 3 != 0:
    if any(a):
        print('No')
    else:
        print('Yes')
else:
    a.sort()
    a1 = set(a[:N//3])
    a2 = set(a[N//3:2*N//3])
    a3 = set(a[2*N//3:])
    if len(a1) == 1 and len(a2) == 1 and len(a3) == 1:
        if a1.pop()^a2.pop()^a3.pop() == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 90564
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x1 := nextInt()
	y1 := nextInt()
	x2 := nextInt()
	y2 := nextInt()

	dx := x2 - x1
	dy := y2 - y1

	fmt.Println(x2 - dy)
	fmt.Println(y2 + dx)
	fmt.Println(x1 - dy)
	fmt.Println(y1 + dx)

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T>
constexpr bool in(T min, T max, T t)
{
    return t >= min && t <= max;
}

template <class T>
constexpr bool nin(T min, T max, T t)
{
    return !in(min, max, t);
}

template <class T>
void ninDebug(T min, T max, T t)
{
    using namespace std;
    if (nin(min, max, t))
    {
        cout << "ERROR" << endl;
    }
}

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n, taro{}, hana{};
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        string s, t;
        cin >> s >> t;

        if (s > t)
            taro += 3;
        else if (s < t)
            hana += 3;
        else
        {
            taro += 1;
            hana += 1;
        }
    }

    cout << taro << " " << hana << endl;

    return 0;
}


Measured memory_bytes: 3224
limit=999999
prime=[0,1]+[0 if i%2==0 else 1 for i in range(3,limit+1)]
for i in range(3,int(limit**0.5)+1):
    if prime[i-1]==1:
        for j in range(i**2,limit+1,i):
            prime[j-1]=0
            
while True:
    try:
        n=int(input())
    except EOFError:
        break
    print(sum(prime[:n]))


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,M;
  cin >> N >> M;
  vector<vector<int>> v(N);

  for(int i = 0; i < M; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--; tmp2--;

    v.at(tmp1).push_back(tmp2);
    v.at(tmp2).push_back(tmp1);
  }

  queue<int> q;
  q.push(0);

  map<int,int> m;
  m[0] = 0;

  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(auto next: v.at(now)){
      if(m.count(next) == 0){
        m[next] = now;
        q.push(next);
      }
    }
  }


  if(m.size() < N){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for(auto x: m){
      if(x.first == 0){
        continue;
      } else { 
        cout << x.second + 1 << endl;
      }
    }

  }
}


Measured memory_bytes: 14444
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
using namespace std;
typedef long long ll;

void Main()
{
    ll x;
    cin >> x;

    ll yen = 100;
    int count = 0;
    while (yen < x)
    {
      
        yen = yen * 1.01;
        count++;

    }
    cout << count << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz=4e6+5;



 
  
int main() 
{ 
    // #ifndef ONLINE_JUDGE 
      
    //     // For getting input from input.txt file 
    //     freopen("input.txt", "r", stdin); 
      
    //     // Printing the Output to output.txt file 
    //     freopen("output.txt", "w", stdout); 
      
    // #endif 
 
    int t=1;
    // cin>>t;
    while(t--)
    {
        
        int n;
        cin>>n;
        if(n>=30)
        {
            cout<<"Yes";

        }
        else
            cout<<"No";


 
    }
    return 0; 
} 

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

#define REP(I, B, E) for (int I = (B); (I) < (E); (I)++)
#define ARRAY_LEN(A) ((long long)(sizeof((A)) / sizeof(*(A))))

int compare_int(int l, int r) {
    if (l < r) {
        return -1;
    }
    if (l > r) {
        return 1;
    }
    return 0;
}

typedef struct City {
    char S[11];
    int P;
    int i;
} City;

int compare_city(const City *l, const City *r) {
    int ord = strcmp(l->S, r->S);
    if (ord != 0) {
        return ord;
    }

    ord = compare_int(r->P, l->P); // 逆順
    if (ord != 0) {
        return ord;
    }

    return compare_int(l->i, r->i);
}

int compare(const void *l, const void *r) {
    return compare_city((const City *)l, (const City *)r);
}

City cities[101];

int main(void) {
    int N;
    scanf("%d", &N);

    REP(i, 0, N) {
        char S[11];
        int P;
        scanf("%10s %d", S, &P);

        strcpy(cities[i].S, S);
        cities[i].P = P;
        cities[i].i = i;
    }

    qsort(cities, N, sizeof(City), compare);

    REP(i, 0, N) {
        printf("%d\n", cities[i].i + 1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int m;
	int i;
	int a, b;
	
	for (i = 0; i < 4; i++){
		scanf("%d %d", &a, &b);
		if (a == 1){
			m = 6000 * b;
		}
		
		else if (a == 2){
			m = 4000 * b;
		}
		else if (a == 3){
			m = 3000 * b;
		}
		else if (a == 4){
			m = 2000 * b;
		}
		printf("%d\n", m);
	}

	return (0);
}

Measured memory_bytes: 600
#include <stdio.h>

int main(){

    int i=0;
    int x[9999];


    do{
        scanf("%d",&x[i]);
        
        if(x[i] == 0){
            break;
        }

        i++;

    }while(i < 100000);

    i = 0;
    do{
        if(x[i] != 0){
            printf("Case %d: %d\n",i+1,x[i]);
        }else{
            break;
        }

        i++;

    }while(i < 100000);

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

using ll = long long;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

using graph = vector< vector< int > >;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    graph G(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dir(N + 1, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dir[1] = 1;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dir[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dir[nv] = v;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
	cout << "Yes" << endl;
    for (int v = 2; v < N + 1; v++) cout << dir[v] << endl;
}

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

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

    vector<pair<int,int>> pairs(n);

    int j; 

    for(int i=0; i<n; i++){
        int a; cin>>a;
        pairs[i] = make_pair(a,i+1);
    }

    sort(pairs.begin(),pairs.end());

    for(int i=0; i<n; i++){
        cout<<pairs[i].second<<" ";
    }

    cout<<endl;
    return 0;
}

Measured memory_bytes: 1664
H, W = list(map(int, input().split()))
a = []
h = []
w = []
aa = ''

for i in range(H):
    a_ = input()
    aa += a_
    a.append(a_)
    if '#' in a_:
        h.append(i)

for i in range(W):
    if '#' in aa[i::W]:
        w.append(i)
        
for i in range(H):
    if i not in h:
        continue
    flag = False
    for l in range(W):
        if l in w:
            print(a[i][l], end='')
            flag = True
    if flag == True:
        print('')


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

#define N 100

int main(void){

  int n, A[N];
  int i, j, key;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    if(i) printf(" %d",A[i]);
    else  printf("%d", A[i]);
  }
  printf("\n");

  for(i=1; i<n; i++){
    key=A[i];
    j=i-1;

    while(j >= 0 && A[j] > key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;

    for(j=0; j<n; j++){
      if(j) printf(" %d", A[j]);
      else  printf("%d", A[j]);
    }
    printf("\n");
  }
  
  return 0;
}



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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

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

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> H(N);
	for(ll i = 0 ; i < N ; i++){
		scanf("%lld",&H[i]);
	}
	unordered_set<ll> s;
	vector<ll> g(N);
	vector<int> good(N, 0);
	for (ll i = 0; i < N; ++i)
	{
		g[i] = i;
	}
	for(ll i = 0 ; i < M ; i++){
		ll a, b;
		cin >> a >> b;
		s.insert(a - 1);
		s.insert(b - 1);
		if (H[a - 1] > H[b - 1])
		{
			g[b - 1] = a;
			good[b - 1] = -1;
		}
		else if (H[a - 1] < H[b - 1])
		{
			g[a - 1] = b;
			good[a - 1] = -1;
		}
		else
		{
			good[a - 1] = -1;
			good[b - 1] = -1;
		}
	}
	for (ll i = 0; i < N; ++i)
	{
		if (s.find(i) == s.end())
		{
			good[i] = 1;
		}
	}

	for (ll i = 0; i < N; ++i)
	{
		if (good[i] < 0)	continue;
		if (g[i] == i)
		{
			good[i] = 1;
		}
	}

	ll sum = 0;
	for (ll i = 0; i < N; ++i)
	{
		if (good[i] > 0)
		{
			// cerr << i << endl;
			++sum;
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 8888
#include<bits/stdc++.h>
using namespace std;
long long C(int a,int b){
	double s=1;
	for(int i=1;i<=b;i++){
		s*=(i+a-b);
		s/=i;
	}
	return s;
} 
int main() {
	int n,m;
	cin>>n>>m;
	cout<<C(n,2)+C(m,2);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>


const long long MOD_CONST = 1000000007;


using namespace std;

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

	a.emplace_back(n + 1);
	
	

	vector<int> fibo(n+1);
	fibo[0] = 1;
	fibo[1] = 1;
	for (int i = 2;i <=n; i++) {
		fibo[i] = (fibo[i - 2] + fibo[i-1]) % MOD_CONST;
	}

	long long ans = 1;
	int pos = 0;
	for (int i = 0; i < m; i++) {
		
		if (a[i] == a[i+1] - 1) {
			ans *= 0;
			break;
		}
		
		ans = (ans*fibo[a[i]-1-pos]) % MOD_CONST;
		
		pos = a[i] + 1;
	}

	ans = (ans*fibo[n - pos]) % MOD_CONST;
	
	cout << ans << endl;

}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble();
		double m = sc.nextDouble();
		List<Double> list = new ArrayList<>();
		double sum = 0;
		for (int i = 0; i < n; i++) {
			double in = sc.nextDouble();
			list.add(in);
			sum += in;
		}
		sc.close();

		double m1 = sum / (4 * m);
		double count = 0;
		for (double i : list) {
			if (i >= m1) {
				count += 1;
			}
		}
		if (count >= m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
/*
void solve(){
  ll n; cin >> n;
  vector<ll> prime;
  FOR(i,2,(1000006)){
    bool flg = true;
    
    if(flg) prime.push_back(i);
  }
}
*/
/*
void solve(){
  int n; cin >> n; int ans =0;
  if(n<10) {cout << n; return;}
  priority_queue<
      int,                // 要素の型はint
      std::vector<int>,   // 内部コンテナはstd::vector (デフォルトのまま)
      std::greater<int>   // 昇順 (デフォルトはstd::less<T>)
    > qb, qa;
  FOR(i,1,10000000){
    string s = std::to_string(i);
    bool flg=true;
    FOR(j,0,s.size()-1){
      if(abs(s[j]-s[j+1])>1) {flg=false; break;}
    }
    if(flg) ans++;
    if(ans==n) {cout << i; return;}
  }
  cout << ans << endl;
}*/
/*
void solve(){
  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
}*/
template <class T> std::vector<T> divisors(const T &n) {
  std::vector<T> ret;
  T i = static_cast<T>(1);
  while (i * i < n) {
    if (n % i == static_cast<T>(0)) {
      ret.push_back(i);
      ret.push_back(n / i);
    }
    ++i;
  }
  if (i * i == n) {
    ret.push_back(i);
  }
  std::sort(ret.begin(), ret.end());
  ret.shrink_to_fit();
  return std::move(ret);
}


template<class T> struct prime{
  T N;
  vector<T> v;
  void init(const T &n){
    N = n;
    T i = static_cast<T>(2);
    while(true);
  }
};


void solve(){
  ll n; cin >> n;
  size_t ans = 0;
  for (const ll k : divisors(n)) {
    if (k == 1)
      continue;
    ll m = n;
    while (m % k == 0) {
      m /= k;
    }
    if (m % k == 1) {
      ans += 1;
    }
  }
  ans += divisors(n - 1).size();
  std::cout << ans - 1 << std::endl;
}

void solve2(){
  int n, k, c;
  cin >> n >> k >> c;
  string s; cin >> s;
  vector<int> L(k+5), R(k+5);
  int cnt = 0, bf=-987654321;
  FOR(i,0,n){
    if(s[i]=='o' && (i-bf)>c) {bf = i; L[cnt] = i; cnt++;}
    if(cnt==k) break;
  }
  bf = 987654321; cnt = k-1;
  IFOR(i,0,n){
    if(s[i]=='o' && (bf-i)>c) {bf = i; R[cnt] = i; cnt--;}
    if(cnt==-1) break;
  }
  FOR(i,0,k){
    if(L[i]==R[i])  cout << (L[i]+1) << '\n' ;
  }
}

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

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int dp[1<<20];
int rsk[21][100002]={0};
int main(void){
	int n,m;
	int i,j,k;
	int box[100000];
	int kind[21]={0};
	int now,now_kazu;
	int next,next_kazu;
	int cost,cost_before;
	int cnt;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>box[i];
		kind[box[i]-1]++;
		rsk[box[i]-1][i+1]++;
	}
	// for(i=0;i<m;i++)	cout<<kind[i]<<" ";	cout<<endl;
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			rsk[i][j+1]+=rsk[i][j];
		}
	}
	// for(i=0;i<m;i++){
		// for(j=0;j<=n;j++){
			// cout<<rsk[i][j]<<" ";
		// }
		// cout<<endl;
	// }
	for(i=0;i<1<<m;i++)	dp[i]=INT_MAX;
	dp[0]=0;
	for(i=0;i<(1<<m)-1;i++){
		now=i;
		// printf("now=%d\n",now);
		for(j=0;j<m;j++){
			next=(1<<j);
			// printf("next=%d\n",next);
			if((now&next)==0){
				// printf("now=%d next=%d\n",now,next);
				now_kazu=0;
				next_kazu=0;
				for(k=0;k<m;k++){
					// printf("k=%d 1<<k=%d kind[k]=%d\n",k,1<<k,kind[k]);
					if((now&(1<<k))!=0)		now_kazu+=kind[k];
					if((next&(1<<k))!=0)	next_kazu+=kind[k];	
				}
				next_kazu+=now_kazu;
				// printf("now_kazu=%d next_kazu=%d\n",now_kazu,next_kazu);
				cost=0;
				for(k=0;k<m;k++){
					if(j!=k)	cost+=rsk[k][next_kazu]-rsk[k][now_kazu];
				}
				cost_before=0;
				if(dp[now]!=INT_MAX)	cost_before+=dp[now];
				// printf("coming\n");
				// printf("now|next=%d mix=%d cost=%d cost_before=%d\n",now|next,cost+cost_before,cost,cost_before);
				dp[now|next]=min(dp[now|next],cost+cost_before);
				// for(int l=0;l<(1<<m);l++){
					// cout<<dp[l]<<" ";
				// }
				// cout<<endl;
			}
		}
		// printf("\n");
	}
	cout<<dp[(1<<m)-1]<<endl;
	return 0;
}	


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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,0,s.size()){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;

    
    return 0;
}

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

using namespace std;

typedef long long ll;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main()
{
#ifdef iq
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.size();
    int block_len = 0;
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
            block_len++;
            continue;
        }
        if (s[i] == 'A') {
            ans += block_len;
        }
        if (s[i] == 'B' || (s[i] == 'C' && i && s[i - 1] != 'B')) {
            block_len = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (((x)<0)?(x)%mo_num+mo_num:(x)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define SET set<int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<(x)<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4,SINF=0x3f;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//down up left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;
int p[maxn];
int Find(int x){return p[x]==x?p[x]:p[x]=Find(p[x]);}
void solve()
{
    cin>>n>>m;
    fun(i)p[i]=i;
    fum(i)
    {
        int u,v;
        cin>>u>>v;
        int Fu=Find(u),Fv=Find(v);
        if(Fu==Fv)continue;
        ans++;
        p[Fu]=Fv;
    }
    out(n-1-ans)
    return ;
}
main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)solve();
    return 0;
}


Measured memory_bytes: 4404
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
const int MAX_N=100000;
 
int N;
int A[MAX_N];
 
long long sum[MAX_N*2];
 
int main(){
    scanf("%d",&N);
    int i;
    for (i=0;i<N;i++){
        scanf("%d",A+i);
    }
    sum[0]=A[0];
    for (i=1;i<N;i++){
        sum[i]=sum[i-1]+A[i];
    }
    for (i=N;i<2*N;i++){
        sum[i]=sum[i-1]+A[i-N];
    }
    long long ans=0;
    int s,t;
    s=0;
    t=0;
    long long a=0,b,c;   //s-t間のバームクーヘン
    while (s<N){
        long long *p;
        do{
            while (a<=ans){
                t++;
                a+=A[(t-1)%N];
            }
            //aがansを更新できるか
            p=lower_bound(sum+t,sum+s+N-1,a+sum[t-1]);
            if (p!=sum+s+N-1){
                //見つかった
                b=*p-sum[t-1];
                c=sum[N-1]-b-a;
                if (c>=a){
                    //aが最小値
                    ans=a;
                }
                else{
                    break;
                }
            }
        }while (p!=sum+s+N-1);
        s++;
        a=sum[t-1]-sum[s-1];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4712
import math

def s(number):
    if number <= 2:
        return 0
    for i in range(2,math.floor(math.sqrt(number))+1):
        if number % i == 0:
            return 0
    for i in range(2,math.floor(math.sqrt((number+1)//2))+1):
        if ((number+1)//2) % i == 0:
            return 0
    return 1

num = [s(i) for i in range(1,10 ** 5+1)]
li = [0]
for nu in num:
    li.append(li[-1]+nu)

q = int(input())

for _ in range(q):
    l,r = map(int,input().split())
    print(li[r]-li[l-1])

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[50];
    int b[50];
    
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    
    rep(i, n) {
        int cnt = 0;
        
        rep(ii, m) {
            if (a[ii] == i) {
                cnt++;
            }
            
            if (b[ii] == i) {
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

# 優先度付きキュー
# 優先度とフラグを入れ込んだキューで、優先度が大きいものからポップできる
# 優先度が小さいものとする場合は、マイナスでキューにプッシュする
# hp キュー
# hist フラグの履歴（一度読んだものは再度使わない場合）

from heapq import heapify, heappop, heappush, heappushpop

def main():
    N, M = map(int, input().split())
    S = {}
    for i in range(N):
        a,b = map(int,(input().split()))
        if a in S.keys():
            S[a].append((-b,a))
        else:
            S[a]=[(-b,a)]
    hp = []
    heapify(hp)
    ret = 0
    for i in range(1,M+1):
        if i in S:
            for jb in S[i]:
                heappush(hp, jb)
        if len(hp)==0:
            continue
        x = heappop(hp)
        ret += -x[0]
    print(ret)

if __name__ == '__main__':
    main()

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

int main(){
	int N;
	cin >> N;
	ll A[N];
	for(int i=0; i<N; i++){
		cin >> A[i];
		A[i] -= i+1;
	}
	sort(A, A+N);
	if(N%2 == 0){
		ll a = 0, b = 0;
		for(int i=0; i<N; i++){
			a += abs(A[i] - A[(N/2) - 1]);
		}
		for(int i=0; i<N; i++){
			b += abs(A[i] - A[N/2]);
		}
		cout << min(a, b) << endl;
	}else{
		ll a = 0;
		for(int i=0; i<N; i++){
			a += abs(A[i] - A[N/2]);
		}
		cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
char c[999];s,i;
main(){
	gets(c);
	s=strlen(c)-1>>1;
	for(;;s--){
		int l=1;
		for(i=0;i<s;i++)l&=c[i]==c[s+i];
		if(l)break;
	}
	printf("%d",s*2);
}


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

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

long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    return a / g * b;
}

int main() {
    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    long long cnt_C_A = A / C, cnt_D_A = A / D;
    long long cnt_C_B = B / C, cnt_D_B = B / D;
    long long lcm_CD = lcm(C, D);
    long long cnt_CD_A = A / lcm_CD, cnt_CD_B = B / lcm_CD;

    long long cnt = (cnt_C_B - cnt_C_A) + (cnt_D_B - cnt_D_A) - (cnt_CD_B - cnt_CD_A);

    if (A % C == 0 || A % D == 0) {
        cout << (B - A) - cnt << endl;
    } else {
        cout << (B - A + 1) - cnt << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdlib.h>
#include <numeric>
#include <cmath>
#include <iomanip>
#define mod 1000000007
typedef unsigned long long int ll;
using namespace std;





int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin>>n;
    vector<double> a;
    for(int i=0;i<n;i++)
    {
       int temp;
       cin>>temp;
       double d=1.0/temp;
       a.push_back(d);
    }
    double result=accumulate(a.begin(),a.end(),0.0);
    cout<<(1.0/result)<<"\n";
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	cin>>s;
	
	bool ans=true;
	if(s.size()%2){
		ans=false;
	}else{
		string key="hi";
		for(int i=0;i<s.size();i+=2){
			string tmp=s.substr(i,2);
			if(tmp=="hi"){}
			else{
				ans=false;
				break;
			}
		}
	}
	
	cout<<((ans)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  int cnt = 0;
  char cur = 'A';
  REP(i, 0, s.length()) {
    if (cur != 'A' && cur != s[i]) {
      cnt++;
    }
    cur = s[i];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
object Main extends App{
    // Your code here!
    
    var s = io.StdIn.readLine
    var r = s.reverse
    var count = 0;
    for (i <- 0 until r.size / 2) {
        if (s(i) != r(i)) {
            count = count + 1
        }
    }

    println(count)
}


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

using namespace std;

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  for(int i = 0; i < N; i++)cin >> x[i];
  vector<int> y(M);
  for(int i = 0; i < M; i++)cin >> y[i];
  
  int minx = 100000 ,miny = 100000, maxx = -100000, maxy = -100000;
  for(int i = 0; i < N; i++){
    minx = min(x[i],minx);
    maxx = max(x[i],maxx);
  }
  for(int i = 0; i < M; i++){
    miny = min(y[i],miny);
    maxy = max(y[i],maxy);
  }
  string s = "";
  bool f = false;
  for(int i = X+1; i <= Y; i++){
    if(maxx < i && i <= miny) f = true;
  }
  if(f) s = "No War";
  else s = "War";
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200000;
int a[maxn+5];
int b[maxn+5];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	
		for(int i=1;i<=n;i++){
			if(a[i]<=b[n/2]){
				cout<<b[n/2+1]<<endl;
			}else if(a[i]>b[n/2]){
				cout<<b[n/2]<<endl;
			}
		}
	
	return 0;
} 

Measured memory_bytes: 3712
import string
numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets

def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
 
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

def main():
    n, k = map(int, input().split())

    ans = len(base_cvt(n,k))
    
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
    int N;  cin >> N;
    vector<int> V(N,0), C(N,0);
    for(int i=0; i<N; i++) cin >> V[i];
    for(int i=0; i<N; i++) cin >> C[i];

    int ans = 0;
    for(int i=0; i<N; i++){
        ans += max(0, V[i]-C[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
*A, = map(int, input().split())
C = {i: 0 for i in range(1, 10**5 + 1)}
for a in A:
    C[a] += 1
s = sum(A)
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    tmp = C[b]
    C[b] = 0
    C[c] += tmp
    s += (c - b) * tmp
    print(s)


Measured memory_bytes: 24452