akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()


def main():
    n, s = map(int, input().split())
    A = list(map(int, input().split()))
    mod = 998244353
    dp = np.zeros(3001, dtype=np.int64)
    dp[0] = 1
    for AA in A:
        dp = dp*2+np.concatenate([np.zeros(AA, dtype=np.int64), dp[:3001-AA]])
        dp %= mod
    print(dp[s])





if __name__ == '__main__':
    main()


Measured memory_bytes: 27636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
s = readline().rstrip().decode('utf-8')

if s[0] == 0: #反転からスタート
    r = 0
else: #無操作からスタート
    r = 1

if r==0:
    lst1 = [0] #裏からに調整
else:
    lst1 = []
res = 0
cache = str(r)
for i in s:
    if i != cache:
        lst1.append(res)
        cache = "1" if cache=="0" else "0"
        res = 1
    else:
        res += 1

lst1.append(res)
lst1.append(0)

#全部1で埋められるなら
if len(lst1) <= 2*k:
    print(n)
    exit()

#累積和
for i in range(len(lst1)-1):
    lst1[i+1] += lst1[i]

def cumsumdif(a,b,lst): #求めたい差のインデックスを入れる
    if a == 0:
        return lst[b]
    else:
        return lst[b] - lst[a-1]
i = 0
ans = 0
while True:
    if i+(k*2) >= len(lst1):
        break
    ans = max(ans,cumsumdif(i,i+2*k,lst1))
    i += 2

print(ans)








Measured memory_bytes: 45424
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    ll k,n; cin>>k>>n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    
    int mx = k-a[n-1]+a[0];
    
    rep(i,n-1){
        chmax(mx, a[i+1]-a[i]);
    }
    cout << k-mx << ln;
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis1=LI()
lis2=LI()
u=sum(lis2)-sum(lis1)
count=0
if u<0:
    print("No")
    exit()
for i in range(n):
    count+=-(-max(0,lis2[i]-lis1[i])//2)
#print(count)
if count<=u:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 10840
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[100];
int d[110];
int dp[110][31];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		int c;scanf("%d",&c);
		for(int i=0;i<110;i++)d[i]=-1;
		for(int i=0;i<c;i++){
			int p,q;scanf("%d%d",&p,&q);
			p--;
			if(!~d[p]||d[p]>q)d[p]=q;
		}
		for(int i=0;i<110;i++)for(int j=0;j<31;j++)dp[i][j]=999999999;
		dp[0][0]=0;
		for(int i=0;i<100;i++){
			for(int j=0;j<a;j++){
		//		printf("%d %d: %d\n",i,j,dp[i][j]);
				if(!~d[i]||b[j]<=d[i])dp[i+1][(j+1)%a]=min(dp[i+1][(j+1)%a],dp[i][j]);
				dp[i+1][1%a]=min(dp[i+1][1%a],dp[i][j]+1);
			}
		}
		int ret=999999999;
		for(int i=0;i<a;i++)ret=min(ret,dp[100][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

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

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n;
	vi a(n), b(n,0);
	FOR(i,1,n){cin >> a[i]; b[(a[i]-1)]++;}
	REP(i,n){
    	cout << b[i] << endl;
    }
}


Measured memory_bytes: 6364
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();

        for (int i=0; i<m; i++) {
            int tmp = sc.nextInt();
            n -= tmp;
        }

        if (n >= 0) {
            System.out.println(n);
        } else {
            System.out.println(-1);
        }

    }
}


Measured memory_bytes: 46400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(ll n){
    vector<vec> cnt(10,vec(10,0));
    rep(i,1,n+1){
        string s=to_string(i);
        ll m=s.length();
        cnt[s[0]-'0'][s[m-1]-'0']++;
    }
    ll ans=0;
    rep(i,1,10){
        rep(j,1,10){
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    cout<<ans<<endl;
}

int main(){
    ll n;
    scanf("%lld",&n);
    solve(n);
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N,vector<int>(2));
  for(vector<int> &i:A)
    cin>>i.at(0)>>i.at(1);
  double k=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<i;j++){
      int x=A.at(i).at(0)-A.at(j).at(0),y=A.at(i).at(1)-A.at(j).at(1);
      k+=pow(x*x+y*y,0.5);
    }
  cout<<setprecision(16)<<k*2/N<<endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var d = p[0];
		var n = p[1];
		
		long q = (long)Math.Pow(100, d);
		if(n==100)
		{
		Console.WriteLine(q*101);
		}
		else
		Console.WriteLine(q*n);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27572
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<deque>

using namespace std;

int N, M, X;
vector<int> A(1000, 0);

int input(){
  cin >> N >> M >> X;
  for( int i = 0; i < M; i++ ){
    int x = 0;
    cin >> x;
    A[x] += 1;
  }
  return 0;
}

int run(){
  int c1 = 0, c2 = 0;
  for( int i = 0; i < X; i++ ){
    c1 += A[i];
  }
  for( int i = X; i < N; i++ ){
    c2 += A[i];
  }
  cout << (c1<c2?c1:c2) << endl;
  return 0;
}


int main(int argc, char *argv[]){
  input();
  run();
  return 0;
}






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

int main() {
  int h, w, n;
  cin >> h;
  cin >> w;
  cin >> n;
  
  if (h >= w) {
    for (int i = 1; i < w + 1; i++) {
      if (h * i >= n) {
        cout << i << endl;
        break;
      }
    }
  }
  else {
    for (int i = 1; i < h + 1; i++) {
      if (w * i >= n) {
        cout << i << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}


int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		ll n;
		cin>>n;
		ll a[n];
		rep(i,n){
			cin>>a[i];
		}
		ll maxi = a[0];
		ll ans = 0;
		repA(i,1,n-1){
			if(a[i]<maxi){
				ans+=maxi-a[i];
			}
			maxi = max(maxi,a[i]);
		}
		cout<<ans;
	}
	return 0;
}


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int N;
    cin >> N;
    vector<int> house(N);
    for(int i=0;i<N;i++) cin >> house[i];
    int max = house[0];
    int min = house[0];
    for(int i=1;i<N;i++){
        if(max < house[i]) max = house[i];
        if(min > house[i]) min = house[i];
    }
    cout << max-min << endl;
    return  0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF (1<<29)
using namespace std;
 
const double EPS=1e-10;
 
struct rod{
  double l,r,w;
  rod(double l=0,double r=0,double w=INF):l(l),r(r),w(w){}
};
 
rod Merge(rod a,rod b){
  rod res;
  res.w=a.w+b.w;
  double mid=b.w/(a.w+b.w);
  res.l=min(-b.w/(a.w+b.w)+a.l,b.l+(1-mid));
  res.r=max(a.w/(a.w+b.w)+b.r,a.r-mid);
  return res;
}

double r,ans;
 
void rec(vector<rod>v){
  int vl=v.size();
  if(vl<=1){
    double res=v[0].r-v[0].l;
    if(res<r-EPS)ans=max(ans,res);
    return;
  }
  for(int i=0;i<vl;i++){
    for(int j=0;j<vl;j++){
      if(i==j)continue;
      vector<rod>nx;
      for(int k=0;k<vl;k++){
        if(k==i || k==j)continue;
        nx.push_back(v[k]);
      }
      nx.push_back(Merge(v[i],v[j]));
      rec(nx);
    }
  }
 
}
 
int main(void){
 
  int T;
  cin >> T;
  while(T--){
    int s;
    cin >> r >> s;
    vector<rod>v(s);
    for(int i=0;i<s;i++)cin >> v[i].w;
    ans=-INF;
    rec(v);
    if(ans<0)cout << -1 << endl;
    else printf("%.16f\n",ans);
  }
  return 0;
}

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

//--> definitions
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=b-1;i>=a;i--)

//--> typedef
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<pii,int> piii;
typedef tuple<int,int,int> tiii;

#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define INF 1e9

const int maxN = 1e4+11;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    cin>>n;
    
    int k;
    cin>>k;
    
    int a[10];
    memset(a,1,sizeof(a));
    FOR(i,0,k){
        int j;
        cin>>j;
        a[j]=0;
    }
    
    while(1){
        bool ok=false;
        int x=n;
        while(x){
            int rem=x%10;
            if(a[rem]==0) {
                ok = true ;
                break;
            }
            x=x/10;
        }
        if(!ok) break;
        ++n;
    }
    
    cout<<n<<"\n";


	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[n-1];
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>
#include <numeric>
#include <set>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;

int Right[4];
int Left[4];

int main()
{
	double r, l;

	while (cin >> r >> l){
		if (r >= 1.1)
			Right[0]++;
		if (l >= 1.1)
			Left[0]++;
		if (r < 1.1&&r>=0.6)
			Right[1]++;
		if (l < 1.1&&l>=0.6)
			Left[1]++;
		if (r <0.6&&r>=0.2)
			Right[2]++;
		if (l <0.6&&l>=0.2)
			Left[2]++;
		if (r <0.2)
			Right[3]++;
		if (l < 0.2)
			Left[3]++;
	}
	REP(i, 4){
		cout << Right[i] << " " << Left[i] << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int a,b;
    cin >> a >> b;
    a--,b--;
    bool ans[3] = {true,true,true};

    ans[a] = false;
    ans[b] = false;

    for(int i=0;i<3;i++){
        if(ans[i]){
            cout << (i+1) << endl;
            break;
        }
    }
    
    

}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n, x, a[1000];

int main(){
	cin >> n >> x;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(i < n-1 && x > a[i]){
			cnt++;
			x -= a[i];
		}
		else if(a[i] == x) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;

   
    int count = 0;

    for(int i=0;i<N-1;i++){
       if(S[i] != S[i+1]){
          count += 1;
       }
    }

    cout << count + 1;
    return 0;
}

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

#define INF 1E18



int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    ll ans = 0;
    
    if(a >= k){
        ans = k;
        cout << ans <<endl;
        return 0;
    }
    else if(a+b >= k){
        ans = a;
        cout << ans <<endl;
        return 0;
    }
    else{
        ans = a - (k-a-b);
        cout << ans <<endl;
        return 0;

    }


    return 0;
}

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

int main() {
  int64_t n, m;
  cin >> n >> m;
  int64_t ans;
  if (n*2 > m) ans = m/2;
  if (n*2 <= m) {
    m -= 2*n;
    ans = n;
    ans += m/4;
  }
  cout << ans << endl;
}


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

int main(){
    int n,k,q; cin >> n >> k >> q;
    vector<int> point(n,k);
    rep(i,q){
        int a; cin >> a;
        point[a-1]++;
    }
    rep(i,n){
        point[i] -= q;
        if(point[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    int c500;
    int c100;
    int c50;
    int c10;
    int c5;
    int c1;
    c500 = ceil(x/500);
    x = x%500;
    c5 = ceil(x/5);
    x = x%5;
    cout << c500*1000+c5*5 << endl;
}




Measured memory_bytes: 256
/*
🧡 QMsh 🧡
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MOD = (int)1e9 + 7;

signed main()
{
#ifdef POSPELOV
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    vector <int> arr(n);
    for (int &i : arr)
        cin >> i;
    map <int, int> mp;
    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        int old = ans;
        if (i > 0 && arr[i] != arr[i - 1])
        {
            ans = (ans + mp[arr[i]]) % MOD;
        }
        if ((i > 0 && arr[i] != arr[i - 1]) || i == 0)
            mp[arr[i]] = (mp[arr[i]] + old) % MOD;
    }
    cout << ans;
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    deque<char> dq;
    string s;cin>>s;
    REP(i,SIZE(s)){
        dq.push_back(s[i]);
    }

    int q;cin>>q;

    int r = 0;

    REP(i,q){
        int t;cin>>t;
        if(t==1){
            r = (r+1)%2;
        }
        else{
            int f;cin>>f;
            char c;cin>>c;

            if((r+f)%2 == 1){
                //s = c+s;
                dq.push_front(c);
            }
            else{
                //s = s+c;
                dq.push_back(c);
            }

        }
    }

    if(r==1){
        while(!dq.empty()){
            cout<<dq.back();
            dq.pop_back();
        }
        cout<<endl;
    }
    else{
        while(!dq.empty()){
            cout<<dq.front();
            dq.pop_front();
        }
        cout<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  string str1,str2;
  vector<int> ans(n);
  cin.ignore();
  for(int i=0; i<n; i++){
    vector<char> a;
    vector<char> b;
    getline(cin,str1);
    for(int j=0; j<(int)str1.size(); j++){
      char ch=str1[j];
      a.push_back(ch);
    }
    getline(cin,str2);
    for(int j=0; j<(int)str2.size(); j++){
      char ch=str2[j];
      b.push_back(ch);
    }
  	int path[a.size()+1][b.size()+1];
  	for(int h=0; h<a.size()+1; h++){
  		for(int w=0; w<b.size()+1; w++){
  			if(h==0 || w==0){
  				path[h][w]=0;
  			}else{
  				int max=path[h-1][w];
  				if(max<path[h][w-1]) max=path[h][w-1];
  				if(a[h-1]==b[w-1] && max<path[h-1][w-1]+1){
  					max=path[h-1][w-1]+1;
  				}
  				path[h][w]=max;
  			}
  		}
  	}
  	ans[i]=path[a.size()][b.size()];
  }
  for(int i=0; i<n; i++){
  	cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 7060
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 16:56:16
**/
#include <bits/stdc++.h>

using namespace std;
  
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, M, sum = 0, cont = 0;
 
	cin >> N >> M;
	vector<int> v(N);
	for(int i=0; i < N; i++)
	{
		cin >> v[i];
		sum+= v[i];
	}
 
	bool popular = false;
	for(int i=0; i<N; i++)
	{
		if(v[i]*4*M >= sum) cont++;
		if(cont == M)
		{ 
			popular = true;
			break;
		}
	}
	popular ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> seat(N);
  for(int i = 0; i < N; i++) {
    cin >> seat.at(i).first >> seat.at(i).second;
  }

  int sum = 0;
  for(pair<int,int> group : seat){
    int member = group.second - group.first + 1;
    sum += member;
  }

  cout << sum << endl;
}

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

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

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

    int X = N*25/27;
    if(X*27/25 == N){
        printf("%d", X);
    }else if((X+1)*27/25 == N){
        printf("%d", X+1);
    }else{
        printf(":(");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, m;
    while (cin >> n && n) {
        cin >> m;
        vector<pii> p(100111);
        vector<int> l(200111), r(200111);
        rep(i, m) { cin >> p[i].F >> p[i].S; p[i].S--; }
        sort(p.begin(), p.begin() + m);
        
        rep(i, n) l[i] = r[i] = i;
        rep(i, m) {
            int y = p[i].S;
            r[y] = r[y + 1];
            l[y + 1] = l[y];
            // cout << endl; rep(_, n) cout << l[_] << " "; cout << endl;
            // rep(_, n) cout << r[_] << " "; cout << endl;
        }
        rep(i, n) cout << r[i] - l[i] + 1 << (i == n - 1 ? '\n' : ' ');
    }
}






Measured memory_bytes: 5204
moji = str(input())
ans = 0
cans = 0
correct = ["A","C","G","T"]
for i in range(len(moji)):
    if moji[i] in correct:
        cans += 1
        if cans > ans:
            ans = cans
    else:
        if cans > ans:
            ans = cans
        cans = 0
print(ans)


Measured memory_bytes: 9072
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
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<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {

    string s="",t;
    cin>>t;
    rep(i,t.size()){
        if(i<t.size()-1&&t[i]=='B'&&t[i+1]=='C')s+='D',i++;
        else s+=t[i];
    }
    ll ans=0;
    vll csum(1,0);
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='D')csum.pb(csum[csum.size()-1]+1);
        else if(s[i]=='A')csum.pb(csum[csum.size()-1]);
        else csum.pb(0);
    }
    reverse(all(csum));
    rep(i,s.size())if(s[i]=='A')ans+=csum[i];
    fin(ans);
}



Measured memory_bytes: 2812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )


typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;


// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
PII,
null_type,
less<PII>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

/*end of header*/

string s;

bool possible(int num)
{
    REP(i,0,25)
    {
        bool flag=1;
        REP(j,0,s.size()-1-num)
        {
            bool flag1=0;
            REP(k,j,min((int)s.size()-1,j+num))
            {
                if(s[k]=='a'+i)
                {
                    flag1=1;
                    break;
                }
            }
            if(!flag1)
            {
                flag=0;
                break;
            }
        }
        if(flag)return 1;
    }
    return 0;
}

int main()
{
    //freopen("input_file_name.in","r",stdin);
    //freopen("output_file_name.out","w",stdout);
    cin>>s;
    int lo=0,hi=s.size()-1,mid,best;
    //possible(1);
    while(hi>=lo)
    {
        mid=(hi+lo)/2;
        if(possible(mid))
        {
            best=mid;
            hi=mid-1;
        }
        else lo=mid+1;
    }
    print(best);
    return 0;
}



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

const int MOD=1000000007;
int H,W;
vector<string> a;

//dp table
int dp[1100][1100]={0};

void add(int &a, int b){
	a+=b;
	if (a>=MOD)a-=MOD;
}

int main(){
	cin>>H>>W;
	a.resize(H);
	for (int i=0;i<H;++i)cin>>a[i];

	dp[0][0]=1;
	for (int i=0;i<H;++i){
		for (int j=0;j<W;++j){
			if (i+1<H && a[i+1][j]=='.') add(dp[i+1][j],dp[i][j]);
			if (j+1<W && a[i][j+1]=='.') add(dp[i][j+1],dp[i][j]);

		}
	}
	cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 5632
N = int(input())
d = list(map(int, input().split()))


# N/2番目に難しい問題が「ARC用の問題」かつ、
# N/2−1番目に難しい問題が「ABC用の問題」であればよい
# 難易度順に昇順でソート
# N/2番目の要素から、N/2−1番目の要素を引く

# 例d=[1,5,9,11,13,15,19,20]なら、答えは12,13の2つ
d = sorted(d)
print(d[N//2] - d[(N//2)-1])

Measured memory_bytes: 20592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

int main()
{
    int N ; 
    scanf("%d", &N) ;
    map<int, int> stat ; 
    for(int i = 0 ; i != N ; i++) {
        int now ; 
        scanf("%d", &now) ; 
        stat[now]++ ; 
    }
    int cnt = 0 ; 
    int statSize = stat.size() ; 
    for(auto p: stat)
        if(p.second % 2 == 0)
            cnt++ ; 
    printf("%d\n", statSize - cnt%2) ; 
    return 0 ; 
}



Measured memory_bytes: 4864
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

int a, b, c, d;

double f(double x) {
    return a * x * x * x + b * x * x + c * x + d;
}

int judge(double x) {
    if(x > 1e-9) return 1;
    if(x < -(1e-9)) return -1;
    return 0;
}

int main() {
    int n;
    cin >> n;
    if(n % 2 == 0) cout << 0.5 << endl;
    else {
        cout << ((n + 1) / 2.0 / n) << endl;
    }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        x: u64, a: u64, b: u64
    }
    println!("{}", (x - a) % b);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int N,cost;
double sum,ave,num;

int main(){
    cin>>N;
    int a[N];
    num=N;
    rep(i,N){
        cin>>a[i];
        sum+=a[i];
    }
    ave=round(sum/num);
    rep(i,N)cost+=(ave-a[i])*(ave-a[i]);
    out(cost);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
int N;
int dp[1000005];
void solve(int a)
{
  for (int i = a; i <= N; i *= a)
    for (int j = 0; i + j <= N; j++)
      dp[i + j] = min(dp[i + j], dp[j] + 1);
}
int main()
{
  cin >> N;
  rep(i, 0, N + 1) dp[i] = i;
  solve(6);
  solve(9);
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
  string S,T;
  cin >> S >> T;
  bool ans=false;
  for(int i=0; i<T.size(); i++){
    if(S==T){
      ans = true;
      break;
    }
    S=S.back()+S.substr(0,S.size()-1);
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int v[n], c[n];
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];

  int ans = 0;
  rep(i, n) {
    if (v[i] - c[i] > 0) ans += v[i] - c[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();

    VI ans(n);
    int c[2] = {};
    FOR(i, 0, n) {
        if (s[i] == 'R')++c[i & 1];
        else {
            ans[i] += c[i & 1];
            ans[i - 1] += c[!(i & 1)];
            c[0] = c[1] = 0;
        }
    }
    rFOR(i, 0, n) {
        if (s[i] == 'L')++c[i & 1];
        else {
            ans[i] += c[i & 1];
            ans[i + 1] += c[!(i & 1)];
            c[0] = c[1] = 0;
        }
    }

    FOR(i, 0, n)cout << ans[i] << ENDL(i, n);
}


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

int main()
{
    int a, b;
    cin >> a >> b;

    int numCoin = 0;
    for (int i=0; i < 2; i++)
    {
        if (a >= b)
        {
          numCoin += a--;
        }
        else
        {
            numCoin += b--;
        }
    }

    cout << numCoin << endl;

    return 0;
}

Measured memory_bytes: 256
n,h = map(int,input().split())
x = (tuple(map(int, input().split())) for _ in [0] * n)
a2,b = [],[]
for j in x:
	a2.append(j[0])
	b.append(j[1])
a = max(a2)
b = [i for i in b if i>a]
b.sort()
b = b[::-1]
if h <= sum(b):
	num,i = 0,0
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h+a-1)//a + len(b)
print(num)

Measured memory_bytes: 11932
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int d,c[26],s[400][26],t[400],last[26];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>d;
    rep(i,26)cin>>c[i];
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int score=0;
    fill(last,last+26,-1);
    rep(i,d){
        cin>>t[i];
        t[i]--;
        score+=s[i][t[i]];
        last[t[i]]=i;
        rep(j,26)score-=c[j]*(i-last[j]);
        cout<<score<<endl;
    }
    return 0;
}

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

int main(){
  vector<int> v(5);
  vector<int> num(5);
  for(int i=0; i<5; i++){
    cin >> v[i];
    num[i]=i+1;
  }
  int ans=-1;
  do{
    int temp=0;
    for(int i=0; i<5; i++){
      temp=ceil((double)temp/10)*10+v[num[i]-1];
    }
    if(ans<0) ans=temp;
    else ans=min(ans, temp);
  }while(next_permutation(num.begin(), num.end()));
  cout << ans <<endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3) {
        cin >> A[i];
    }
    ll ans = 0;
    while (A[0] != A[1] || A[1] != A[2] || A[2] != A[0]) {
        ans++;
        ll mx = std::max({A[0], A[1], A[2]});
        ll n = 0;
        REP(i, 3) {
            if (A[i] < mx)
                n++;
        }
        REP(i, 3) {
            if (n == 2 && A[i] < mx) {
                A[i]++;
            }
            else if (n == 1 && A[i] < mx) {
                A[i] += 2;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

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

int
main(int argc, char *argv[])
{
  int n, a[100000], ans = 0, f = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);

  qsort(a, n, sizeof(int), asc);
  for (int i = 0; i < n; i++) {
    if (f != a[i]) {
      ans++;
      f = a[i];
    }
  }

  if ((n - ans) % 2 != 0) ans--;

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

  return 0;
}


Measured memory_bytes: 892
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import Debug.Trace

solve :: Int -> Int -> V.Vector (VU.Vector Bool) -> [(Int, Int, Int, Int)]
solve !h !w !aij =
  concat
    $ reverse
    $ (\(ps, rs) -> lastColumnFoldDown (VU.fromList $ reverse rs) : ps)
    $ foldl'
        (\(!procs, !rs) (!i) ->
          let (ps, r) = rowFoldRight i in (ps : procs, r : rs)
        )
        ([], [])
        [0 .. h - 1]
 where
  fold s i = first reverse . VU.ifoldl'
    (\(!acc, !isCarrying) (!j) (!b) -> if
      | not isCarrying && b -> ((if j /= s then ((i, j, i, j + 1) :) else id) acc, True)
      | isCarrying && b -> (acc, False)
      | isCarrying && not b -> ((if j /= s then ((i, j, i, j + 1) :) else id) acc, True)
      | otherwise -> (acc, isCarrying)
    )
    ([], False)

  lastColumnFoldDown =
    map (\(y, x, y', x') -> (x, y, x', y)) . fst . fold (h - 1) (w - 1)

  rowFoldRight i = fold (w - 1) i $ aij V.! i

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (h, w) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  aij <-
    V.replicateM h $ VU.map (\i -> odd i) . VU.unfoldrN w readInt <$> B.getLine

  let rs = solve h w aij
  print $ length rs
  forM_ rs $ \(y, x, y', x') ->
    putStrLn
      $  show (y + 1)
      ++ " "
      ++ show (x + 1)
      ++ " "
      ++ show (y' + 1)
      ++ " "
      ++ show (x' + 1)


Measured memory_bytes: 22652
#include<stdio.h>
int main(void){
	
	int S;
	int h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
	
}

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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> v(N, 0);
  rep(i, Q) {
    int a;
    cin >> a;
    a--;
    v.at(a)++;
  }
  rep(i, N) {
    if (K - (Q - v.at(i)) > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  return 0;
}


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

int main()
{
  int red, green, blue, operation, count;
  count = 0;

  cin >> red >> green >> blue;
  cin >> operation;

  if(red >= green)
  {
    while(red >= green)
    {
      green = green * 2;
      count++;
    }
  }

  if(green >= blue)
  {
    //cout << count << end;
    while (green >= blue)
    {
      blue = blue * 2;
      count++;
    }
  }

  //cout << count << endl;

  if(count <= operation)
  {
    cout << "Yes" << endl;
  }

  if(count > operation)
  {
    cout << "No" << endl;
  }
}

  /*두번째꺼가 첫번째꺼보다 작으면 커질때까지 두배시키고
  세번째 두번째 비교
  카운팅이 k보다 작거나 같으면 ok
  크면 안된다*/


Measured memory_bytes: 3596