akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int win = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'o'){
            win++;
        }
    }
    cout << ((15 - s.size() + win >= 8) ? "YES" : "NO") << endl; 
}


Measured memory_bytes: 256
N,Q =map(int,input().split())
S = input()
t = [0]* (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
    l,r =map(int,input().split())
    print(t[r-1]-t[l-1])


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

int used[1000005];
// �񐔂̗�O(n^(1/2))
vector<ll> divisor(ll n){
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}


int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N)cin >> A[i];
    
    
    sort(ALL(A));
    int ans = 0;
    rep(i, N){
        if (i < N - 1 && A[i] == A[i + 1]){
            ans++;
            used[A[i]]++;
            continue;
        }
        vector<ll> divs = divisor(A[i]);
        rep(j, divs.size()){
            //fprintf(stderr, "%d, %d\n", A[i], divs[j]);
            if (used[divs[j]]){
                ans++;
                //fprintf(stderr, "hit\n");
                break;
            }
        }
        used[A[i]]++;
    }
    cout << N - ans;
    return 0;
 
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

struct union_find
{
	vector<int> p;

	union_find(int n) : p(n, -1) {}

	bool join(int u, int v)
	{
		if ((u = root(u)) == (v = root(v)))
			return false;
		if (p[u] > p[v])
			swap(u, v);
		p[u] += p[v];
		p[v] = u;
		return true;
	}

	// be careful with compression path when you can't use it (example: for undo)
	int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); }
	int size(int u) { return -p[root(u)]; }
};

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

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

	union_find uf(n);
	vector<vector<int>> f(n), b(n);
	for (int i = 0, u, v; i < m; ++i)
	{
		cin >> u >> v;
		--u, --v;
		f[u].push_back(v);
		f[v].push_back(u);
		uf.join(u, v);
		debug(u, v);
	}

	for (int i = 0, u, v; i < k; ++i)
	{
		cin >> u >> v;
		--u, --v;
		if (uf.root(u) != uf.root(v)) continue;
		b[u].push_back(v);
		b[v].push_back(u);
	}

	vector<int> ans(n);
	for (int i = 0; i < n; ++i)
	{
		ans[i] = uf.size(i) - 1;
		debug(i, ans[i]);
		set<int> s;
		for (auto v : f[i]) s.insert(v);
		for (auto v : b[i]) s.insert(v);
		s.erase(i);
		debug(i, s);
		ans[i] -= s.size();
	}

	for (auto &i : ans)
		cout << i << " \n"[&i==&ans.back()];

	return 0;
}


Measured memory_bytes: 17272
A,B = map(int, input().split())
import fractions
f=fractions.gcd(A,B)#最大公約数
def factorization(n):
  primen = []
  degree = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primen.append(i)
      degree.append(cnt)
  if temp!=1:
    primen.append(temp)
    degree.append(1)
  if primen==[]:
    primen.append(n)
    degree.append(1)
  return primen,degree
if f != 1:
  ans = factorization(f)
  print(len(ans[1])+1)
else:
  print(1)

Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll mod=1000000007;
int main(){
    int n;
    string s[2];
    cin>>n;
    cin>>s[0]>>s[1];
    int cur=0;
    ll sum;
    bool flag=true;
    if(s[0][cur]==s[1][cur]){
        cur=1;sum=3;
    }
    else{
        cur=2;sum=6;flag=false;
    }
    while(cur<n){
        if(s[0][cur]==s[1][cur]){
            if(flag){
                sum=(sum*2)%mod;
                ++cur;
                }
            else{
                ++cur;flag=true;
            }
        }
        else{
            if(flag){
                sum=(sum*2)%mod;
                cur+=2;flag=false;
            }
            else{
                sum=(sum*3)%mod;
                cur+=2;
            }
        }
    }
    cout<<sum%mod<<endl;
    return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};
//vector<int> dy = {1, 1, 1, 0, -1, -1, -1, 0};
//vector<int> dx = {1, 0, -1, -1, -1, 0, 1, 1};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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


int main(){
  int N; cin >> N;
  vector<ll> p(N); rep(i, N) cin >> p[i];
  ll cnt = 0;
  rep(i, N - 2){
    ll a = p[i], b = p[i+1], c = p[i+2];
    if(a < b && b < c) cnt++;
    else if(c < b && b < a) cnt++;
  }
  cout << cnt << endl;



}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int max = 0;
    int d = 0;
    int first = sc.nextInt();
    int prev = first;
    int next = 0;
    for(int i = 0; i < n-1; i++){
      next = sc.nextInt();
      d = next - prev;
      if(max < d){
        max = d;
      }
      prev = next;
    }
    int b = k - next + first;
    if(max < b){
      max = b;
    }
    System.out.println(k-max);
  }
}

Measured memory_bytes: 64748
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

cnt = 0
dp_table = [0 for i in range(n + 10)]
dp_table[0] = 1
dp_table[1] = 1

for i in range(m):
    dp_table[a[i]] = -10 ** 9 + 7

for i in range(2, n + 10):
    if dp_table[i] > -1:
        dp_table[i] = (max(dp_table[i - 1], 0) + max(dp_table[i - 2], 0)) % (10 ** 9 + 7)

print(dp_table[n])


Measured memory_bytes: 7856
boardLine w dict =
  take w dict

drawBoardLine 0 _ _ = do return ()
drawBoardLine h w dict = do
  putStrLn (boardLine w dict)
  drawBoardLine (h-1) w (tail dict)

drawChess h w = do
  let inf = cycle ['#','.']
  drawBoardLine h w inf
  putStrLn ""

main = do
  ln <- getLine
  let [h, w] = map read $ words ln :: [Int]
  if h == 0 && w == 0 then
    return ()
  else do
    drawChess h w
    main

Measured memory_bytes: 4172
#include<stdio.h>
#include<string.h>

int main()
{
	char w[20], t[20];
	int counter = 0, i, flag;

	scanf("%s", w);
	while (1)
	{
		i = 0;
		flag = 0;
		scanf("%s", t);
		while (t[i] == w[i] || t[i] == w[i] + 32 || t[i] + 32 == w[i])
		{
			if (t[i] == '\0')
			{
				flag = 1;
				break;
			}
			i++;
		}
		if (flag)
			counter++;
		if (!strcmp(t, "END_OF_TEXT"))
			break;
	}

	printf("%d\n", counter);

	return 0;
}


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

int main() {
  int a = 0;
  string s;
  cin >> s;
  if(s.at(0) == 'o')
    a++;
  if(s.at(1) == 'o')
    a++;
  if(s.at(2) == 'o')
    a++;
  cout << 700 + 100 * a << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  puts(c % gcd(a, b) ? "NO" : "YES");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;

class Graph {
    int n;
    vector<vector<pair<int, double>>> adj;
    vector<double> d;
    vector<double> de;
    bool negLoop = false;
    
public:
    Graph(int n) {
        this->n = n;
        adj = vector<vector<pair<int, double>>>(n, vector<pair<int, double>>());
    }
    void addArc(int a, int b, double w) {
        adj[a].push_back(make_pair(b, w));
    }
    
    void addEdge(int a, int b, double w) {
        adj[a].push_back(make_pair(b, w));
        adj[b].push_back(make_pair(a, w));
    }
    
    void bf(int a) {
        d = vector<double>(n, INF);
        de = vector<double>(n);
        d[a] = 0;
        vector<pair<P, double>> edges;
        REP(i,n) {
            for (auto j: adj[i]) {
                edges.push_back(make_pair(P(i,j.first), j.second));
            }
        }
        int loopcnt = 0;
        while (1) {
            loopcnt++;
            bool update = false;
            for (auto e: edges) {
                if (d[e.first.first] != INF && d[e.first.second] > d[e.first.first] + e.second) {
                    if (loopcnt < n) de[e.first.second] = d[e.first.first] + e.second;
                    d[e.first.second] = d[e.first.first] + e.second;
                    update = true;
                }
            }
            if (!update) break;
            if (loopcnt == n) {
                negLoop = true;
                break;
            }
        }
    }
    
    bool hasNegLoop() {
        return negLoop;
    }
    
    bool hasNegLoop(int a) {
        return d[a] != de[a];
    }
    
    void dijkstra(int a) {
        d = vector<double>(n, INF);
        d[a] = 0;
        priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q;
        q.push(make_pair(0, a));
        
        while (!q.empty()) {
            int u = q.top().second;
            q.pop();
            
            for (auto i: adj[u]) {
                if (d[i.first] > d[u] + i.second) {
                    d[i.first] = d[u] + i.second;
                    q.push(make_pair(d[i.first], i.first));
                }
            }
        }
    }
    
    double dist(int a) {
        return d[a];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    Graph g(n);
    int a, b, c;
    REP(i,m) {
        cin >> a >> b >> c;
        a--;
        b--;
        g.addArc(a, b, -c);
    }
    g.bf(0);
    if (g.hasNegLoop(n-1)) {
        cout << "inf" << endl;
        return 0;
    }
    cout << - long(g.dist(n-1)) << endl;
}


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

public class Main {

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

        int x=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();

        if(b<=a){
            System.out.println("delicious");
        }else if(b<=a+x){
            System.out.println("safe");
        }else{
            System.out.println("dangerous");
        }
    }



}

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

using namespace std;

int main()
{
    int n,mx=0;
    cin>>n;
    string s;
    map<string,int>m;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
        mx=max(mx,m[s]);
    }
    for (map<string,int>::iterator it=m.begin();it!=m.end();it++)
        if (it->second==mx)
        cout<<it->first<<'\n';
    return 0;
}


Measured memory_bytes: 25216
N=int(input())
A=[int(i) for i in input().split()]
if N==1:
    print(1)
    exit()
T=[[A[0],A[1]]]
k=0
for i in range(2,N):
    if len(T[k])<=1:
        T[k].append(A[i])
        continue
    if not((T[k][0]>=A[i-2]>=A[i-1]>=A[i]) or (T[k][0]<=A[i-2]<=A[i-1]<=A[i])):
        k+=1
        T.append([A[i]])
    else:
        T[k].append(A[i])
print(len(T))


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

int main() {
  int a,b;
  cin >> a >> b;
  if (a +  b == 3) {
    cout << "3" << endl;
  }
  else if (a + b == 4) {
    cout << "2" << endl;
  }
  else {
    cout << "1" << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
  ll num=0;
  ll nagasa;
  ll longest=0;
  ll N;
  cin>>N;
  for(ll i=0;i<N;i++){cin>>nagasa;num+=nagasa;longest=max(longest,nagasa);}
  if(num-longest>longest) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
vector<int> vertexs[300];
int visited[300] = {};
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	REP(i, n) {
		string a;
		cin >> a;
		REP(q, a.length()) {
			if (a[q] == '1') {
				vertexs[i].push_back(q);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (visited[i] != 0) continue;
		visited[i] = 1;
		queue<int> next_go;
		stack<int> going;
		next_go.push(i);
		while (next_go.empty() == false) {
			int now = next_go.front();
			next_go.pop();
			going.push(now);
			REP(q, vertexs[now].size()) {
				int go = vertexs[now][q];
				if (visited[go] == 0) {
					visited[go] = visited[now] + 1;
					next_go.push(go);
				}
			}
		}
		vector<int> kouhos;
		while (going.empty() == false) {
			int hoge = going.top();
			going.pop();
			kouhos.push_back(hoge);
			visited[hoge] = 0;
		}
		int now_max = 0;
		REP(q,kouhos.size()){
			REP(j, kouhos.size()) {
				visited[kouhos[j]] = 0;
			}
			next_go.push(kouhos[q]);
			visited[kouhos[q]] = 1;
			while (next_go.empty() == false) {
				int now = next_go.front();
				next_go.pop();
				REP(q, vertexs[now].size()) {
					int go = vertexs[now][q];
					if (visited[go] == 0) {
						visited[go] = visited[now] + 1;
						next_go.push(go);
					}
					else {
						if (abs(visited[now] - visited[go]) != 1) {
							cout << -1 << endl;
							return 0;
						}
					}
				}
				now_max = max(now_max, visited[now]);
			}
		}
		ans += now_max;
	}
	cout << ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a) //追加//
#define pp() pop_back() //削除//
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

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

  V<double> p(n);
  fo(i,n){
    cin>>p[i];
  }

  double q[n+1];
  q[0]=0;
  for(int i=1; i<=n; i++){
    q[i]=p[i-1]+q[i-1];
  }

  double ans=0;
  double a=0;
  for(int i=k; i<=n; i++){
    a=q[i]-q[i-k];
    ans=max(ans,a);
  }
  double b=ans/2+0.5*k;
  cout<<yuko(14)<<b<<endl;
}

Measured memory_bytes: 3328
n, k = [int(i) for i in input().split()]
p = 10 ** 9 + 7

kk = [1]
for i in range(1, 2 * n + 1):
    kk.append(kk[i-1]*i % p)


def kai(x, p=p):
    if kk[x] != -1:
        return kk[x]
    a = 1
    for i in range(1, x + 1):
        a *= i
        a %= p
    kk[x] = a
    return a


def comb(a, b, p=p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


ans = 0
if k >= n:
    print(comb(2 * n - 1, n))
else:
    for i in range(k+1):
        ans += comb(n-1, i) * comb(n, i)

        ans %= p
    print(ans)


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string N;
    cin >> N;
    char last = N[N.size()-1];
    if (last == '2' || last == '4' || last == '5' || last == '7' || last == '9'){
        cout << "hon" << "\n";
    } else if (last == '0' || last == '1' || last == '6' || last == '8'){
        cout << "pon" << "\n";
    } else {
        cout << "bon" << "\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int a,n;
    cin >> n;;
    rep(i,n){
        cin >> a;
        if(a%2==0 and a%3!=0 and a%5!=0){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
}

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

for i in range(4, N + 1, 4):
    d = N % i
    if d == 0:
        print("Yes")
        exit()

    if d % 7 == 0:
        print("Yes")
        exit()

for i in range(7, N + 1, 7):
    d = N % i
    if d == 0:
        print("Yes")
        exit()

    if d % 4 == 0:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int N, M;
	cin >> N >> M;

	int ans = 0;
	if (N >= 2) {
		ans += N * (N - 1) / 2;
	}
	if (M >= 2) {
		ans += M * (M - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}



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

int main(){
    auto f = [](int i)->int{
        return i%100 + i/100*60;
    };
    int n, p, q;
    while(cin >> n >> p >> q, n+p+q){
        p = f(p), q = f(q);
        vector<int> imos(q-p+1, 0), a(q-p+1, 0);
        for(int i = 0; i < n; i++){
            int k;  cin >> k;
            while(k-- > 0){
                int from, to;
                cin >> from >> to;
                from = f(from), to = f(to);
                from -= p, to -= p;
                imos[from]++;
                imos[to]--;
            }
        }
        for(int i = 1; i < q-p+1; i++)  imos[i] += imos[i-1];
        for(int i = 0; i < q-p+1; i++)  imos[i] = (imos[i] < n);
        int ans = imos[0];
        if(imos[0] == 1)    a[0] = 1;
        for(int i = 1; i < q-p; i++){
            if(imos[i]) a[i] = a[i-1]+1;
            ans = max(ans, a[i]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

int n, k;
string s[2005], ans;
bitset <10001> ok[2005];
bitset <10001> dp[2005];

int z[10005];
void do_z(string s){
    memset(z, 0, sizeof(z));

    int L = s.size();
    for(int i = 1, last = 0, right = 0; i < L ; ++i){
        if(i <= right) z[i] = min(right - i + 1, z[i - last]);

        while(i + z[i] < L && s[z[i]] == s[i + z[i]]) ++z[i];
        if(i + z[i] - 1 > right) right = i + z[i] - 1, last = i;
    }
}

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

    cin >> n >> k;
    for(int i = 1; i <= n ; ++i) cin >> s[i];

    ok[n + 1][0] = true;
    for(int i = n; i >= 1 ; --i){
        ok[i] = ok[i + 1];
        ok[i] = ok[i] | (ok[i + 1] << (s[i].size()));
    }

    dp[0][0] = 1;
    for(int i = 1; i <= n ; ++i){
        do_z(s[i] + ans);

        dp[i] = dp[i - 1];
        int L = s[i].size();
        for(int j = L; j - L <= ans.size() && j <= k ; ++j){
            if(dp[i - 1][j - L] == false || ok[i + 1][k - j] == false) continue ;

            int aux = z[j];
            if(aux >= L){
                dp[i][j] = true;
                continue ;
            }

            if(j - L == ans.size() || s[i][aux] < ans[j - L + aux]){
                ans = ans.substr(0, j - L) + s[i];
                for(int t = j - L + aux + 1 ; t <= k ; ++t) dp[i][t] = false;
                dp[i][j] = true;
                break ;
            }

        }
    }

    cout << ans;

    return 0;
}












Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  double r;
  cin>>r;
  cout<<(r+r)*3.141592<<'\n';
  return(0);
}


Measured memory_bytes: 3804
import java.util.Scanner;

public class Main {
	static boolean memo[];
	static boolean ok;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((a + b) % 2 == 0) {
			System.out.println((a + b) / 2);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 21972
from collections import deque
 
h,w=map(int,input().split())
ch,cw=map(int,input().split())
ddh,ddw=map(int,input().split())
s=[[c for c in input()] for _ in range(h)]

q=deque([(ch-1,cw-1,0)])
visit=[[0]*w for _ in range(h)]

while len(q)>0:
    uh,uw,cnt=deque.popleft(q)
    if visit[uh][uw]==1:
        continue

    stack=[(uh,uw)]
    stack2=[(uh,uw)]
    while len(stack)>0:
        vh,vw=stack.pop()

        visit[vh][vw]=1

        if vh==ddh-1 and vw==ddw-1:
            print(cnt)
            exit(0)

        for dh,dw in ((0,1),(0,-1),(1,0),(-1,0)):
            nh=vh+dh
            nw=vw+dw
            if 0<=nh<h and 0<=nw<w and visit[nh][nw]==0 and s[nh][nw]=='.':
                stack.append((nh,nw))
                stack2.append((nh,nw))

    
    while len(stack2)>0:
        vh,vw=stack2.pop()

        for dh in range(-2,3):
            for dw in range(-2,3):
                nh=vh+dh
                nw=vw+dw

                if 0<=nh<h and 0<=nw<w and visit[nh][nw]==0 and s[nh][nw]=='.':
                    deque.append(q,(nh,nw,cnt+1))
                
print(-1)

Measured memory_bytes: 160216
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n,k,c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> w;
  {
    int K = k;
    for(int i = 0;i < n;i++){
      if(s[i] == 'o'){
        K--;
        w.push_back(i+1);
        i += c;
      }
      if(K == 0)break;
    }
  }
  vector<int> v;
  {
    int K = k;
    for(int i = n-1;i >= 0;i--){
      if(s[i] == 'o'){
        K--;
        v.push_back(i+1);
        i -= c;
      }
      if(K == 0)break;
    }
  }
  reverse(ALL(v));
  rep(i,k)if(v[i] == w[i])cout << v[i] << "\n";
  
  


  

  return 0;
}

Measured memory_bytes: 5708
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
int p[110000];
int q[110000];
int r[110000];
int z[110000];
int x[110000];
int cnt[110000];
int val[110000];
vector<int>g[110000];
int ret[110000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
		if(q[i]>p[i])q[i]=p[i];
	}
	for(int i=0;i<=a;i++){
		scanf("%d",r+i);
		z[i]=r[i];
	}
	std::sort(z,z+a+1);
	for(int i=0;i<=a;i++){
		cnt[lower_bound(z,z+a+1,r[i])-z]--;
	}
	for(int i=0;i<a;i++){
		cnt[lower_bound(z,z+a+1,p[i])-z]++;
		g[lower_bound(z,z+a+1,q[i])-z].push_back(lower_bound(z,z+a+1,p[i])-z);
	}
	priority_queue<int>Q;
	int now=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<g[i].size();j++){
			Q.push(g[i][j]);
		}
		int to=a+1;
		while(Q.size()&&cnt[i]<0){
			int at=Q.top();Q.pop();
			if(at<=i)continue;
			to=at;
			now++;
			cnt[i]++;
			cnt[at]--;
		}
		x[i]=to;
		cnt[i+1]+=cnt[i];
	}
	int ls=a;
	int rm=a;
	int len=0;
	for(int i=a;i>=0;i--){
		if(cnt[i]<=-2){
			rm=-1;
		}else if(cnt[i]==-1){
			rm=min(i,rm);
			//ls=i;
			//len=0;
			ls=i;
		}else if(x[i]<=ls){
			len++;
			ls=i;
		}
		ret[i]=len;
	}
	int c;scanf("%d",&c);
	for(int i=0;i<c;i++){
		int s,t;
		scanf("%d%d",&s,&t);
		int ss=lower_bound(z,z+a+1,s)-z;
		int tt=lower_bound(z,z+a+1,t)-z;
		int ans=mod;
		if(rm>=ss)ans=min(ans,now-ret[ss]);
		if(rm>=tt)ans=min(ans,now-ret[tt]+1);
	//	printf("%d %d: %d %d %d\n",ss,tt,now,ret[ss],ret[tt]);
		if(ans==mod)ans=-1;
		else ans=a+1-ans;
		printf("%d\n",ans);
	}
}

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

public class Main{
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		int n=sc.nextInt();
		long ans=0;
		
		for(int i=1;i<=n;i++) {
			if(i%3==0 || i%5==0)continue;
			ans+=i;
		}
		pw.println(ans);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

Measured memory_bytes: 33008
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/rope>
// using namespace __gnu_pbds; 
// using namespace __gnu_cxx;
// template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
// template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
// template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) { for(auto& i:x) input>>i; return input; }
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {  for(auto& i:x) output<<i<<' '; return output; }
template<typename T, typename U> 
istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> 
ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}

const int mod = 1e9 + 7;
const int N = 1e5 + 5;
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
int water[N / 10], sugar[N / 10];
signed main () {
    io();
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    water[0] = sugar[0] = 1;
    for(int i = 0; i <= 3000; i++) {
        if(water[i]) {
            water[i + a] = water[i];
            water[i + b] = water[i];
        }
        if(sugar[i]) {
            sugar[i + c] = sugar[i];
            sugar[i + d] = sugar[i];
        }
    }
    int ans = 0, sug = 0;
    for(int i = 0; i <= f; i++) {
        if(water[i]) {
            for(int j = 0; j <= f; j++) {
                if(i * 100 + j > f) break;
                if(sugar[j]) {
                    if(i * e >= j) {
                        debug(i * 100, j);
                        if((i * 100 + j) * sug <= ans * j) {
                            ans = i * 100 + j;
                            sug = j;
                        }

                    }
                    else
                        break;
                }
            }
        }
    }
    cout << ans << " " << sug << "\n";

}

//asdasdlkjl

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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 int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

Vi p; //自分自身を親に
Vi Rank; //0に
Vi setSize; //1に

int find(int x)
{
    if (p[x] == x)  return x;
    else return p[x] = find(p[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;

    int t = setSize[x] + setSize[y];
    setSize[x] = setSize[y] = t;

    if (Rank[x] < Rank[y]) {
        p[x] = y;
    }
    else {
        p[y] = x;
        if (Rank[x] == Rank[y]) Rank[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

int main()
{
    int n, m;
    cin >> n >> m;
    p.resize(n);
    rep(i, n) p[i] = i;
    Rank.resize(n, 0);
    setSize.resize(n, 1);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, setSize[i]);
    }
    cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];

    vector<int> Y(N);
    rep(i, N) Y[i] = X[i];
    sort(Y.begin(), Y.end());    

    int z = N/2;
    int prev, after;
    prev = Y[z - 1];
    after = Y[z];

    rep(i, N) {
        if (X[i] == after) {
            cout << prev << endl;
        } else if (X[i] <= prev) {
            cout << after << endl;
        } else {
            cout << prev << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

char s[N];
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,n,K;
    double start=clock();
    scanf("%s",s);n=strlen(s);
    ll ans=0;
    per(i,0,n){
        if(s[i]=='B'){
            ans+=m;
        }
        else m++;
    }
    printf("%lld\n",ans);
    cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


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

int main(){
  int H, W;
  cin >> H >> W;

  char s[H][W];
  int p[H + 2][W + 2];

  for(int i = 0; i < W + 1; i++){
    p[H + 1][i] = 0;
    p[0][i] = 0;
  }
  for(int i = 0; i < H + 1; i++){
     p[i][W + 1] = 0;
     p[i][0] = 0;
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> s[i][j];
      if(s[i][j] == '#') p[i + 1][j + 1] = 1;
      else p[i + 1][j + 1] = 0;
    }
  }

  int flag = 0;

  for(int i = 0; i < H + 2; i++){
    for(int j = 0; j < W + 2; j++){
      if(p[i][j] == 1){
        if(p[i][j] * p[i][j + 1] + p[i][j] * p[i][j - 1] + p[i][j] * p[i + 1][j] + p[i][j] * p[i - 1][j] == 0) flag = 1;
      }
    }
  }

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


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
M = max(a)
m = min(a)
ans = []
if m >= 0:
    for i in range(1, n):
        a[i] += a[i - 1]
        ans.append([i, i + 1])
else:
    if M <= 0:
        for i in range(n - 1)[::-1]:
            a[i] += a[i + 1]
            ans.append([i + 2, i + 1])
    else:
        if M > -m:
            index = a.index(M)
            for i in range(n):
                if a[i] < 0:
                    a[i] += M
                    ans.append([index + 1, i + 1])
            for i in range(1, n):
                a[i] += a[i - 1]
                ans.append([i, i + 1])
        else:
            index = a.index(m)
            for i in range(n):
                if a[i] > 0:
                    a[i] += m
                    ans.append([index + 1, i + 1])
            for i in range(n - 1)[::-1]:
                a[i] += a[i + 1]
                ans.append([i + 2, i + 1])
print(len(ans))
print('\n'.join([str(i) + ' ' + str(j) for i, j in ans]))

Measured memory_bytes: 9292
//a,ee,ii,oo,uu
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    char a;
    cin>>a;
    if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
        cout<<"vowel";
    else
        cout<<"consonant";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,k,c,nxt[N],pre[N],tms[N];
string s;
vector<ll> wk,r1,r2;
int main(){
	ll i,j;
	cin>>n>>k>>c>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='o')
		{
			wk.push_back(i);
		}
	}
	memset(tms,0,sizeof(tms));
	for(i=wk.size()-1;i>=0;i--)
	{
		j=lower_bound(wk.begin(),wk.end(),wk[i]+c+1)-wk.begin();
		nxt[i]=j;
	}
	for(i=0;i<wk.size();i++)
	{
		j=upper_bound(wk.begin(),wk.end(),wk[i]-c-1)-wk.begin()-1;
		pre[i]=j;
	}
	i=0;
	while(i<wk.size())
	{
		r1.push_back(i);
		i=nxt[i]; 
	}
	i=wk.size()-1;
	while(i>=0)
	{
		r2.push_back(i);
		i=pre[i];
	}
	sort(r1.begin(),r1.end());
	sort(r2.begin(),r2.end());
	if(r1.size()>k||r2.size()>k)
	{
		return 0;
	}
	for(i=0;i<r1.size();i++)
	{
		tms[r1[i]]++;
	}
	for(i=0;i<r2.size();i++)
	{
		tms[r2[i]]++;
	}
	for(i=0;i<wk.size();i++)
	{
		if(tms[i]==2)
		{
			cout<<wk[i]+1<<endl;
		}
	}
	return 0;
}

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

int main(){
	string s ; cin >> s ;
	int cnt = 0 ;
	int q ; cin >> q ;
	string front,back ;
	for(int i=0;i<q;i++){
		int a ; cin >> a ;
		if(a==1) cnt++ ;
		else{
			int b ;
			char c ;
			cin >> b >> c ;
			if(cnt%2==1) b++ ;
			if(b%2==1){
				front += c ;
			}else{
				back += c ;
			}
		}
	}
	if(cnt%2==1){
		reverse(s.begin(),s.end()) ;
		reverse(back.begin(),back.end()) ;
		cout << back+s+front << endl ;
	}else{
		reverse(front.begin(),front.end()) ;
		cout << front+s+back << endl ;
	}
}


Measured memory_bytes: 1436
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> a(m);
	int sum = 0;
	for(int i = 0; i < m; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	
	if( n - sum >= 0 ) cout << n - sum << endl;
	else cout << -1 << endl;
	
	return 0;
}


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

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define endl '\n'
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

using ll = long long;
using P = pair<ll, ll>;

/*追加部分*/



/*main関数*/

int main() {
FASTIO;
    int n, a; cin >> n >> a;

    n %= 500;
    cout << (n <= a ? "Yes" : "No") << endl;
return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <stdio.h>
#include <cassert>

#define rep(i, a, b) for (int i = (a); i <= (b); i++)

using namespace std;
using ll = long long;
using vi = vector<int>;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vi V(N), C(N);
    rep(i,0,N-1) cin >> V[i];
    rep(i,0,N-1) cin >> C[i];
    ll ans = -1;

    rep(i,0, (1<<N)-1) {
        ll tt = 0;
        rep(j,0,N-1) {
            if (i & (1<<j)) {
                tt += V[j] - C[j];
            }
        }
        ans = max(ans, tt);
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 100
#define INT_MAX 2000000

int N;
int M[MAX][MAX];

void prim(){
//    dist = 0.0;
    
    char visited[MAX];
    int cost[MAX];
    int pi[MAX];
    int i;
    for (i = 0; i < N; i++ ){
        visited[i] = 0;
        cost[i] = INT_MAX;
    }
    
    cost[0] = 0;
    pi[0] = -1;
    
    while ( 1 ){
        int mincost = INT_MAX;
        int u;
        // cost ªÅ¬ÆÈém[h u ðIð·é
        for (i = 0; i < N; i++ ){
            if ( !visited[i] && cost[i] < mincost ){
                mincost = cost[i];
                u = i;
            }
        }
        
        // ·×ÄÌm[hª MST ÉÜÜê½Æ«
        if ( mincost == INT_MAX ) break;
        
        visited[u] = 1;
        int v;
        for (  v = 0; v < N; v++ ){
            if ( visited[v] || M[u][v] == INT_MAX ) continue;
            // XV
            if ( M[u][v] < cost[v] ){
                cost[v] = M[u][v];
                pi[v] = u;
            }
        }
    }
	int j=0;
	for(i=0;i<N;i++){
		j+=M[i][pi[i]];
	}
	printf("%d\n",j);
}

int main(){
	int m,i,j,a,b,c;
	
	while(~scanf("%d",&N)){
		if(N==0) break;
		
		for(i=0;i<N;i++){
			for(j=0;j<N;j++){
				M[i][j]=INT_MAX;
			}
		}
		
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%d,%d,%d",&a,&b,&c);
			M[a][b]=c/100-1;
			M[b][a]=c/100-1;
		}
		
		prim();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
vector<string> res;
int n;
void dfs(int i,char c,string s,int x){
  s.push_back(c);
  if(i==n){
    res.push_back(s);
    return ;
  }
  rep(j,x+1){
    char cc = 'a' + j;
    if(j==x) dfs(i+1,cc,s,x+1);
    else dfs(i+1,cc,s,x);
  }
}
int main()
{
  cin >> n;
  dfs(1,'a',"",1);
  sort(res.begin(), res.end());
  rep(i,res.size()) cout << res[i] << "\n";
  return 0;
}


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

#define   ll     long long int

const int N = 200005;
int ara[N];

int main( )
{
    int n, i, j, k;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
    }
    if (n % 2) {
        i = n;
        int fl = 0;
        while (i > 0) {
            if (fl) cout << ' ';
            cout << ara[i];
            fl = 1;
            i -= 2;
        }
        i = 2;
        while (i < n) {
            if (fl) cout << ' ';
            cout << ara[i];
            i += 2;
            fl = 1;
        }
    }
    else {
        i = n;
        int fl = 0;
        while (i > 0) {
            if (fl) cout << ' ';
            cout << ara[i];
            fl = 1;
            i -= 2;
        }
        i = 1;
        while (i < n) {
            if (fl) cout << ' ';
            cout << ara[i];
            i += 2;
            fl = 1;
        }
    }
    cout << '\n';
    return 0;
}



Measured memory_bytes: 2944