akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

ll f(ll n) {
  if (n % 2 == 0) {
    return n / 2;
  } else {
    return 3 * n + 1;
  }
}

int main() {
  ll s;
  cin >> s;
  
  set<ll> m;
  m.insert(s);
  
  int i = 1;
  while (1) {
    s = f(s);
    i++;
    if (m.count(s)) {
      cout << i << endl;
      break;
    }
    m.insert(s);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	for(int i = 1; i<s.size(); i++)
		if(s[i] == s[i - 1]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
	for(int i = 2; i < s.size(); i++)
		if(s[i] == s[i - 2]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	cout << "-1 -1\n";
	return 0;
}

Measured memory_bytes: 512
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    for i in range(h):
        ln=''
        for j in range(w):
            if i%2==0:
                if j%2==0:ln+='#'
                else :ln+='.'
            else :
                if j%2==0:ln+='.'
                else :ln+='#'
        print ln
    print ''

Measured memory_bytes: 4212
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int N;
string ans="No";
cin >> N;
for(int i=1;i<10;i++)
{
for(int j=1;j<10;j++)
{
if(i*j==N){ans="Yes";break;}
}
if(ans=="Yes")break;
}
cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> a(n,vector<int>(26,0));
	
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		for(int j=0;j<s.size();j++){
			a[i][int(s[j]-'a')]++;
		}
	}
	
	vector<int> check(26,0);
	int now;
	for(int i=0;i<26;i++){
		now=INF;
		for(int j=0;j<n;j++){
			check[i]=min(now,a[j][i]);
			now=check[i];
		}
	}
	
	
	for(int i=0;i<26;i++){
		if(check[i]==0)continue;
		for(int j=0;j<check[i];j++){
			cout << (char)(i+'a');
		}
	}
	cout << endl;

	return 0;
}


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

#define endl '\n'
typedef long long ll;
ll const M = 1000000007, N = 2e5 + 1;
ll f1[N], f2[N], iv[N];

ll mult(ll a, ll b){ return ( a%M * (b%M))%M;}
ll nck(ll n, ll k){
    return f1[n]*f2[n-k]%M*f2[k]%M;
}

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

    iv[1] = f1[0] = f2[0] = 1;
    for (ll i=2; i<N; i++) iv[i] = (M - (M/i) * iv[M%i] % M) % M;
    for (ll i=1; i<N; i++){
        f1[i] = f1[i-1]*i%M;
        f2[i] = f2[i-1]*iv[i]%M;
    }

    ll n,k; cin >> n >> k;
    k = min(n-1, k);

    ll ans = 0;
    for (ll x=0; x <= k; x++){
        ans = (ans + nck(n, x) * nck(n-1, x)%M)%M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	multiset<int> ir;
	ir.insert(a);
	ir.insert(b);
	ir.insert(c);
	auto it = ir.begin();
	if (*it + *(++it) == *(++it))cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n,t,x=0,y,ans=0;
    cin >> n >> t;
    for(ll i=0;i < n;i++){
        
        if(n-1 == 0){
            cin >> y;
            ans += t;
        }else if(i==n-1){
            cin >> y;
            ans += min(t,y-x);
            ans += t;
        }else if(i==0){
            cin >> x;
        }else{
            cin >> y;
            ans += min(t,y-x);
            x=y;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;

	int len = s.size();

	int a[3] = {0};

	rep(i, len)
	{
		a[s[i] - 'a']++;
	}

	sort(a, a+3);

	if (a[2] - a[0] <=1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;



int main(){
	int a,b=0;
	rep(i,5){
	scanf("%d",&a);
	b+=(a>=40?a:40);
}
	printf("%d\n",b/5);
	
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

bool checkValidity(ll a, ll b, ll c) 
{ 
    // check condition 
    if(a==b || b==c || a==c) return false;
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
}

int main(){
  fastio
  ll n;
  cin>>n;
  ll l[n];
  for(ll i=0; i<n; i++)cin>>l[i];
  ll ans=0;
  for(ll i=0; i<n-2; i++){
    for(ll j=i+1; j<n-1; j++){
      for(ll k=j+1; k<n; k++){
        if(checkValidity(l[i], l[j], l[k])){
          ans++;
        }
      }
    }
  }
  cout<<ans<<"\n";
  
  return 0; 
}


Measured memory_bytes: 3660
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = -10000000000007L;
    //static final long MOD = 998244353L;
    static final int INF = 50000000;
    static final int NINF = -500000000;
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int N = sc.ni();
        int M = sc.ni();
        DisjointSetUnion dsu = new DisjointSetUnion(N);
        for (int e = 0; e < M; e++) {
        	int a = sc.ni()-1;
        	int b = sc.ni()-1;
        	dsu.connect(a, b);
        }
        pw.println(dsu.count-1);
        
        pw.close();
    }
    
    static class DisjointSetUnion {
    	public int[] parent;
    	public int[] weight;
    	public int count;

    	public DisjointSetUnion(int N) {
    		count = N;
    		parent = new int[N];
    		for (int i = 0; i < N; i++)
    			parent[i] = i;
    		weight = new int[N];
    		Arrays.fill(weight,1);
    	}

    	//"find"
    	public int root(int p) {
    		while (p != parent[p]) {
    			p = parent[p];
    		}
    		return p;
    	}

    	//"union"
    	public void connect(int p, int q) {
    		p = root(p);
    		q = root(q);
    		if (p==q)
    			return;
    		if (weight[p] < weight[q]) {
    			parent[p] = q;
    			weight[q] += weight[p];
    		} else {
    			parent[q] = p;
    			weight[p] += weight[q];
    		}
    		count--;
    	}

    	public boolean connected(int p, int q) {
    		return root(p) == root(q);
    	}
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

int main(int argc, char const *argv[]) {
  int n, a, b;
  cin >> n >> a >> b;
  int plan_a = n * a;
  int plan_b = b;
  if (plan_a < plan_b)
    cout << plan_a << endl;
  else
    cout << plan_b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    string a,b,c;
    string ans = "NO";
    cin >> a >> b >> c;
    if(a.substr(a.length()-1,1)==b.substr(0,1)&&b.substr(b.length()-1,1)==c.substr(0,1)){
        ans = "YES";
    }
    cout << ans << endl;
}

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

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

  string S;
  cin >> S;

  for (int i = 0; i < S.size(); ++i) {
    bool chack = false;
    if (S.size() % 2 != 0) {
      break;
    }
    else {
      for (int j = 0; j < (S.size() - i) / 2; ++j) {
        if (S.at(j) == S.at(((S.size() - i) / 2) + j)) {
          chack = true;
        }
        else {
          chack = false;
          break;
        }
      }
      if (i != 0 && chack) {
        cout << S.size() - 1 - i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    vector<string>c={"Sunny","Cloudy","Rainy","Sunny"};
    rep(i,3){
        if(s==c.at(i)){
            cout<<c.at(i+1)<<endl;
            return 0;
        }
    }
}

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  if(a[2] > 7){
    cout << "NO";
  }else if(a[1] > 5){
    cout << "NO";
  }
  else cout << "YES";
  return 0;
}


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

using namespace std;

int main()
{
	char n[10][9]={"* = ****","* =* ***","* =** **","* =*** *","* =**** ",
				   " *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};
	int a;
	for(int k=0;cin>>a;k++){
		if(k>0)	cout<<endl;

		char s[6];
		sprintf(s,"%05d",a);

		char abacus[8][6];
		for(int i=0;i<5;i++){
			for(int j=0;j<8;j++){
				abacus[j][i]=n[s[i]-'0'][j];
			}
		}

		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				cout<<abacus[i][j];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define t 1000000007
int main(void){
    int n,m,a;
    cin >> n >> m;
    vector<bool> safe;
    safe.assign(n+1, true);
    
    for(int i=0;i<m;i++){
        cin >> a;
        safe[a] = false;
    }
    vector<int> dp(n+1, 0);//各段について 0 で初期化
    
    dp[0]=1;
    if(safe[1]) dp[1]=1;
    
    for(int i=2;i<=n;i++){
        if(safe[i-1]) dp[i] += dp[i-1];
        if(safe[i-2]) dp[i] += dp[i-2];
        dp[i] %= t; 
    }
    
    cout << dp[n] << endl;
    
    return 0;
}


Measured memory_bytes: 640
using AtCoderBeginnerContest138.Questions;
using AtCoderBeginnerContest138.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest138.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var a = inputStream.ReadInt();
            var s = inputStream.ReadLine();

            if (a >= 3200)
            {
                yield return s;
            }
            else
            {
                yield return "red";
            }
        }
    }
}


namespace AtCoderBeginnerContest138
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest138.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest138.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int price = 700;
		for (char c: s.toCharArray()) {
			if (c=='o') {
				price += 100;
			}
		}
		System.out.println(price);
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;

pair<int, int> merge(pair<int, int> a, pair<int, int> b){
	vector<int> v = {a.first, a.second, b.first, b.second};
	sort(v.begin(), v.end());
	return {v[3], v[2]};
}
 
int main(void){
  int n;
  cin >> n;
  int m = 1 << n;
  vector<pair<int, int>> arr = vector<pair<int, int>>(m);
  for(int i = 0; i <= m - 1; i++) {
    cin >> arr[i].first;
  }

  //vector<int> result = vector<int>(m + 1);
  for(int k = 0; k < n; k++){
  	for(int i = 0; i <= m - 1; i++){
  		if( (i & (1 << k)) == 0){
  			arr[i | (1 << k)] = merge(arr[i], arr[i | (1 << k)]);
  		}
  	}
  }

  int max = -1;
  for(int k = 1; k <= m - 1; k++){
  	if(max < arr[k].first + arr[k].second) max = arr[k].first + arr[k].second;
  	cout << max << endl;
  }
}

Measured memory_bytes: 5120
k,n=map(int,input().split())
a=[int(x) for x in input().split()]
ll=-1
for i in range(len(a)):
    if i==n-1:
        l=a[0]-a[i]+k
        ll=max(ll,l)
    else:
        l=a[i+1]-a[i]
        ll=max(ll,l)
print(k-ll)

Measured memory_bytes: 26420
import collections
n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]
bc = collections.Counter(b)
rc = collections.Counter(r)
ans = 0
for x in bc.keys():
  ans = max(ans, bc[x]-rc[x])
print(ans)

Measured memory_bytes: 82828
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,d,A = inpl()
d *= 2
xh = [inpl() for _ in range(n)]
xh.sort()
ln = 1
f = [0]
a = [0]
for i in range(n):
    x,h = xh[i]
    r = bisect_left(f,x+d)
    l = bisect_left(f,x)
    tmp = a[r-1] - a[l-1]
    # print(i,l,r)
    h -= tmp * A
    if h > 0:
        ind = x + d
        att = (h+A-1)//A
        f.append(ind)
        a.append(a[-1] + att)
        ln += 1
# print(f,a)
print(a[-1])


Measured memory_bytes: 120664
#include <stdio.h>
#include <stdint.h>

int gcd(int m, int n) {
  int tmp;
  while (m % n != 0) {
    tmp = n;
    n = m % n;
    m = tmp;
  }
  return n;
}

int main(void) {
  int64_t A, B, C, D;
  scanf("%ld %ld %ld %ld", &A, &B, &C, &D);
  int64_t X = B - A + 1;
  int64_t C_X = (B / C) - ((A-1) / C);
  int64_t D_X = (B / D) - ((A-1) / D);
  int64_t CD  = (C * D) / gcd(C, D);
  int64_t CD_X = (B / CD) - ((A-1) / CD);
  printf("%ld\n", X - C_X - D_X + CD_X);
  
  return 0;
}


Measured memory_bytes: 128
# find the longest subsequence where the common difference is 1

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())
p=[int(input()) for _ in range(n)]

got=[0]*(n+1)
for i in p:
    got[i]=got[i-1]+1

print(n-max(got))


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


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  if ((a + b) & 1) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }
  cout << (a + b) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0,s.size() - 8) << endl;
    return 0;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Saturday, April 04, 2020
5:56 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

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

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,k,c;
	cin >> n >> k >> c;

	string tmp;
	cin >> tmp;

	string s = "*" + tmp;

	if(n == 1){
		cout << 1 << endl;
		return 0;
	}

	int done = -1;
	vi lpref(n+1,0);
	for(int i = 1; i <= n; i++){
		lpref[i] = lpref[i-1];
		if(i <= done) continue;
		if(s[i] == 'o'){
			lpref[i]++;
			done = i + c;
		}
	}

	vi rpref(n+2,0);
	done = n + 1;
	for(int i = n; i >= 1; i--){
		rpref[i] = rpref[i+1];
		if(i >= done) continue;
		if(s[i] == 'o'){
			rpref[i]++;
			done = i - c;
		}
	}


	int maxi;
	vi ans;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'o'){
			maxi = lpref[i - 1] + rpref[i + 1];
			if(maxi < k){
				ans.pb(i);
			}
		}
	}
	
	for(auto i : ans) cout << i << endl;


	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 6792
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	A := ReadInts(N)
	max := Max(A...)
	gcd := A[0]
	for i := 1; i < N; i++ {
		gcd = GCD(gcd, A[i])
	}
	if K%gcd == 0 && K <= max {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;


int main(){
	//cout<<-10%-10<<endl;
	while(1){
		ll n = in.nextLong();
		if(n == 0LL) break;
		stack<ll> st;
		while(n != 0LL){
			ll a = n % (-10LL);
			//cout<<" "<<a;
			if(a < 0LL){
				a += 10LL;
				n -= a;
			}
			//cout<<" "<<a<<endl;
			n /=-10;
			st.push(a);
		}
		while(!st.empty()){
			printf("%lld", st.top());
			st.pop();
		}
		printf("\n");
	}
}

Measured memory_bytes: 1196
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int nums[] = new int[3];
        
        for(int i = 0; i < nums.length; i ++) {
            nums[i] = sc.nextInt();
        }
        
        int new_num;
        for(int j = 0; j < nums.length; j ++){
            for(int k = nums.length - 1; k > j; k-- ){
                if(nums[j] > nums[k]) {
                    new_num = nums[k];
                    nums[k] = nums[j];
                    nums[j] = new_num;
                }
            }
        }
        
        System.out.println(nums[0] + " " + nums[1] + " " + nums[2]);
        
    }
}


Measured memory_bytes: 26344
#include<bits/stdc++.h>
#define Mod 1000000007ll
#define Val(x) ((((long long)x) % Mod + Mod) % Mod)
#define maxn 405
using namespace std;
int arr[maxn][maxn];
int A[maxn],B[maxn];
int dp[maxn][maxn];
inline int cost(int i,int j,int k) {
	return Val(arr[j][k]-arr[i-1][k]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int i=1;i<=400;i++)
		for(int j=0,fac=1;j<=400;j++,fac=Val(fac*i))
			arr[i][j] = fac;
	for(int i=2;i<=400;i++)
		for(int j=0;j<=400;j++)
			arr[i][j] = Val(arr[i][j]+arr[i-1][j]);
		
	int n,c;
	cin >> n >> c;
	for(int i=1;i<=n;i++)	cin >> A[i];
	for(int i=1;i<=n;i++)	cin >> B[i];
	
	dp[0][0] = 1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
				dp[i][j] = Val(dp[i-1][j-k]*cost(A[i],B[i],k)+dp[i][j]);
				
	cout << dp[n][c] << endl;
	return 0;
}


Measured memory_bytes: 1536
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = null;
		try {
			scan = new Scanner(System.in);
			int W = scan.nextInt();
			int H = scan.nextInt();
			int x = scan.nextInt();
			int y = scan.nextInt();
			int r = scan.nextInt();
			IsInside(W, H, x, y, r);
		} catch (InputMismatchException e) {
			System.out.println(e);
		} finally {
			scan.close();
		}
	}

	static void IsInside(int W, int H, int x, int y, int r) {
		if (x < -100 || x > 100 || y < -100 || y > 100) {
			throw new RuntimeException("Out of range x or y");
		} else if (W < 0 || W > 100 || H < 0 || H > 100 || r < 0 || r > 100) {
			throw new RuntimeException("Out of range W or H or r");
		}

		if (x - r < 0 || W < x + r || y - r < 0 || H < y + r) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 998244353;
const LL INF = LLONG_MAX;
const LL N = 3e5+1;

#define F first
#define S second

struct segtree {
	LL size = 1;
	vector<LL> seg;
	
	void init(LL n) {
		while (size < n) size *= 2;
		seg.assign(2*size, 0);
	}

	void set (LL i, LL v, LL x, LL lx, LL rx) {
		if (rx - lx == 1) {
			seg[x] = v;
			return;
		}
		LL m = (lx + rx) / 2;
		if (i < m) {
			set (i, v, 2*x + 1, lx, m);
		}
		else {
			set (i, v, 2*x + 2, m, rx);
		}

		seg[x] = max(seg[2*x + 1], seg[2*x + 2]);
	}

	void set (LL i, LL v) {
		set (i, v, 0, 0, size);
	}

	LL query (LL l, LL r, LL x, LL lx, LL rx) {
		if (r <= lx || l >= rx) return 0;
		if (l <= lx && r >= rx) return seg[x];

		LL m = (lx + rx)/2;
		LL max1 = query(l, r, 2*x + 1, lx, m);
		LL max2 = query(l, r, 2*x + 2, m, rx);
		return max(max1, max2);
	}

	LL query (LL l, LL r) {
		return query(l, r, 0, 0, size);
	}
};

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

	vector<LL> a(n);

	for (auto &e : a ) {
		cin >> e;
	}

	segtree st;
	st.init(N);

	LL ans = 0;
	for (LL i = 0; i < n; ++i) {
		LL l = max(0LL, a[i]-k);
		LL r = min(N-1, a[i]+k);
		LL rmax = st.query(l, r+1);
		st.set(a[i], rmax+1);
		ans = max(ans, rmax+1);
		//cout << i << " " << a[i] << " " << rmax+1 << "?\n";
	}

	cout << ans << "\n";

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int64_t a[3]; rep(i, 3) cin >> a[i];
  sort(a, a + 3);
  int k; cin >> k;
  rep(i, k) {
    a[2] *= 2;
  }
  int64_t s = 0; rep(i, 3) s += a[i];
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 998244353;

int n;
int a[305];
ll dp[305][90005];
ll dp2[305][90005];

ll p(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

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

  dp[0][0] = 1;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i * maxa; j++) {
      if(dp[i][j] == 0) continue;
      dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % mod;
      dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % mod;
			 
    }
  }
  dp2[0][0] = 1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i * maxa; j++) {
       if(dp2[i][j] == 0) continue;
      dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % mod;
      dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % mod;
    }
  }

  ll ans = p(3,n);
  for(int i = 0; i <= n * maxa; i++) {
    if(i >= sum - i) {
      ans = (ans + mod - dp[n][i] * 3 % mod) % mod;
    }
    if(i == sum - i) {
      ans = (ans + dp2[n][i] * 3 % mod) % mod;
    }
  }
  if(ans < 0 ) cout << ans + mod << endl;
  else 
  cout << ans << endl;
}
				 
  
  


  
  


Measured memory_bytes: 426240
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long lli;
 
int main() {
	lli n, t, p=p, q;
    char a;
    cin >> a;
    if(a>='a' and a<='z') cout << 'a' << endl;
    else if(a>='A' and a<='Z') cout << 'A' << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;


int main()
{
  int n;
  cin >> n;
  int a[n];
  int c=0;
  for(int i = 0; i <= n; ++i){
    cin >> a[i];
    if(i%2==0 && a[i]%2==1) c++;
  }
  cout << c << endl;

}


Measured memory_bytes: 3592
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		int x;
		int sum = 0;
		for(i=0;i<n;i++) {
			x = parseInt(sc.next());
			sum += Math.min(x, abs(x-k))*2;
		}
		sc.close();
		out.println(sum);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <functional>
#include <stack>
#include <numeric>
#define PI 3.1415926535
#define FOR(i,n) for (int i=0; i<(n) ;i++)
#define INF 114514810

using namespace std;

string s, p;

int main(){
	cin >> s >> p;
	s += s;
	for (int i = 0; i < (s.size() - p.size()); i++) 
		if (s.substr(i,p.size()) == p) {
		cout << "Yes" << endl;
		return 0;
		}
	cout << "No" << endl;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    //vector<long long int>v;
    long long int n,i,x;
    cin>>n;
    long long int a[n]={0};
    for(i=1;i<n;i++)
    {
        cin>>x;
        a[x-1]++;
    }
    for(i=0;i<n;i++)
    {
        cout<<a[i]<<endl;
    }
}


Measured memory_bytes: 5184
module Main where

import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    [n, k] <- fmap read . words <$> getLine :: IO [Int]
    if odd k
        then do
            let s = length [x | x <- [1 .. n], x `mod` k == 0]
            print $ s ^ 3
        else do
            let s = length [x | x <- [1 .. n], x `mod` k == 0]
            let t = length [x | x <- [1 .. n], x `mod` k == k `div` 2]
            print $ s ^ 3 + t ^ 3

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; ++i) {
        cout << i << ' ';
    }
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 256
W,H=map(int,input().split())
List=[]
for i in range(W):
  p=int(input())
  List.append((p,"W"))
for j in range(H):
  q=int(input())
  List.append((q,"H"))
ans=0
List.sort()
for a,l in List:
  if l=="W":
    ans+=(H+1)*a
    W-=1
  elif l=="H":
    ans+=(W+1)*a
    H-=1
print(ans)
  

Measured memory_bytes: 73432
a = list(map(int,input().split( )))
H = a[0]
W = a[1]
b = H//2
c = H//2
if H%2 == 1:
  b = b+1

d = W//2
answer = (b+c)*d
if W%2 == 1:
  answer = answer + b

if H==1 or W==1:
  answer = 1

print(answer)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<vector<int>> adj;
vector<vector<ll>> dp;

ll dfs(int b, int n, int p) {
  if (dp[b][n]!=-1) return dp[b][n];

  ll result = 1;
  for (auto x: adj[n]) {
    if (x==p) continue;
    if (b==0) result = (result*(dfs(0,x,n)+dfs(1,x,n))) % MOD;
    else result = (result*dfs(0,x,n)) % MOD;
  }
  return dp[b][n] = result;
}

int main() {
  int N; cin >> N;
  adj.resize(N);
  rep(i,N-1) {
    int x, y; cin >> x >> y; x--; y--;
    adj[x].push_back(y); adj[y].push_back(x);
  }

  dp.resize(2,vector<ll>(N,-1));
  ll result = (dfs(0,0,-1)+dfs(1,0,-1))%MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 15600
n = int(input())
A = list(map(int, input().split()))

uni_A = list(set(A))
cnt_dict = {}
for uni_a in uni_A:
    cnt_dict[uni_a] = 0

# print(cnt_dict)

del_count = 0
for a in A:
    cnt_dict[a] += 1
    if cnt_dict[a] > a:
        del_count += 1

for key in cnt_dict.keys():
    if cnt_dict[key] < key:
        del_count += cnt_dict[key]

print(del_count)


Measured memory_bytes: 20340
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <iostream>
#include <ctype.h>
#include <string>

typedef long long ll;
using namespace std;



int main(){
  string st;
  double a,b, h, m;
  cin>>a>>b>>h>>m;
  
  double kaku=((60*h-11*m)/360)*M_PI;
  //cout<<kaku;
  cout<<fixed<<setprecision(11);
  double ans;
  ans=a*a+b*b-2*a*b*cos(kaku);
  ans=sqrt(ans);
  cout<<ans;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int n; cin >> n;
    cout << n/3 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int s;
  cin >> s;

  vector<int> a(1, s);
  for (int i = 0; i < 1000000; i++) {
    if (a[i] % 2 == 0) {
      a.push_back(a[i] / 2);
    }
    else {
      a.push_back(3 * a[i] + 1);
    }
    for (int j = 0; j < i; j++) {
      if (a[i] == a[j]) {
        cout << i+1 << endl;
        return 0;
      }
    }
  }
}

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

using namespace std;

int main()
{
    int k, n, sum = 0;
    cin >> k >> n;
    vector <int>vec(k);
    for (int i = 0 ; i < k ; i++)
        cin >> vec[i];
    sort(vec.begin(), vec.end());

    for (int i = 0 ; i < n ; i++)
        sum += vec[i];

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int x = sc.nextInt();
	    int y = sc.nextInt();
	    
	    int cou = 0;
	    for(int i=0; i<=x; i++) {
	    if(2*i + 4*(x-i) == y) {
	    	cou++;
	    }
	    }
	    if(cou>0){
	    	System.out.println("Yes");
	    }else{
	    	System.out.println("No");
	      }
	}
	}

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

int main(){
    int K, S; cin >> K >> S;

    int cnt = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S - x - y;
            if(0 <= z && z <= K) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = double.Parse(input[0]);

            var m = a * a * Math.PI;
            var n = 2 * a * Math.PI;

            Console.WriteLine($"{m} {n}");
        }
    }
}



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

int main()
{
    int n;
    std::cin >> n;
    n %= 10;
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        std::cout << "hon" << std::endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        std::cout << "pon" << std::endl;
        break;
    case 3:
        std::cout << "bon" << std::endl;
        break;
    default:
        break;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

class UnionFind{
private:
    vector<int> p,s,e;
	int cnt;
public:
	UnionFind(){}
	UnionFind(int N){
		cnt = N;
		p = s = e = vector<int>(N+1,0);
		for(int i=1;i<=N;i++){
			p[i] = i; s[i] = 1; e[i] = 0;
		}
	}
	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){
            e[x]++;
            return;
		}
        if(s[x]>s[y]){
			p[y] = x;
			s[x] += s[y];
            e[x] += e[y]+1;
		}else{
			p[x] = y;
			s[y] += s[x];
            e[y] += e[x]+1;
		}
		cnt--;
	}
	bool is_same_set(int x,int y) {return find(x)==find(y);}
	int number_of_nodes(int x) {return s[find(x)];}
    int number_of_edges(int x){return e[find(x)];}
	int number_of_components(){return cnt;}
};

struct card{
    int s,t;
    ll value;
    bool operator<(const card& right)const{
        return value>right.value;
    }
};

int main(){
    int N,H,W;
    cin >> N >> H >> W;
    vector<card> v;
    for(int i=0;i<N;i++){
        int r,c; ll a;
        cin >> r >> c >> a;
        v.push_back({r,c+H,a});
    }
    sort(v.begin(),v.end());
    UnionFind uf(H+W);
    ll ans = 0;
    for(auto x:v){
        if(!uf.is_same_set(x.s,x.t)){
            if(uf.number_of_nodes(x.s)+uf.number_of_nodes(x.t)<=uf.number_of_edges(x.s)+uf.number_of_edges(x.t)) continue;
            ans += x.value;
            uf.unite(x.s,x.t);
         }else if(uf.number_of_nodes(x.s)>uf.number_of_edges(x.s)){
            ans += x.value;
            uf.unite(x.s,x.t);
        }
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vl v(n);
	REP(i, n)cin >> v[i];
	vl a(n + 1);
	a[0] = 0;
	REP(i, n)a[i + 1] = a[i] + v[i];
	vl s;
	REP(i, n) {
		FOR(j, i, n) {
			s.push_back(a[j + 1] - a[i]);
		}
	}
	ll ans = 0;
	for (ll i = 40; i >= 0; --i) {
		int cnt = 0;
		ll a = 1;
		REP(j, i)a *= 2;
		REP(j,s.size()){
			if (s[j] & a)cnt++;
		}
		
		if (cnt >= k) {
			vl tmp;
			REP(j, s.size()) {
				if (s[j] & a)tmp.push_back(s[j]);
			}
			
			ans |= a;
			s = tmp;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 6384
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
	ll n, k, a, mod = 1000000007;
	scanf("%lld %lld", &n, &k);
	ll dp[k + 1], p[k + 2];
	for (ll i = 0; i < n; i++){
		scanf("%lld", &a);
		fill(dp, dp + k + 1, 0);
		if (i == 0) for (ll j = 0; j <= a; j++) dp[j] = 1;
		else for (ll j = 0; j <= k; j++) dp[j] = (p[j + 1] - p[max(0ll, j - a)] + mod) % mod;
		p[0] = 0;
		for (ll j = 0; j <= k; j++) p[j + 1] = (p[j] + dp[j]) % mod;
	}
	printf("%lld\n", dp[k]);
}

Measured memory_bytes: 1664
n,l = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
c = -1
for i in range(n-1):
  if x[i] + x[i+1] >= l:
    c = i
    break

if c == -1:
  print("Impossible")
else:
  print("Possible")
  for i in range(1,c+1):
    print(i)
  for i in range(1,n - c):
    print(n - i)

Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	rep(t,4){
		vi ans(n);
		ans[0]=t/2, ans[1]=t%2;
		range(i,2,n){
			if(s[i-1]=='o')ans[i]=ans[i-1]^!ans[i-2];
			if(s[i-1]=='x')ans[i]=ans[i-1]^ans[i-2];
		}
		bool ok1=false,ok2=false;
		if(s[n-1]=='o' and ans[n-1] and ans[0]==ans[n-2])ok1=true;
		if(s[n-1]=='o' and !ans[n-1] and ans[0]!=ans[n-2])ok1=true;
		if(s[n-1]=='x' and ans[n-1] and ans[0]!=ans[n-2])ok1=true;
		if(s[n-1]=='x' and !ans[n-1] and ans[0]==ans[n-2])ok1=true;
		if(s[0]=='o' and ans[0] and ans[1]==ans[n-1])ok2=true;
		if(s[0]=='o' and !ans[0] and ans[1]!=ans[n-1])ok2=true;
		if(s[0]=='x' and ans[0] and ans[1]!=ans[n-1])ok2=true;
		if(s[0]=='x' and !ans[0] and ans[1]==ans[n-1])ok2=true;
		if(ok1 and ok2){
			rep(i,n) cout<<(ans[i]?"S":"W");
			cout<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 976
### constant

MAX_INT = 1 << 30

### main

loop do
  n, k = gets.strip.split(' ').map{|s| s.to_i}
  break if (n | k) == 0

  edges = n.times.map{[]}
  nbrs = n.times.map{[]}

  k.times do
    qid, a, b, e = gets.strip.split(' ').map{|s| s.to_i}
    a -= 1
    b -= 1

    if qid == 1
      e0 = edges[a][b]
      if e0.nil?
        edges[a][b] = edges[b][a] = e
        nbrs[a] << b
        nbrs[b] << a
      elsif e0 > e
        edges[a][b] = edges[b][a] = e
      end
    else
      dists = n.times.map{MAX_INT}
      dists[a] = 0

      q = (0...n).to_a

      while ! q.empty?
        u = q.min{|a, b| dists[a] <=> dists[b]}
        q.delete u

        break if u == b

        for v in nbrs[u]
          du = dists[u] + edges[u][v]
          if dists[v] > du
            dists[v] = du
          end
        end
      end

      puts (dists[b] >= MAX_INT ? -1 : dists[b])
    end
  end
end

Measured memory_bytes: 6168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0]==5 && a[1] == 5 && a[2]==7) cout<<"YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256