akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    int res = 0;
    int i=0;
    rep(i,n){
        int idx = upper_bound(all(a),a[i]+2) - a.begin();
        res = max(res,idx - i);
    }
    out(res);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
char c;
int i=1; 
int l=100000;
int r=0;
while(cin>>c){
if(c=='A'&&i<l)l=i;
if(c=='Z'&&r<i)r=i;
i++;}
cout<<max(0,r-l+1)<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;

int main() {
	fastio;
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll sum = 0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		a[i] -= i+1;
		
	}
	sort(a.begin(),a.end());
	if(n%2){
		for(ll i=0;i<n;i++){
			sum += abs(a[i]-a[n/2]); 
		}
		cout<<sum<<"\n";
	}
	else{
		ll s1 = 0,s2 = 0;
		for(ll i=0;i<n;i++){
			s1 += abs(a[i]-a[n/2-1]); 
		}
		
		cout<<s1<<"\n";
	}
	
	
	
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		String s = scanner.next();
		if(a >= 3200){
			System.out.println(s);	
		}else if(a <= 3200){
			System.out.println("red");
		}
		}
	}


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

int main()
{
    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    if(arr[0]==arr[1]&&arr[0]!=arr[2]||arr[1]==arr[2]&&arr[1]!=arr[0])
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


int main(){
    int n, x, ret=INF;
    R n >> x;
    rep(i, n){
        int m;
        R m;
        x -= m;
        chmin(ret, m);
    }
    co(n + x / ret);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int sum = 0;
    vector<int> ary(N, 0);

    for (int i = 0; i < N; i++)
    {
        if (scanf("%d", &ary[i]) < 1) return 0;
        sum += ary[i];
    }

    if (sum % 10 != 0)
    {
        printf("%d\n", sum);
        return 0;
    }

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

    for (int i = 0; i < ary.size(); i++)
    {
        int tmp = sum - ary[i];
        if (tmp % 10 != 0)
        {
            printf("%d\n", tmp);
            return 0;
        }
    }

    printf("%d\n", 0);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<long long> q;
    for(int i = 0; i < N; i++) {
        long long a;
        cin >> a;
        q.push(a);
    }
    for(int i = 0; i < M; i++){
        long long t = q.top();
        q.pop();
        q.push(t / 2);
    }
    long long ans = 0;
    while(!q.empty()){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b, x;
    cin >> a >> b >> x;
    if (b >= x - a && a <= x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;

    if (S.length() % 2 != 0) {
        print("No");
    } else {
        int N = S.length() / 2;
        bool flag = true;
        for (int i = 0; i < N; i++) {
            if (S[2*i] == 'h' and S[2*i+1] == 'i') {
                continue;
            } else {
                flag = false;
                break;
            }
        }
        if (flag) print("Yes");
        else print("No");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  int ans[A[A.size()-1]+1];
  for(int i=0;i<=A[A.size()-1];++i) ans[i] = 0;
  map<int, int> amap;
  for(int i=0;i<N;++i) {
    if(ans[A[i]]>0) continue;
    amap[A[i]]++;
    for(int j=2;A[i]*j<=A[A.size()-1];++j) {
      ans[A[i]*j]++;
    }
  }
  int ans1 = 0;
  for(int i=0;i<=A[A.size()-1];++i) {
    if(amap[i]==1 && ans[i]==0) ans1++;
  }
  cout<<ans1<<endl;
}



Measured memory_bytes: 54668
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    bool fla = false;

    for(ll i = 0;i < N;i++){
        if(H <= 0){
            fla = true;
            break;
        }
        H -= A.at(i);
    }

    if(H <= 0)
        fla = true;

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

Measured memory_bytes: 4032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
        int datanum;
        while ((datanum = Integer.parseInt(bReader.readLine())) != 0) {
            String[][] dataSet = new String[datanum][datanum];
            String inputStr;
            for (int x = 0; x < datanum; x++) {
                inputStr = bReader.readLine();
                dataSet[x] = inputStr.split(" ");
            }
            for (int x = 0; x < datanum; x++) {
                int rmul = 0;
                for (int y = 0; y < datanum; y++) {
                    int output = Integer.parseInt(dataSet[x][y]);
                    rmul += output;
                    System.out.printf("%5d", output);
                }

                System.out.printf("%5d", rmul);
                if (x == datanum - 1) {
                    int cmulsum = 0;
                    System.out.println();
                    for (int i = 0; i < datanum; i++) {
                        int cmul = 0;
                        for (int j = 0; j < datanum; j++) {
                            cmul += Integer.parseInt(dataSet[j][i]);
                        }
                        System.out.printf("%5d", cmul);
                        cmulsum += cmul;
                        cmul = 0;
                    }
                    System.out.printf("%5d", cmulsum);
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
ll MOD = 1e9+7;
 
ll mod(ll num) {
	return ((num%MOD)+MOD)%MOD;
}
 
int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> neg, nneg;
	for (int i = 0; i < N; ++i) {
		ll num;
		cin >> num;
		if (num < 0) neg.push_back(-num);
		else nneg.push_back(num);
	}
	sort(begin(neg), end(neg));
	reverse(begin(neg), end(neg));
	sort(begin(nneg), end(nneg));
	reverse(begin(nneg), end(nneg));
 
	ll ans = 1;
 
	if (!nneg.size() && K%2) {
		for (int i = 0; i < K; ++i)
			ans = mod(ans*(-neg[neg.size()-1-i]));
		cout << ans << endl;
		return 0;
	}
 
	int cnt = 0, p1 = 0, p2 = 0;
	for (int i = 0; i < K; ++i) {
		if (p1 == neg.size()) ans = mod(ans*nneg[p2++]);
		else if (p2 == nneg.size() || neg[p1] > nneg[p2]) {
			++cnt;
			ans = mod(ans*(-neg[p1++]));
		} else ans = mod(ans*nneg[p2++]);
	}
 
	if (K == N) {
		cout << ans << endl;
		return 0;
	}
 
	if (cnt%2) {
		if (p1 == neg.size() || p2 == 0) {
			ans = 1;
			for (int i = 0; i < cnt-1; ++i) ans = mod(ans*(-neg[i]));
			for (int i = 0; i < K-(cnt-1); ++i) ans = mod(ans*nneg[i]);
		} else if (p2 == nneg.size() || p1 == 0) {
			ans = 1;
			for (int i = 0; i < cnt+1; ++i) ans = mod(ans*(-neg[i]));
			for (int i = 0; i < K-(cnt+1); ++i) ans = mod(ans*nneg[i]);
		} else if (neg[p1]/(long double)(nneg[p2-1]) > nneg[p2]/(long double)(neg[p1-1])) {
			ans = 1;
			for (int i = 0; i < cnt+1; ++i) ans = mod(ans*(-neg[i]));
			for (int i = 0; i < K-(cnt+1); ++i) ans = mod(ans*nneg[i]);
		} else {
			ans = 1;
			for (int i = 0; i < cnt-1; ++i) ans = mod(ans*(-neg[i]));
			for (int i = 0; i < K-(cnt-1); ++i) ans = mod(ans*nneg[i]);
		}
	}
 
	cout << ans << endl;
 
}

Measured memory_bytes: 5628
/*
ID: toooooEasy or RafaelSaddatimov
PROG:
*/
#include <bits/stdc++.h>
#define MAX 101
#define MOD 1000000LL
#define INF 1000000000
#define EPS 1e-12
#define ll long long
using namespace std;
int arr[150];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; ++i)
        scanf("%d", &arr[i]);
    sort(arr, arr + n);
    printf("%d", arr[n-1] - arr[0]);
}


Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define int long long
#define sz(x) (int)x.size()
const int mx = 2000* 100 + 5;
char c[mx], b[mx]; 
string s;
int n, q;
int f(int p){
	for(int i = 0; i < q; i++){
		if(c[i] == s[p]){
			if(b[i] == 'L')
				p--;
			else
				p++;
		}
		if(p < 0)
			return 1;
		if(p >= n)
			return 2;
		
	}

	return 0;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin >> n >> q >> s;
	for(int i = 0; i < q; i++)
		cin >> c[i] >> b[i];
	int r = n, l = 0, mid;
	while(r - l > 1){
		mid = (r + l) / 2;

	//	cout << "YO" << endl;
		if(f(mid) == 1)
			l = mid;
		else
			r = mid;
	}
	int r2 = n, l2 = 0;
	while(r2 - l2 > 1){
		mid = (r2 + l2) / 2;
		if(f(mid) == 2)
			r2 = mid;
		else
			l2 = mid;
	}
//	cout << r << " " << l << " " << r2 << " " << l2 << endl;
	cout << r2 - l - 1 << endl;
	return 0;
}


Measured memory_bytes: 976
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Swap<T>(ref T a, ref T b)
        {
            T temp = a;
            a = b;
            b = temp;
        }

        static void Main(string[] args)
        {
            int x, y, z;
            ReadInt(out x, out y, out z);
            Swap(ref x, ref y);
            Swap(ref x, ref z);
            Console.WriteLine($"{x} {y} {z}");
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static string YesNo(bool condition) => condition ? "Yes" : "No";
        static string YESNO(bool condition) => condition ? "YES" : "NO";

        #endregion
    }
}

Measured memory_bytes: 13268
<?php
while ( !feof(STDIN) ) {
  $line[] = trim(fgets(STDIN));
}

$lengthSequence = $line[0];
$numbers = explode(" ", $line[1]);

print($line[1]."\n");

for ($i = 1; $i < $lengthSequence; $i++) {
    $v = $numbers[$i];
    $j = $i - 1;
    while ($j >= 0 && $numbers[$j] > $v) {
        $numbers[$j + 1] = $numbers[$j];
        $j--;
    }
    $numbers[$j + 1] = $v;
    print(trim(implode(" ",$numbers))."\n");
}


Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;
struct node{
  node *prev,*next;
  int v;
  node(){next=NULL;}
  node(int v):v(v){next=NULL;}
};
struct mlist{
  node *head,*tail;
  mlist(){
    head=new node();
    tail=new node();
    head->next=tail;
    tail->prev=head;
  }
  void push_front(int v){
    node *tmp=new node(v);
    tmp->next=head->next;
    tmp->next->prev=tmp;
    head->next=tmp;
    tmp->prev=head;
  }
  void pop_front(){
    if(head->next==tail) return;
    node *tmp=head->next->next;
    if(tmp!=NULL) delete(head->next);
    head->next=tmp;
    tmp->prev=head;
  }
  void pop_back(){
    if(tail->prev==head) return;
    node *tmp=tail->prev->prev;
    if(tmp!=NULL) delete(tail->prev);
    tail->prev=tmp;
    tmp->next=tail;
  }
  void erase(int x){
    for(node *it=head->next;it!=tail;it=it->next){
      if(it->v==x){
	it->prev->next=it->next;
	it->next->prev=it->prev;
	delete(it);
	break;
      }
    }
  }
  int front(){
    return head->next->v;
  }
  bool empty(){
    return head->next==NULL;
  }
  node *begin(){
    return head->next;
  }
  node *end(){
    return tail;
  }
};
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  mlist l;
  for(int i=0;i<n;i++){
    string s;
    int x;
    cin>>s;
    if(s=="insert"||s=="delete") cin>>x;
    if(s=="deleteFirst"){
      l.pop_front();
      continue;
    }
    if(s=="deleteLast"){
      l.pop_back();
      continue;
    }
    if(s=="insert"){
      l.push_front(x);
      continue;
    }
    if(s=="delete"){
      l.erase(x);
      continue;
    }
  }
  bool f=0;
  for(node *it=l.begin();it!=l.end();it=it->next){
    if(f) cout<<" ";
    cout<<it->v;
    f=1;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 34340
#include <stdio.h>

int main(void){
	int w, h;
	int x, y, r;

	scanf("%d", &w);
	scanf("%d", &h);
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &r);

	if(((w >= x + r) && (x + r > 0)) && ((h >= y + r) && (y + r > 0))){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, m;
vector<int> s[20];
int p[20];
signed main() {

    cin >> n >> m;
    int k;
    for(int i = 0; i < m; i++) {
        cin >> k;
        s[i].resize(k);
        for(auto&&j:s[i]){
            cin >> j;
            j--;
        }
    }

    for(int i = 0; i < m; i++) cin >> p[i];
    
    int ans = 0;
    for(int i = 0; i < (1 << n); i++) {
        bool f = true;
        for(int j = 0; j < m; j++) {
            int count = 0;
            for(int k = 0; k < s[j].size(); k++) 
                count += !!(i & ( 1 << s[j][k])) ;
            if(count%2 != p[j]) f = false;
        }
        if(f) ans++;
    }

    cout << ans << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n;

const int INF = 1 << 29;

int main(void)
{
	while(cin >> n && n)
	{
		for (int i = 0; i < 9; i++)
		{
			int a;
			cin >> a;
			n -= a;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

bool is_palindrome(const std::string& s)
{
    for (int i = 0; i < s.size() / 2; i++)
    {
        if (s[i] != s[s.size() - 1 - i])
        {
            return false;
        }
    }
    return true;
}

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

    string ss;
    for (auto ch : s)
    {
        if (ch != 'x')
        {
            ss.push_back(ch);
        }
    }
    if (!is_palindrome(ss))
    {
        cout << -1 << endl;
    }
    else
    {
        int x_count = 0;

        int left = 0;
        int right = s.size() - 1;
        for (int i = 0; i < (ss.size() + 1) / 2; i++)
        {
            int left_x = 0;
            while (s[left] != ss[i])
            {
                if (s[left] == 'x')
                {
                    left_x++;
                }
                left++;
            }
            int right_x = 0;
            while (s[right] != ss[i])
            {
                if (s[right] == 'x')
                {
                    right_x++;
                }
                right--;
            }
            x_count += abs(left_x - right_x);

            left++;
            right--;
        }
        cout << x_count << endl;
    }
}


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

int main(void)
{
	char s[50];
	int a, cnt = 0;
	pair <string, vector <int> > res[128];
	while (scanf("%s %d", s, &a) != EOF){
		bool flag = false;
		for (int i = 0; i < cnt; i++){
			if (res[i].first == s){
				res[i].second.push_back(a);
				flag = true;
				break;
			}
		}
		if (!flag){
			res[cnt].first = s;
			res[cnt].second.push_back(a);
			cnt++;
		}
	}
	sort(res, res + cnt);
	for (int i = 0; i < cnt; i++){
		sort(res[i].second.begin(), res[i].second.end());
	}
	
	for (int i = 0; i < cnt; i++){
		cout << res[i].first << endl;
		for (int j = 0; j < res[i].second.size(); j++){
			cout << res[i].second[j];
			if (j+1 != res[i].second.size()) cout << " ";
			else puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
s = input().rstrip()
dir = set()
for i in range(len(s)):
  dir.add(s[i])
if len(dir)%2 == 0:
  if ('N' in dir and 'S' in dir) or ('E' in dir and 'W' in dir):
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3060
import collections
N = int(input())
A = list(map(int,input().split()))

d = collections.Counter(A)
su = 0
for val in d.values():
    su += int(val*(val-1)//2)
for i in range(N):
    val = d[A[i]]
    print(su - int(val*(val-1)//2) + int((val-1)*(val-2)//2))

Measured memory_bytes: 26780
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	char a;
	cin>>a;
	if(isupper(a)){
		cout<<"A"<<"\n";
	}else{
		cout<<"a"<<"\n";
	}

	
	
		


	
	return 0;
}

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

using namespace std;

int main() {
	int x;

	cin >> x;

	if (400 <= x && x <= 599)
		cout << "8";
	else if (600 <= x && x <= 799)
		cout << "7";
	else if (800 <= x && x <= 999)
		cout << "6";
	else if (1000 <= x && x <= 1199)
		cout << "5";
	else if (1200 <= x && x <= 1399)
		cout << "4";
	else if (1400 <= x && x <= 1599)
		cout << "3";
	else if (1600 <= x && x <= 1799)
		cout << "2";
	else if (1800 <= x && x <= 1999)
		cout << "1";
	cout << "\n";

	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2
typedef long long ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef pair<int, ll> pii;

struct Comp {
	bool operator() (pii a, pii b) {
		return a.second > b.second;
	}
};

int main()
{
	int N, M, s, t;
	cin >> N >> M >> s >> t;
	s--; t--;

	map< int, vector<pii> > edge;
	rep(i, 0, M)
	{
		int x, y;
		cin >> x >> y;
		x--; y--;
		edge[x].push_back(pii(y, 1));
		edge[y].push_back(pii(x, 1));
	}

	vi dist(N, INF);
	vb done(N, false);
	priority_queue<pii, vector<pii>, Comp> que;
	dist[s] = 0;
	que.push(pii(s, 0));
	while (!que.empty())
	{
		pii p = que.top(); que.pop();
		if (done[p.first]) continue;
		done[p.first] = true;
		for (pii pp : edge[p.first])
		{
			int newcost = p.second + pp.second;
			if (newcost < dist[pp.first])
			{
				dist[pp.first] = newcost;
				que.push(pii(pp.first, newcost));
			}
		}
	}

	vi dist2(N, INF);
	vb done2(N, false);
	dist2[t] = 0;
	que.push(pii(t, 0));
	while (!que.empty())
	{
		pii p = que.top(); que.pop();
		if (done2[p.first]) continue;
		done2[p.first] = true;
		for (pii pp : edge[p.first])
		{
			int newcost = p.second + pp.second;
			if (newcost < dist2[pp.first])
			{
				dist2[pp.first] = newcost;
				que.push(pii(pp.first, newcost));
			}
		}
	}

	int len = dist[t];
	vi from_s(len + 1, 0);
	vi from_t(len + 1, 0);
	rep(i, 0, N)
	{
		if (dist[i] <= len)
			from_s[dist[i]]++;
		if (dist2[i] <= len)
			from_t[dist2[i]]++;
	}

	ll ans = 0;
	rep(i, 0, len-1)
	{
		ans += from_s[i] * from_t[len - 1 - i - 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 22588
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
  const int MAX = 1010;
  vector<bool> isp(MAX, true);
  vector<int> primes;
  for (int i = 2; i < MAX; i++) {
    if (isp[i]) {
      primes.push_back(i);
      for (int j = i * i; j < MAX; j += i) {
        isp[j] = false;
      }
    }
  }
  int N;
  while (cin >> N) {
    ll res = 1;
    for (int p : primes) {
      int e = 0;
      for (int n = N; n > 0; n /= p) {
        e += n / p;
      }
      res = res * (e + 1) % MOD;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

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

    int A[2][N];

    rep(i,0,N) {
        cin >> A[0][i];
    }
    rep(i,0,N) {
        cin >> A[1][i];
    }

    int ans = 0;
    rep(i,0,N) {
        int tmp = 0;
        rep(j,0,i+1) {
            tmp+=A[0][j];
        }
        rep(j,i,N) {
            tmp+=A[1][j];
        }
        ans = max(ans,tmp);
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sqr(x) ((x)*(x))

using namespace std;
const double eps = 1e-9;
const int INF = (int)1e9 + 7;
const long long linf = (long long)1e18 + 7;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int MAXN =(int)1e6;

int main() {
    int n, k;
    cin >> n >> k;
    vector <ll> a(n), b(n);
    vector <int> good(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        if (a[i] <= k) {
            sum += b[i];
            good[i] = 1;
        }
    }

    ll ans = 0;
    for (ll i = 30; (1 << i) >= 0; --i) {
        int cur = (bool)((1 << i) & k);
        if (cur == 0) {
            for (int j = 0; j < n; ++j) {
                if (good[j] && ((a[j] >> i) & 1)) {
                    good[j] = 0;
                    sum -= b[j];
                }
            }
        } else {
            ll cur_bad = 0;
            for (int j = 0; j < n; ++j) {
                if (good[j] && ((a[j] >> i) & 1)) {
                    cur_bad += b[j];
                }
            }
            ans = max(ans, sum - cur_bad);
        }
    }
    ans = max(ans, sum);
    cout << ans;

    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main(void)
{
    int N;
    int i,flg;
    scanf("%d",&N);
    flg=0;
    for(i=0; i<=(double)N/7.0; i++){
        if((N-7*i)%4==0){
            flg=1;
            break;
        }
    }
    if(flg==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

using namespace std;
int main(void){
    int N;
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, -1, 0, 1};
    while (cin >> N && N) {
        int x[N] = {0};
        int y[N] = {0};
        int t = 0, l = 0, r = 0, b = 0;
        for (int i = 1; i < N; ++i) {
            int n, d;
            cin >> n >> d;
            x[i] = x[n] + dx[d];
            y[i] = y[n] + dy[d];
            t = max(t, y[i]);
            l = min(l, x[i]);
            r = max(r, x[i]);
            b = min(b, y[i]);
        }
        cout << (r - l + 1) << " " << (t - b + 1) << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3052
s = input()
n = len(s) + 1
s = s[0] + s + s[-1]

A = [0]
for i in range(n-1):
    if s[i] == '>' and s[i+1] =='>':
        A[-1] -= 1
    elif s[i] == '<' and s[i+1] =='<':
        A[-1] += 1
    else:
        A.append(0)
        if s[i+1] == '<':
            A[-1] += 1
        else:
            A[-1] -= 1

if s[0] == '>':
    A = [0] + A
if s[-1] == '<':
    A = A + [0]

m = len(A)
ans = 0

for j in range(m):
    A[j] = abs(A[j])
for i in range(m//2):
    a = max(A[2*i], A[2*i+1])
    b = min(A[2*i], A[2*i+1])
    ans += (a*(a+1)+b*(b-1))//2
            
        

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    REP(i,N){
        int a;
        cin >> a;
        a--;
        X[a] = i;
    }

    REP(i,N){
        cout << X[i]+1 << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<time.h>
typedef long long ll;
using namespace std;

bool isprime(int a) {
	bool ispri = true;

	for (int i = 2; i <= sqrt(a + 0.5); i++) {
		if (a % i == 0)
			ispri = false;
	}
	return ispri;
}
int main() {
	//freopen("run.in", "r", stdin);
	//freopen("run.out", "w", stdout);

	int n;
	cin >> n;
	int x, cnt = 0;
	for (int i = 0; i < n; i++) {
		
		cin >> x;
		if (isprime(x))
			cnt++;
	}
	cout << cnt << endl;

	return 0;

}

Measured memory_bytes: 3092
#include <stdio.h>
#define MAX 25
#define NIL -1

typedef struct node{
  int p;
  int l;
  int r;
}Node;

void preorder(int);
void inorder(int);
void postorder(int);

Node T[MAX];
int n = 0;

int main(){
  int i = 0;
  int v = 0, l = 0, r = 0, root = 0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      root = i;
    }
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");
  
  return 0;
}

void preorder(int u){
  if(u != NIL){
    printf(" %d",u);
    preorder(T[u].l);
    preorder(T[u].r);
  }
}

void inorder(int u){
  if(u != NIL){
    inorder(T[u].l);
    printf(" %d",u);
    inorder(T[u].r);
  }
}

void postorder(int u){
  if(u != NIL){
    postorder(T[u].l);
    postorder(T[u].r);
    printf(" %d",u);
  }
}



Measured memory_bytes: 2132
use strict;
my $N = <>;chomp $N;
my $M = 1e9+7;
my %DB;
my $sum=1;
my $zero=0;
for(my $i=0;$i<$N;$i++){
    my ($a,$b) = split(/ /,<>);
    if($a==0&&$b==0){
		$zero++;
	}else{
      #my $g = gcd($a,$b);
      my ($ga,$gb)=($a,$b);
      ($ga,$gb)=($gb,$ga%$gb)while$gb!=0;
      $a = $a/$ga;
      $b = $b/$ga; 
      if($a<0 || ($a==0&&$b>0 )){
        $a = -$a;
        $b = -$b;
      }
      my $f=0;
      if( $b<0){
        my $aa = -$b;
        $b = $a;
        $a = $aa;
        $f = 1;
      }
      my $str = "$a $b";
      if( ! defined($DB{$str}[$f] )){
        $DB{$str}[$f] = 1;
      }
      $DB{$str}[$f] = $DB{$str}[$f]*2%$M; 
	}  
}
foreach my $key ( keys %DB){
    for(0..1){
      if( ! defined($DB{$key}[$_])){
        $DB{$key}[$_] = 1;
      }
    }
    $sum = $sum *($DB{$key}[0]+$DB{$key}[1]-1)%$M; 
}
$sum = ($sum + $zero -1)%$M;
print "$sum";


sub gcd{ #最大公約数
    my ($a,$b) = @_;
    if($b == 0){
        return $a;
    }
    return gcd($b, $a%$b);
}

Measured memory_bytes: 76504
#abc158d
s=raw_input()
q=int(raw_input())
res=""
for i in range(q):
 x=raw_input().split()
 if x[0]=='1':
  res,s=s,res
 else:
  if x[1]=='1':
   res+=x[2]
  else:
   s+=x[2]
res=res[::-1]
print res+s


Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"

const int N = 1001;
int s[N][N];
int32_t main(){
	boost;
	int n;
	cin >> n;
	vector<int>v[n+1];
	for(int i = 1; i <= n; i++){
		for(int j = 1, x; j < n; j++) {
			cin >> x;
			v[i].push_back(x);
		}
		reverse(v[i].begin(),v[i].end());
		s[i][v[i].back()] = 1;
	}	
	int day = 0;
	int cnt = 0;
	while(true) {
		vector<pi>ve;
		for(int i = 1; i <= n; i++) {
			if(v[i].empty())
				continue;
			if(s[v[i].back()][i]) 
				ve.push_back({i,v[i].back()});
		}
		if(ve.empty())
			break;
		cnt += ve.size()/2;
		for(auto p : ve) {
			s[p.ff][p.ss] = 0;
			v[p.ff].pop_back();
			if(!v[p.ff].empty())
				s[p.ff][v[p.ff].back()] = 1;
		}
		day++;
	}
	if(2*cnt == n*(n - 1))
		cout << day << endl;
	else
		cout << -1 << endl;
}



Measured memory_bytes: 19156
#include <cstring>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <ctime>
#include <vector>
#include <cassert>
typedef long long i64;
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, k, c[N]; i64 ans;
int main()
{   
    n = read(), k = read(); for(int i = 1; i <= n; ++i) ++c[i%k];
    ans = c[0]+3*c[0]*(c[0]-1ll)+c[0]*(c[0]-1ll)*(c[0]-2ll);
    if(~k&1) ans += c[k/2]+3*c[k/2]*(c[k/2]-1ll)+c[k/2]*(c[k/2]-1ll)*(c[k/2]-2ll);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

#define A 0
#define B 1
#define C 2
#define D 3

int result[2][4];

int main()
{
  double buf[2];
  while(cin >> buf[0] >> buf[1])
  {
    for(int i = 0; i < 2; i++)
    {
      if(buf[i] >= 1.1)
        result[i][A]++;
      else if(buf[i] >= 0.6)
        result[i][B]++;
      else if(buf[i] >= 0.2)
        result[i][C]++;
      else
        result[i][D]++;
    }
  }

  for(int i = 0; i < 4; i++)
    cout << result[0][i] << " " << result[1][i] << endl;

  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

ll ans = 0, n = 0;
ll P = 998244353;
string x;
std::vector<ll> rui(300000, 1);
std::vector<ll> minu(300000, 0);

void check(ll num, ll block){
  ll o = 0;
  for(int i=0;i<num;i++) if(x[i]=='1') o = (o+rui[num-1-i])%P;
  string s="";
  for(int i=0;i<block;i++) for(int j=0;j<num;j++) s+=(i%2==0?x[j]:(x[j]=='1'?'0':'1'));
  if(s<=x) o = (o+1)%P;
  //std::cout << num << " " << o << '\n';
  ll tmp = (o-minu[num]); //current number
  for(int i=2;i*num<300000;i++) minu[i*num] = (minu[i*num] + tmp)%P;
  ans = (ans - ((2*(n-num)*tmp)%P) + P)%P;
}
int main(int argc, char const *argv[]) {
  std::cin >> n;std::cin >> x;
  ans = 2*n;
  for(int i=0;i<n;i++) {
    rui[i] = (i==0?1:(rui[i-1]*2)%P);
    if(x[n-1-i]=='1') ans = (ans + ((rui[i]*2*n)%P))%P;
  }
  vvl q = vv(0, 2, 0, ll);
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      if(i*i==n&&i%2==1) q.push_back(vll{i, i});
      if(i*i!=n){
        if(i%2==1) q.push_back(vll{n/i, i});
        if((n/i)%2==1) q.push_back(vll{i, n/i});
      }
    }
  }
  sort(q.begin(), q.end());
  for(int i=0;i<q.size();i++) check(q[i][0], q[i][1]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5784
a, b, k = map(int, input().split())
result_a = [i for i in range(a, min(b+1,a+k))]
result_b = [i for i in range(max(a,b-k+1), b+1)]
result_a.extend(result_b)
result = set(result_a)
for i in sorted(result):
    print(i)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int people_number[4][3][10];
	int n;
	int a, b, c, d;
	int i, j, k, l;
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				people_number[i][j][k] = 0;
			}
		}
	}
	
	scanf("%d", &n);
	
	for(l = 0; l < n; l++) {
		scanf("%d %d %d %d", &a, &b, &c, &d);
		people_number[a - 1][b - 1][c - 1] += d;
	}
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				printf(" %d", people_number[i][j][k]);
			}
			
			printf("\n");
		}
		if(i != 3) {
			printf("####################\n");
		}
	}
	
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int a[60];
  for (int i = 0; i < N; ++i) cin >> a[i];
  
  sort(a, a + N, greater<int>());

  int length = 0;
  for (int i = 0; i < K; ++i) {
    length += a[i];
  }
  
  cout << length << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
class Solver{
public:
    static const int MAXN=2e5+10;
    int N,K,C;
    char s[MAXN];
    int t1[MAXN];
    int t2[MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>K>>C;
        cin>>s+1;
        int work=1;
        int rest=C;
        for(int d=1;d<=N;d++){
            if(s[d]=='o'){
                if(rest>=C){
                    t1[work++]=d;
                    rest=0;
                }
                else rest++;
            }
            else rest++;
        }
        work=K;
        rest=C;
        for(int d=N;d>0;d--){
            if(s[d]=='o'){
                if(rest>=C){
                    t2[work--]=d;
                    rest=0;
                }
                else rest++;
            }
            else rest++;
        }
        for(int w=1;w<=K;w++){
            if(t1[w]==t2[w]){
                cout<<t1[w]<<"\n";
            }
        }
    }
};
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    (new Solver())->solve();
}

Measured memory_bytes: 3328
n = gets.to_i
aa = gets.split.map(&:to_i)

wat = []

sum = aa.inject(:+)
odd_sum = 0

aa.each_with_index do |a,i|
  odd_sum+=a if i%2==1
end

x0 = sum - 2 * odd_sum
wat << x0

1.upto(n-1) do |nn|
  # x_i = 2a_(i-1)-x_(i-1)
  wat << 2 * aa[nn-1] - wat.last
end

puts wat.join(' ')


Measured memory_bytes: 14084
#include<cstdio>
#include<cstring>
using namespace std;
int N,Pre[100005],a[100005];
long long A[100005],l=0,m,r=1e9+1,F[800005],cnt;
void in(int O,int l,int r,int k)
{
	if(l==r)
	{
		F[O]++;
		return ;
	}
	int mid=(l+r)/2;
	if(k<=mid)
	in(O*2,l,mid,k);
	else
	in(O*2+1,mid+1,r,k);
	F[O]=F[O*2]+F[O*2+1];
}
long long qu(int O,int l,int r,int s,int t)
{
	if(l==s&&r==t)
	return F[O];
	int mid=(l+r)/2;
	if(t<=mid)
	return qu(O*2,l,mid,s,t);
	if(s>mid)
	return qu(O*2+1,mid+1,r,s,t);
	return qu(O*2,l,mid,s,mid)+qu(O*2+1,mid+1,r,mid+1,t);
}
bool check()
{
	cnt=0;
	memset(F,0,sizeof(F));
	for(int i=1;i<=N;i++)
	if(A[i]>m)
	a[i]=1;
	else
	a[i]=-1;
	for(int i=1;i<=N;i++)
	Pre[i]=Pre[i-1]+a[i];
	for(int i=0;i<=N;i++)
	{
		cnt+=qu(1,0,N*2,0,Pre[i]+N);
		in(1,0,N*2,Pre[i]+N);
	}
	if(cnt*2>=(long long)N*(N+1)/2)
	return true;
	return false;
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	scanf("%lld",&A[i]);
	while(l+1<r)
	{
		m=(l+r)/2;
		if(check())
		l=m;
		else
		r=m;
	}
	m=l;
	printf("%lld",check()?r:l);
	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  string z;
  cin >> z;
  R(i,8)z.pop_back();
  cout << z << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>


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


int main(void)
{
	int h, w, n;

	while(scanf("%d%d%d", &h, &w, &n)==3)
	{
		vi a(n);
		vi f(w);

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
		}
		int x=0, y=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<a[i];j++)
			{
				if(y&1)
				{
					f[x--]=i+1;
				}
				else
				{
					f[x++]=i+1;
				}
				if(x<0 || w<=x)
				{
					for(int k=0;k+1<w;k++)
					{
						printf("%d ", f[k]);
					}
					printf("%d\n", f[w-1]);

					if(x<0) x=0;
					if(x>=w) x=w-1;
					y++;
				}
			}
		}
	}

	return 0;
}


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

int n, k;
int a[200003];
int b[200003];
set<int> s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=1;i<n;i++)
        b[i] = b[i-1] + (a[i-1] < a[i]);
    int ans = n-k+1;
    int same = 0;
    for(int i=k-1;i<n;i++)
        if(b[i] - b[i-(k-1)] == k-1) same++;
    for(int i=0;i<k;i++)
        s.insert(a[i]);
    for(int i=k;i<n;i++)
    {
        s.erase(a[i-k]);
        if(b[i] - b[i-(k-1)] == k-1)
        {
            s.insert(a[i]);
            continue;
        }
        if(*(s.begin()) > a[i-k] && *(s.rbegin()) < a[i])
        {
            ans--;
        }
        s.insert(a[i]);
    }
    cout << ans - max(same-1, 0);
}

Measured memory_bytes: 11264
n = int(input())
lis = [0] + list(map(int,input().split())) + [0]
b = 0
for i in range(n+1):
 b += abs(lis[i+1]-lis[i])
for i in range(1,n+1):
 if (lis[i-1] <= lis[i] <= lis[i+1]) or (lis[i+1] <= lis[i] <= lis[i-1]):
   print(b)
 else:
  print(b-abs(lis[i-1] - lis[i]) - abs(lis[i+1] - lis[i]) + abs(lis[i+1] - lis[i-1]))

Measured memory_bytes: 14172
#include <stdio.h>
#define N 44
int fibonacci(int x);
int F[N];

int main(){
  int i,n,ans;
  scanf("%d",&n);
  for(i=0;i<N;i++){
    F[i] = 0;
  }
  ans = fibonacci(n);
  printf("%d\n",ans);
  
  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1) return F[n] = 1;
  if(F[n] != 0) return F[n];
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}



Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

int dp[100010][13];

void solve(std::string S) {
    int N = S.size();
    dp[0][0] = 1;

    for(int i = 0; i < N; ++i) {
        for(int k = 0; k < 10; ++k) {
            if (S[i] == '0' + k || S[i] == '?') {
                for(int l = 0; l < 13; ++l) {
                    int c = (l * 10 + k) % 13;
                    dp[i + 1][c] = (dp[i + 1][c] + dp[i][l]) % MOD;
                }
            }
        }
    }

    cout << dp[N][5] << endl;
}

signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

using namespace std;

int main(){
    int n, cnt;
    string str;
    cin >> n >> str;
    cnt = 1;
    char s = str[0];
    for(int i=1; i<n; i++){
        char s_now = str[i];
        if(s == s_now) continue;
        cnt++;
        s = s_now;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <set>
#include <vector>
#define rep(i,n) for(int i=0; i< (int)(n); ++i)
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	int ans;
	if(2*c > (a+b)) ans = a*x + b*y;
	else{
		if(x > y) ans = 2*c*y + min(2*c,a)*(x-y);
		else ans = 2*c*x + min(2*c,b)*(y-x);
	}
	cout << ans << "\n";
} 


Measured memory_bytes: 256