akhauriyash/Code-Regression huggingface dataset:
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
void fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[1000006];
ll spf[1000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
    memset(spf,0,sizeof(spf));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p){
                prime[i]=false;
                if(spf[i]==0)
                {
                	spf[i]=p;
                }
                }
                
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
	sieve(n+4);
	for(int i=2;i<=n;i++)
	{
		if(spf[i]==0)
		spf[i]=i;
	}
	spf[1]=2;
	// cout<<spf[2]<<endl;
	ll ans=0;
	for(int i=n-1;i>=1;i--)
	{
		
		ll temp=1;
		int j=i;
		while(j%spf[j]==0)
		{
			int x=spf[j];
			ll cnt=0;
			while(j%x==0)
			{
				cnt++;
				j=j/x;
			}
			temp=temp*(cnt+1);
		}
		ans+=temp;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12444
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,ans=0;
  int count=0;
  string s,t;
  cin>>n>>s>>t;
  for(int i=0; i<n; i++){
    count=0;
    for(int j=0; j<n-i; j++){
      if(s[i+j]==t[j]){
	count++;
      }
    }
    if(count==n-i){
      ans=2*n-count;
      break;
    }else{
      ans=2*n;
    }
  }
  cout<<ans<<'\n';
  return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
using namespace std;

int main(){
    long long a,b;
    long long lcm,gcd;
    while(cin>>a>>b){

    lcm=a*b;

    while(b!=0){
    gcd=a%b;
    a=b;
    b=gcd;
    }

    cout<<a space lcm/a <<endl;
    }
}


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

P = list(map(int,input().split()))

ans = 0

for i in range(N):
    if P[i] == i+1:
        if i < N-1:
            now = P[i]
            P[i] = P[i+1]
            P[i+1] = now
        ans += 1
print(ans)

Measured memory_bytes: 83988
#include<bits/stdc++.h>
    using namespace std;
    #define int long long 
    #define mp make_pair
    #define pb push_back
    #define pii pair<int,int>
    #define F first
    #define S second
    int const M=2e5+10,inf=1e9+10;
    int a[M],n;
    void print(int x,int y)
    {
    	y=y xor x;
    	if(y==1)cout<<"Second";
    	else cout<<"First";
    	exit(0);
    }
    void bt(int now)
    {
    	int cnt=0;
    	for(int i=1;i<=n;i++)
    	{
    		cnt+=a[i]%2;
    	}
    	if(cnt>=2)
    	{
    		if(cnt%2==n%2)
    		{
    			print(1,now);
    		}
    		else print(0,now);
    	}
    	bool flag=0;
    	if(cnt==1)
    	{
    		if(cnt%2!=n%2)
    		{
    			print(0,now);
    		}
    		else
    		{
    			flag=1;
    			for(int i=1;i<=n;i++)
    			{
    				if(a[i]%2){
    					if(a[i]==1)
    					{
    						print(1,now);
    					}
    					a[i]--;
    				}
    			}
    			int tmp=0;
    			for(int i=1;i<=n;i++)tmp=__gcd(tmp,a[i]);
    			for(int i=1;i<=n;i++)a[i]/=tmp;
    			bt(1-now);
    		}
    	}
    }
    main()
    {
    	cin>>n;
    	for(int i=1;i<=n;i++)cin>>a[i];
    	if(n==1)
    	{
    		if(a[1]%2==1)cout<<"Second";
    		else cout<<"First";
    		return 0;
    	}
    	bt(0);
    }

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ab=lambda i,j:a[i] if abs(i-j)%2==0 else b[i]
inf=10**9
dp=[n*[inf]for _ in range(1<<n)]
dp[0][0]=0
for i in range(n):dp[1<<i][i]=i
for bit in range(1,1<<n):
  m=[0]*n
  ii=0
  for i in range(n):
    if bit&1<<i:
      m[i]=ii
      ii+=1
  bit_count=ii
  for i in range(n):
    if bit&1<<i==0:
      m[i]=ii
      ii+=1
  for i in range(n):
    if bit&1<<i:continue
    ci=ab(i,bit_count)
    for j in range(n):
      if bit&1<<j==0:continue
      cj=ab(j,bit_count-1)
      if cj>ci:continue
      dp[bit|(1<<i)][i]=min(dp[bit|(1<<i)][i],dp[bit][j]+m[i]-bit_count)
ans=inf
for i in range(n):ans=min(ans,dp[-1][i])
if ans==inf:ans=-1
print(ans)

Measured memory_bytes: 116144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >>N>>M;
    priority_queue<int> pr;
    for(int i=0;i<N;i++){
        int t;
        cin >>t;
        pr.push(t);
    }
    for(int i=0;i<M;i++){
        int t;
        t=pr.top();
        pr.pop();
        pr.push(t/2);
    }
    long long ans=0;
    while(!pr.empty()){
        int t=pr.top();
        pr.pop();
        ans +=t;
    }
    cout << ans<<endl;
    
    
}


Measured memory_bytes: 892
from collections import deque
import sys
n = int(input())
deq = deque()
sub_deq = {}
for cmd in sys.stdin.readlines():
    if cmd == 'deleteFirst\n':
        while deq:
            data = deq.pop()
            if data[1]:
                data[1] = 0
                break
    elif cmd == 'deleteLast\n':
        while deq:
            data = deq.popleft()
            if data[1]:
                data[1] = 0
                break
    else:
        cmd, val = cmd.split()
        if cmd == 'insert':
            data = [val, 1]
            deq.append(data)
            if val not in sub_deq:
                sub_deq[val] = [data]
            else:
                sub_deq[val].append(data)
        elif cmd == 'delete':
            if val in sub_deq:
                deq_v = sub_deq[val]
                while deq_v:
                    data = deq_v.pop()
                    if data[1]:
                        data[1] = 0
                        break
sys.stdout.write(" ".join(data[0] for data in reversed(deq) if data[1]))
sys.stdout.write('\n')


Measured memory_bytes: 420656
n = int(input())
dic = {}
for i in range(n):
  s = input()
  s = sorted(s)
  s = ''.join(s)
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1

ans = 0
for _ in dic:
  if dic[_]>1: ans = ans + int(dic[_]*(dic[_]-1)/2)
    
print(ans)

Measured memory_bytes: 17852
array = []
i = 0
while True:
    height, width = map(int, input().split())
    if height == 0 and width == 0:
        break
    array.append(height)
    array.append(width)


def frame(height, width):
    for i in range(height):
        for k in range(width):
            if i == 0 or i == height - 1 or k == 0 or k == width - 1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


while True:
    frame(array[i], array[i + 1])
    i += 2
    if i == len(array): break


Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
	int A,m,a[99],ba=0,ma=0;
	cin>>A>>m;
	for(int i=0;i<A;i++)
	{ 
		cin>>a[i];
		ba=ba+a[i];
		//cout<<ba<<" ";
	} 
	for(int i=0;i<A;i++)
	{ 
		if(ba<=a[i]*4*m)
		{ 
			ma++;
			//cout<<i<<" "<<ma<<" ";
		} 
	} 
	if(ma<m)
	{ 
		cout<<"No";
	} 
	else
	{ 
		cout<<"Yes";
	} 
	return 0;
} 

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//223
	int n;
	cin>>n;
	if(n<=999)cout<<"ABC";
	else cout<<"ABD";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;
int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll n,m,i,j,k,x,y,z;
	sc(n);
	if(n==1){
		printf("1\n");
		return 0;
	}	
	x=2;
	y=1;
	for(i=2;i<=n;i++){
		z=x+y;
		x=y;
		y=z;
	}
	pr(z);

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A>B){
        A=A+(A-1);
        printf("%d",A);
    }
    else if(B>A){
        B=B+(B-1);
        printf("%d",B);
    }
    else{
        A=A+B;
        printf("%d",A);
    }
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

const int INF = 1ll << 60;

signed main() {
	int n, t, q;
	cin >> n >> t >> q;
	vector<int> stops;
	vector<P> as(n);

	P pre;
	cin >> pre.first >> pre.second;
	as[0] = pre;
	rep(i, n - 1) {
		int a, d;
		cin >> a >> d;
		as[i + 1] = P(a, d);
		if (pre.second != d) {
			int pa = pre.first;
			stops.push_back((a + pa) / 2);
		}
		pre = P(a, d);
	}

	rep(i, q) {
		int x;
		cin >> x;
		x--;
		int a = as[x].first, d = as[x].second;
		int time;
		if (d == 1) {
			if (stops.size() && stops.back() < a) {
				time = INF;
			} else {
				time = *lower_bound(all(stops), a) - a;
			}
		} else {
			if (stops.size() && stops[0] > a) {
				time = INF;
			} else {
				time = a - *(--upper_bound(all(stops), a));
			}
		}

		if (time <= t) {
			cout << a + time * (d == 1 ? 1 : -1) << endl;
		} else {
			cout << a + t * (d == 1 ? 1 : -1) << endl;
		}
	}

	//system("pause");
}

Measured memory_bytes: 5076
n,m=map(int,input().split())
K=[]
S=[]
for i in range(m):
    x=list(map(int,input().split()))
    K.append(x[0])
    S.append(list(x[1:]))
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    flg=True
    for j in range(m):
        tmp=0
        for k in S[j]:
            if i>>(k-1) & 1:
                tmp+=1
        if tmp%2==p[j]:
            continue
        else:
            flg=False
    if flg:
        ans+=1

print(ans)

Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int mod = 1e9 + 7;

const int N = 2e5 + 5;

int n;
vector<pair<int ,int>> g[N];
int ans[N];

void DFS(int u, int p, int cur)
{
  ans[u] = cur;
  for(int i = 0 ; i < sz(g[u]) ; i++){
    int v = g[u][i].first;
    int c = g[u][i].second;
    if(v != p)
      DFS(v, u, cur ^ c);
  }
}

int main()
{
  scanf("%d", &n);
  for(int i = 1 ; i < n ; i++){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a, --b;
    g[a].pb(mp(b, c & 1));
    g[b].pb(mp(a, c & 1));
  }
  DFS(0, -1, 0);
  for(int i = 0 ; i < n ; i++)
    cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	cout << N * N * N;

	return 0;
}


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

int main(){
  int s;
  int h,t,o;
  cin >> s ;
  h = s / 100;
  t = (s - h * 100) / 10;
  o = s - h * 100 - t * 10;
  cout << h + t + o << endl;
}

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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    long long arr[n+10],sum=0,ans=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum=sum+arr[i];
    }
    sort(arr,arr+n,greater<long long>());
    if(k==0){
        cout<<sum;
    }
    else if(k>=n){
        cout<<0;
    }
    else {
        for(int i=0;i<n;i++){
        if(k!=0){

            k--;
        }
        else {
            ans=ans+arr[i];
        }
    }
    cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	int N, l, r;
	int all = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> l >> r;
		all += r + 1 - l;
	}
	cout << all << endl;
	return 0;
}

Measured memory_bytes: 256
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        k: usize,
        n: usize,
        a: [usize; n]
    }

    let mut d = 0;
    for i in 0..n-1 {
        d = max(d, a[i+1] - a[i]);
    }
    d = max(d, a[0] + (k - a[n-1]));

    println!("{}", k - d);
}


Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{

  int N; cin>>N;
  set<int> SET;
  for (int i = 0; i < N; i++)
  {
    int A; cin>>A; 
    auto itr = SET.find(A);
    if(itr == SET.end())
    {
      SET.insert(A);
    }
    else
    {
      SET.erase(itr);
    }
    
  }
  cout<<SET.size()<<endl;

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 4992
#着席位置は中央*奥
#問題は「Dinner」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2642&lang=jp)
#方針としては、自炊をする回数(0~n)を決め打ちし、それぞれの時の最大値を計算してその最大値を返すことにする
#n回自炊するとき、自炊パワーはn-1回自壊する時に比べ最終的に2増える。
#これを考えると、n回自炊する時、高まる自炊パワーによる幸福度の増加分はn*(n+1)となる
#したがって、まずリストdifsに「自炊と食堂の幸福度の差分」を全て入れる
#これを降順にソートし、n回自炊した時の幸福度の最大値をansに入れていく
#ansの最大値を出力して、終了
n,p,q = map(int,input().split())
cs = []
for i in range(n):
    cs.append(int(input()))
ans = [sum(cs)]
difs = [p * (q-i) - cs[i] for i in range(n)]
difs.sort(reverse = True)
for i in range(n):
    ans.append(ans[-1] + 2 * i * p + difs[i])
print(max(ans))



Measured memory_bytes: 71196
#include<stdio.h>
int main()
{
  int x,a,b,goukei=0;
  
  scanf("%d\n%d\n%d\n",&x,&a,&b);
  
  goukei=x-a;
  

   while(goukei>=0){
     goukei=goukei-b;
   }
  
  
  printf("%d", goukei+b);
  
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    vector<ll> ans(S.size(),0);
    // Rについて処理
    ll lastR =0;
    ll num =1;
    for(int i=1;i<S.size();i++){
        if(S[i] == 'R'){
            lastR =i;
            num++;
        }else{
            ans[i] += num/2;
            ans[i-1] += (num+1)/2;
            num =0;
        }

    }
    ll lastL =S.size()-1;
    num =1;
    for(int i=S.size()-2;i>=0;--i){
        if(S[i] == 'L'){
            lastL =i;
            num++;
        }else{
            ans[i] += num /2;
            ans[i+1] += (num+1)/2;
            num =0;
        }

    }
    for(ll p:ans){
        cout << p << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    int i, x, y, z;
    cin >> x >> y >> z;

    bool br = false;
    for(i=y; i<=z; i++){
        if(i%x==0){
            cout << "OK" << endl;
            br = true;
            break;
        }
    }
    if(br == false){
        cout << "NG" << endl;
    }




    return 0;
}


Measured memory_bytes: 3640
n, k, q = map(int, input().split())
l = [0 for i  in range(n)]

for i in range(q): 
    a = int(input()) -1
    l[a] += 1

for i in range(n):
    if k - (q - l[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<string>
#include<climits>
#define ll long long
#define mem(x) memset(x,0,sizeof(x)) 
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pi 3.14159265358979323846
const double eps=1e-6;
using namespace std;
typedef pair<int,int> pii;
const ll mod=1e9+7;
string a[200005];
int main()
{
	map<string,int> m;
	map<string,int> mm;
	int n;
	cin>>n;	
	int maxx=0;
	for(int i=0;i<n;i++)
	{
		a[i].clear();
		cin>>a[i];
		m[a[i]]++;
		if(m[a[i]]>maxx)
		maxx=m[a[i]];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(m[a[i]]==maxx&&mm[a[i]]==0)
		{
			cout<<a[i]<<endl;
			mm[a[i]]=1;
		}
	}
} 

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

//傾きは単調減少

struct ConvexHullTrick{
  std::deque<std::pair<long long, long long> > dq; //（傾き、切片）

  void add(long long a, long long b){
    std::pair<long long, long long> p0=std::make_pair(a, b);
    while(dq.size()>=2){
      int sz=dq.size();
      std::pair<long long, long long> p1=dq[sz-1];
      std::pair<long long, long long> p2=dq[sz-2];
      if((p0.second-p1.second)*(p0.first-p2.first) < (p0.second-p2.second)*(p0.first-p1.first))break;//交点のx座標を比較
      dq.pop_back();
    }
    dq.push_back(p0);
  }

  long long query(long long x){
    while(dq.size()>=2){
      long long v1=dq[0].first*x+dq[0].second;
      long long v2=dq[1].first*x+dq[1].second;
      if(v1<=v2)break;
      dq.pop_front();
    }
    return dq[0].first*x+dq[0].second;
  }

};

int N;
long long C;
long long h[1000000];
long long dp[1000000];

int main(){
  std::cin>>N>>C;
  for(int i=0;i<N;++i){
    std::cin>>h[i];
  }
  ConvexHullTrick d;
  for(int i=0;i<N;++i){
    if(i>0)
      dp[i]=C+h[i]*h[i]+d.query(h[i]);
    d.add(-2*h[i],h[i]*h[i]+dp[i]);//傾き、高さ
  }
  std::cout<<dp[N-1]<<std::endl;
  return 0;
}


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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3628
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

/*
ll gcd(ll A,ll B){
 while(A != 0){
 if(A < B){
   swap(A,B);
 }

   A %= B;

 }
 return B;
}
*/

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  int cnt = 0;
  int hantei = 1;
  rep(i,N){
    if(A.at(i) == hantei){
      hantei++;
      cnt++;
    }
  }
  if(cnt == 0){
    cout << -1 <<endl;
  }else{
    cout << N - cnt <<endl;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,h[30],c=0,d=0;
  cin >> n;
  rep(i,n)cin >> h[i];
  rep(i,n){
    if(d<=h[i]){
      d=h[i];
      c++;
    }
  }
  printf("%lld\n",c);
}

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

using namespace std;


int main() {
	int D;
	cin >>D;
	if (D == 25) {
		cout << "Christmas" << endl;
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
dic = defaultdict(int) #初期化する関数。

N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
#B = set(A)
for i in A:
  dic[i] +=1

beki = [1]
for i in range(32): #30に変更
  temp = beki[-1]
  beki.append(temp*2)
#print(beki)
L = [[] for _ in range(N)]
for i in range(N):
  for t in beki:
    now = t-A[i]
    if A[i] == now and dic[now] >=2:
      L[i].append(now)
    elif A[i] != now and now>0 and now in dic:
      L[i].append(now)
  L[i].append(A[i]) #自分を足しておく

#L.sort(key=len)
#print(L)
#print(dic)
ans = 0
for i in range(N):
  now = L[i].pop()
  #print(L[i],dic)
  for num in L[i]:
    if num in dic:
      if num == now and dic[now] > 1:
        dic[num] -=2
        ans += 1
        break
      elif num != now and dic[num] > 0 and dic[now] > 0:
        dic[num] -= 1
        dic[now] -= 1
        ans += 1
        break

print(ans)

Measured memory_bytes: 147532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int l;
    cin >> l;
    double n = (double)l/3;
    cout << fixed << setprecision(12) << n*n*n << endl;
}

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

int main(){
    int n;
    ll t, sum = 0, prev_t, maxt;
    cin >> n >> maxt >> prev_t;
    rep(i, n-1){
        cin >> t;
        sum += min(t - prev_t, maxt);
        prev_t = t;
    }
    cout << sum + maxt << "\n";
    return 0;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 00:53:55
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0)
        cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3604
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=2e5+5;
char s[N];ll res;int sf[N],n;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	fd(i,n,1)sf[i]=sf[i+1]+(s[i]=='W');
	fp(i,1,n)if(s[i]=='B')res+=sf[i+1];
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
    int plus,minus,kakeru,a,b,c ;
    cin >>  a >>  b ;

    plus = a+b;
    minus = a - b;
    kakeru = a*b;
    c = max(plus,minus);
    cout << max(c,kakeru) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {	
	// IOS
	ll T;
	// cin>>T;
	T = 1;
	// ll i = 1;
	
	while(T--){
		// cout<<"Case #"<<i<<": ";
		ll n;
		cin>>n;
		string s[n];
		map<string,ll> mp;
		for(int i = 0;i<n;i++)
		{
			cin>>s[i];
			mp[s[i]]++;
		}
		cout<<"AC x "<<mp["AC"]<<'\n';
		cout<<"WA x "<<mp["WA"]<<'\n';
		cout<<"TLE x "<<mp["TLE"]<<'\n';
		cout<<"RE x "<<mp["RE"]<<'\n';
	}
	return 0;
	
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
     
    using namespace std;
    using ull = unsigned long long;
     
    const int MAX_N = 400;
    const ull MAX_VAL = numeric_limits<ull>::max();
    ull costs[MAX_N + 1][MAX_N + 1];
    ull sums[MAX_N + 1][MAX_N + 1];
    ull inp[MAX_N + 1];
     
    int main() {
    	ios_base::sync_with_stdio(false);
    	int N; cin >> N;
    	for (int i = 0; i <= MAX_N; i++) {
    		for (int j = 0; j <= MAX_N; j++) {
    			costs[i][j] = MAX_VAL;
    		}
    	}
    	for (int i = 1; i <= N; i++) {
    		cin >> inp[i];
    		costs[i][i] = 0;
    	}
     
    	for (int i = 1; i <= N; i++) {
    		sums[i][i] = inp[i];
    		for (int j = i + 1; j <= N; j++) {
    			sums[i][j] = inp[j] + sums[i][j - 1];
    		}
    	}
    	
    	for (int L = 1; L <= N; L++) {
    		for (int start = 1; start + L <= N; start++) {
    			for (int div = 0; div + 1 <= L; div++) {
    				costs[start][start + L] = min(costs[start][start + L], costs[start][start + div] + costs[start + div + 1][start + L] + sums[start][start + L]);
    			}
    		}
    	}
    	cout << costs[1][N] << endl;
    	return 0;
    }

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

int main() {
      string str;
      cin>>str;
      int c1=0,c2=0;
 for(int i=0;i<str.length();i++)
 {     if(str[i]== '+')
       c1++;
      else if(str[i]== '-')
       c2++;
}
    if(c1>=c2) cout<<(c1-c2)<<endl;
    else
      cout<<(c1-c2)<<endl;
        
     
	return 0;
}

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

int main(){
    string s;
    int ans = 0;
    int price = 700;
    
    cin >> s;
    
    if (s[0] == 'o')
        ans++;
    if (s[1] == 'o')
        ans++;
    if (s[2] == 'o')
        ans++;

    price = price + ans * 100;
    cout << price << endl;
}


Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  string s;cin>>s;
  int n = sz(s);

  int res = INF;
  rep(i, n-2){
    chmin(res, (int)abs(753 - stoi(s.substr(i, 3))));
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    string x;
	cin >> x;
    string ans;
    if(x=="a"||x=="i"||x=="u"||x=="e"||x=="o")ans="vowel";
    else ans = "consonant";
      cout << ans << endl;
}

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

class Team{
public:
  int id;
  char name;
  int win, lose;

  Team(){}
  Team(int id, char name, int win, int lose):
    id(id), name(name), win(win), lose(lose){}

  bool operator<(const Team &team)const{
    if(win == team.win){
      if(lose == team.lose){
        return id < team.id;
      }
      return lose < team.lose;
    }
    return win > team.win;
  }
};

int main(){
  int n;

  while(cin >> n){
    if(n == 0){
      break;
    }

    Team t[n];

    for(int i = 0; i < n; i++){
      t[i].id = i;
      cin >> t[i].name;

      t[i].win = 0;
      t[i].lose = 0;

      for(int j = 0; j < n - 1; j++){
        int x;
        cin >> x;

        if(x == 0) t[i].win++;
        else if(x == 1) t[i].lose++;
      }
    }

    sort(t, t + n);

    for(int i = 0; i < n; i++){
      cout << t[i].name << endl;
    }
  }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 2e5 + 5;
const int oo = 1e9;

int movex[4] = {-1, 1, 0, 0};
int movey[4] = {0, 0, -1, 1};

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    for (auto &it : v) cin >> it;
    vector<vector<int>> reach(h, vector<int>(w, oo));
    queue<pair<int, int>> bfs;
    bfs.push({x1, y1});
    reach[x1][y1] = 0;
    while(!bfs.empty()) {
        auto now = bfs.front(); bfs.pop();
        int xx = now.first, yy = now.second;
        for (int move=0;move<4;++move) {
            for (int d=1;d<=k;++d) {
                int x = xx + movex[move] * d;
                int y = yy + movey[move] * d;
                if (x < 0 || x >= h || y < 0 || y >= w) break;
                if (v[x][y] != '.') break;
                if (reach[x][y] < reach[xx][yy] + 1) break;

                if (reach[x][y] > reach[xx][yy] + 1) {
                    bfs.push({x, y});
                    reach[x][y] = min(reach[xx][yy] + 1, reach[x][y]);
                }
            }
        }
    }
    int ans = reach[x2][y2];
    if (ans >= oo) ans = -1;
    cout << ans << '\n';
} 
int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 12160
from collections import defaultdict
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

N = int(input())
Slist = []
for i in range(N):
    S = input()
    Slist.append(S)
Slist.sort(key=len)
dic = defaultdict(lambda:defaultdict(int))
ans = 0
for S in Slist:
    alp = set()
    l = len(S)
    RH = RollingHash(S,37,10**18+9)
    for i in range(len(S)):
        alp.add(S[i])
        alpdic = dic[RH.get(i+1,l)]
        for X in alpdic.keys():
            if X in alp:
                ans += alpdic[X]
    dic[RH.get(1,l)][S[0]] += 1
print(ans)

Measured memory_bytes: 510480
#include<iostream>
using namespace std;
int main(){
	int N;
  	cin>>N;
  	int A[2][N];
  	for(int i=0;i<N;++i){
     	cin>>A[0][i];
    }
    for(int i=0;i<N;++i){
     	cin>>A[1][i];
    }
  	int max=0;
  	for(int cnt=0;cnt<N;++cnt){
      	int sum=0;
  		for(int i=0;i<=cnt;++i){
    		sum+=A[0][i];
    	}
    	for(int j=cnt;j<N;++j){ 
      		sum+=A[1][j];
    	}
      if(sum>max) max=sum;
  	}
  cout<<max<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    set<int>t;
    for(int i=n-1,p=0;i>=0;i--)
    {
        if(s[i]=='o')++p,t.insert(i),i-=c;
        if(p>k)return 0;
    }
    for(int i=0,p=0;i<n&&p<k;i++)
    {
        if(s[i]=='o')++p,(t.find(i)!=t.end()?cout<<i+1<<endl:cout<<""),i+=c;
    }
    return 0;
}


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

int main(){
  int n,m;//問題数/提出数
  cin >> n >> m;
  vector<int> p(m);//問題番号
  vector<string> s(m);//AC or WA
  for(int i=0;i<m;i++)
    cin >> p.at(i) >> s.at(i);
  
  vector<int> a(n);//各問のAC数
  
  for(int i=0;i<m;i++){
    if(s.at(i)=="AC")
      a.at(p.at(i)-1)++;
  }
  
  int k=0;
  for(int i=0;i<n;i++){
    if(a.at(i)!=0)
      k++;
  }
  
  cout << k << ' ';
  
  k=0;
  vector<int> b(n);
  
  for(int i=0;i<m;i++){
    if(s.at(i)=="AC")
      b.at(p.at(i)-1)++;
    else if(b.at(p.at(i)-1)==0&&a.at(p.at(i)-1)!=0)
      k++;
  }
  cout << k;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    int can=w%2==0&&h%2==0?(w/2==x&&h/2==y?1:0):0;
    printf("%.9f %d\n",0.5*w*h,can);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};

int V, E;
//vector<vector<edge>> es; //隣接リスト
bool used[10000];
vector<vector<edge>> es;

pair<int, vector<edge>> prim()  //重さの合計と辺の集合を返す
{
	memset(used, false, sizeof(used));
	vector<edge> res;
	int sum = 0;

	priority_queue<edge,vector<edge>,greater<edge>> que;
	que.push(edge{ -1, 0, 0 });

	while (!que.empty())
	{
		edge e = que.top(); que.pop();
		if (used[e.to]) continue;
		if (e.from >= 0) res.push_back(e);
		sum += e.cost;
		used[e.to] = true;
		for(edge i:es[e.to])
		{
			if (!used[i.to]) que.push(i);
		}
	}
	return pair<int, vector<edge>>(sum, res);
}

int main()
{
	cin >> V >> E;
	es.resize(V);

	REP(i, E)
	{
		int a, b, c;
		cin >> a >> b >> c;
		es[a].push_back(edge{ a, b, c });
		es[b].push_back(edge{ b, a, c });
	}

	cout << prim().first << endl;
	vector<edge> v = prim().second;
}

Measured memory_bytes: 7784
#include<cstdio>
using namespace std;
int a[4][4];
int main() {
	scanf("%d%d%d",&a[1][1],&a[1][2],&a[2][2]);
	a[0][0]=a[2][2]*3;
	a[1][3]=a[0][0]-a[1][1]-a[1][2];
	a[3][1]=a[0][0]-a[1][3]-a[2][2];
	a[3][3]=a[0][0]-a[1][1]-a[2][2];
	a[2][1]=a[0][0]-a[1][1]-a[3][1];
	a[2][3]=a[0][0]-a[2][1]-a[2][2];
	a[3][2]=a[0][0]-a[1][2]-a[2][2];
	for(int i=1;i<=3;i++) {
		for(int j=1;j<=3;j++) {
			printf("%d ",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
import Control.Applicative

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve n = f 0 20
  where
    f l r
      | l + 1 == r = r
      | otherwise = let m = (l + r) `div` 2
                    in case compare (3 ^ m) n of
                        GT -> f l m
                        EQ -> m
                        LT -> f m r



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

vector<int> divisors(int N) {
    vector<int> res;
    for(int d=1; d*d<=N; d++) {
        if(N % d == 0) {
            res.emplace_back(d);
            res.emplace_back(N/d);
        }
    }
    return res;
}

int sub(string A, string B) {
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());

    int N = A.size();
    for(int i=2; i<N; i++) {
        if(A[i] != B[i]) return 100;
    }

    string sa = A.substr(0, 2), sb = B.substr(0, 2);
    reverse(sa.begin(), sa.end());
    reverse(sb.begin(), sb.end());
    // fprintf(stderr, "sa = %s, sb = %s\n", sa.c_str(), sb.c_str());
    return stoi(sa) - stoi(sb);
}

int solve1(string &s, int d) {
    string mi(d, '9'), ma(d, '0');
    int N = s.length();
    for(int i=0; i<N; i+=d) {
        string t = s.substr(i, d);
        mi = min(mi, t);
        ma = max(ma, t);
    }
    // fprintf(stderr, "d = %d, ma = %s, mi = %s\n", d, ma.c_str(), mi.c_str());
    return sub(ma, mi);
}

int solve2(string &s) {
    // i 桁目、最大 => 最小の最大値
    int N = s.size();
    vector< vector<int> > dp(N + 1, vector<int>(100, -1));
    if(N >= 1) dp[1][stoi(s.substr(0, 1))] = stoi(s.substr(0, 1));
    if(N >= 2 and N != 2) dp[2][stoi(s.substr(0, 2))] = stoi(s.substr(0, 2));
    
    for(int i=0; i<N; i++) {
        for(int j=0; j<100; j++) {
            if(dp[i][j] < 0) continue;
            for(int k=1; k<=2; k++) {
                if(i + k > N) continue;
                int val = stoi(s.substr(i, k));
                int a = j, b = dp[i][j];
                int ma = max({a, b, val});
                int mi = min({a, b, val});
                dp[i+k][ma] = max(dp[i+k][ma], mi);
            }
        }
    }

    int ans = 100;
    for(int i=0; i<100; i++) {
        if(dp[N][i] < 0) continue;
        ans = min(ans, i - dp[N][i]);
    }
    // fprintf(stderr, "ans = %d\n", ans);
    return ans;
}

int main() {
    string s; cin >> s;
    int N = s.length();

    int ans = 10;
    for(auto d : divisors(N)) {
        if(d == N) continue;
        ans = min(ans, solve1(s, d));
    }

    ans = min(ans, solve2(s));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 45972
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

vector<int> g[100];
vector<bool> vi(100);
map<P, bool> mp;

void dfs(int a) {
	vi[a] = true;
	for (auto& c : g[a]) {
		if (vi[c]) continue;
		if (mp[P(a, c)]) continue;
		dfs(c);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<P> p(m);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[i] = make_pair(a, b);
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	int ans = 0;
	rep(i, m) {
		mp[P(p[i].first, p[i].second)] = true;
		mp[P(p[i].second, p[i].first)] = true;
		rep(i, n) vi[i] = false;
		dfs(0);
		bool elf = true;
		rep(i, n) if (!vi[i]) elf = false;
		if (!elf) ans++;
		mp[P(p[i].first, p[i].second)] = false;
		mp[P(p[i].second, p[i].first)] = false;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define MAX 1000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

char a[MAX + 5][MAX + 5];
int c[MAX + 5][MAX + 5];
set<int> graph[MAX * MAX + 5];
int dis[MAX * MAX + 5], h, w;

int dir[4][2] = {{0,  1},
                 {1,  0},
                 {0,  -1},
                 {-1, 0}};

bool ok(int x, int y) {
    return x >= 0 and x < h and y >= 0 and y < w and a[x][y] != '#';
}

void dfs(int x, int y, int cc) {
    c[x][y] = cc;
    for (int i = 0; i < 4; ++i) {
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if (ok(xx, yy) and !c[xx][yy]) {
            dfs(xx, yy, cc);
        }
    }
}

int bfs(int c1, int c2) {
    queue<int> q;
    q.push(c1);
    memset(dis, -1, sizeof(dis));
    dis[c1] = 0;
    while (!q.empty()) {
        auto z = q.front();
        q.pop();
        for (auto w:graph[z]) {
            if (dis[w] == -1) {
                dis[w] = dis[z] + 1;
                q.push(w);
            }
        }
    }
    return dis[c2];
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int i, j, k, l, cc = 0;
    int s1, s2, d1, d2;
    cin >> h >> w;
    cin >> s1 >> s2 >> d1 >> d2;
    for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) {
            if (!c[i][j] and a[i][j] != '#') {
                dfs(i, j, ++cc);
            }
        }
    }
    for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) {
            if (a[i][j] != '#') {
                int x = i - 2, y = j - 2;
                for (k = x; k < x + 5; ++k) {
                    for (l = y; l < y + 5; ++l) {
                        if (ok(k, l) and c[k][l] != c[i][j]) {
                            graph[c[i][j]].insert(c[k][l]);
                        }
                    }
                }
            }
        }
    }
    cout << bfs(c[s1 - 1][s2 - 1], c[d1 - 1][d2 - 1]);

    return 0;
}


Measured memory_bytes: 77896
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long a, b, g, ans, k, ct = 0, i;
	cin >> a >> b >> k;
	
	for (i = min(a, b); i >= 1; i--) {
		if ((a % i == 0) && (b % i == 0)) {
			ct++;
			if (ct == k) ans = i;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256