akhauriyash/Code-Regression huggingface dataset:
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;

template<class T>
using vec2d = std::vector<std::vector<T>>;


template<class T>
vec2d<T> makeVec2d(const int n1, const int n2, const T initValue) {
  return vec2d<T>(n1, vec<T>(n2, initValue));
}


#define FORA(i, a, n) for (int i = (a); i < (n); ++i)


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto a = next_vec<int64_t>(in, n);
  vec2d<int64_t> dp = makeVec2d<int64_t>(n, n, -1);
  vec<int64_t> sum(n);
  sum[0] = a[0];
  FORA(i, 1, n) sum[i] = sum[i-1] + a[i];

  auto getSum = [&] (int le, int ri) -> int64_t {
    if (le == 0) return sum[ri];
    return sum[ri] - sum[le - 1];
  };


  function<int64_t(int, int)> rec = [&](int le, int ri) -> int64_t {

    if (le == ri) {
      return 0;
    }
    auto& res = dp[le][ri];
    if (res != -1) return res;
    res = numeric_limits<int64_t>::max() / 2;

    for (int i = le; i < ri; ++i) {
      int64_t cur = rec(le, i) + rec(i + 1, ri) + getSum(le, ri);
      res = min(res, cur);
    }
    return res;
  };
  out << rec(0, n-1) << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
int power(int x,int y){
    int res=1;
    while(y>0){
        if(y&1)res=(res*x)%mod1;
        x=(x*x)%mod1;
        y/=2;
    }
    return res;
}
// int mulmod(int x,int y){
//     int res=0ll;
//     while(y>0){
//         if(y&1)res=(res+x)%mod;
//         x=(2*x)%mod;
//         y/=2ll;
//     }
//     return res%mod;
// }
// bool prime[1000001];
// int spf[2000005];
// int fact[1000001];
// // vector<int> p;
// void sieve(){
//     for(int i=2;i<2000005;i++){spf[i]=i;}
//     for (int i=2;i<2000005;i++){
//         if (spf[i]==i){  
//             // p.push_back(i);
//             for (int j=i*i;j<2000005;j+=i)
//                 spf[j]=i;
//         }
//     }
// }
// int phi(int n){
// 	//phi(p)=p-1;
// 	//phi(p^k)=(p^(k-1))(p-1);
// 	//phi(ab)=phi(a)*phi(b) if a and b are co-prime;
// 	//phi(ab)=phi(a)*phi(b)*(gcd(a,b))/(phi(gcd(a,b));
// 	//a^(phi(b)) is equivalent to 1 mod b if a and b are co-prime;
// 	int result=n;
// 	for(int i=2;i*i<=n;i++){
// 		if(n%i==0){
// 			while(n%i==0)
// 				n/=i;
// 			result-=(result)/i;
// 		}
// 	}
// 	if(n>1)
// 		result-=result/n;
// 	return result;
// }
// void bfs(vector<int> adj[],int src,int n,vector<int> &dist){
// 	priority_queue<iP,vector<iP>,greater<iP>> pq;
// 	pq.push({0,src});
// 	dist[src]=0;
// 	vector<bool> vis(n+1,false);
// 	while(!pq.empty()){
// 		int a=pq.top().second;
// 		pq.pop();
// 		if(vis[a])continue;
// 		vis[a]=1;
// 		for(auto it: adj[a]){
// 		    if(dist[it]>dist[a]+1){
// 				pq.push({dist[it],it});
// 				dist[it]=dist[a]+1;
// 		    }
// 		}
// 	}
// }
void dfs(vector<int> adj[],int x,vector<bool> &vis){
    vis[x]=1;
    for(auto it: adj[x]){
        if(!vis[it]){
            dfs(adj,it,vis);
        }
    }
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;
    int h,w;
    cin>>h>>w;
    if(w==1||h==1)cout<<1;
    else
    cout<<(int)ceil((h*w)/2.0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
int T, N, a, b, c, d, e, f;
char arr[10];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c>>N;
	int ans = 0;
	ans += min(max(0, N), a);
	N -= min(max(0, N), a + b);
	ans -= N;
	cout << ans << '\n';
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vector<vector<bool>> dp(N+1,vector<bool>(K+1)),cp(N+1,vector<bool>(K+1));
  dp[0][0]=1;
  rep(i,0,N){
    REP(j,0,K){
      if(dp[i][j]){
        dp[i+1][j]=1;
        dp[i+1][min(j+A[i],K)]=1;
      }
    }
  }
  cp[N][0]=1;
  rep(i,0,N){
    int k=N-i;
    REP(j,0,K){
      if(cp[k][j]){
        cp[k-1][j]=1;
        cp[k-1][min(j+A[k-1],K)]=1;
      }
    }
  }
  int ans=0;
  rep(i,0,N){
    int sum=0;
    int memo=K-1;
    rep(j,0,K){
      if(dp[i][j]){
        for(memo;0<=memo;memo--){
          if(cp[i+1][memo]&&memo+j<K){
            sum=max(sum,memo+j);
            break;
          }
        }
      }
    }
    if(sum+A[i]<K) ans++;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 6912
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = INF
for i in range(1,n//2+2):
    tmp = 0
    t = str(i)
    j = str(n-i)
    for k in t:
        tmp += int(k)
    for k in j:
        tmp += int(k)
    res = min(res, tmp)
print(res)

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

using namespace std;
const int MAXN = 8;
vector<int> G[MAXN];
int ans = 0;
int n, m;

void dfs(int cur, vector<bool> visited) {
  bool done = true;
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) done = false;
  }
  if (done) {
    ans++;
    return;
  }
  for (size_t i = 0; i < G[cur].size(); ++i) {
    int next = G[cur][i];
    if (!visited[next]) {
      visited[next] = true;
      dfs(next, visited);
      visited[next] = false;
    }
  }
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<bool> visited(n, false);
  visited[0] = true;
  dfs(0, visited);
  printf("%d\n", ans);
  return 0;
}


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

public class Main{
	public static void main(String[] args){

		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int T[] = new int[n];
		int sumT = 0;

		for(int i = 0;i < n;i++){
			T[i] = stdIn.nextInt();
			sumT += T[i];
		}

		int border = 0;

		int i = 0;
		while(border < sumT / 2){
			border += T[i++];
		}
		
		if(Math.abs(border - sumT / 2) > Math.abs(border - T[i - 1] - sumT / 2)){
			border -= T[i - 1];
		}
		int ans = Math.abs(border * 2 - sumT); 
		System.out.println(ans);
  
	}
}

Measured memory_bytes: 25044
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n<1 || 10000<n){
            System.exit(-1);
        }
        int[] list = new int[n];
        int a=0;
        for(int i=0; i<n; i++){
            a=sc.nextInt();
            if(a<-1000000 || 1000000<a){
                System.exit(-1);
            }
            list[i]=a;
        }
        
        long min = list[0];
        for(int i=1; i<n; i++){
            if(min>list[i]){
                min = list[i];
            }
        }
        
        long max = list[0];
        for(int i=1; i<n; i++){
            if(max<list[i]){
                max = list[i];
            }
        }
        
        long sum = 0;
        for(int i=0; i<n; i++){
            sum = sum + list[i];
        }
            System.out.println(min + " " + max + " " + sum);
    }
}

Measured memory_bytes: 42132
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n;
    cin >> n;

    vi arr(n);
    for (auto &it : arr) {
        cin >> it;
    }

    vi pre(n);
    pre[0] = arr[0];
    for (int i = 1; i < n; i++) {
        pre[i] = pre[i - 1] + arr[i];
    }

    ll ans = LLONG_MAX;

    ll lazy = 0, curr = 0, curr_ans = 0;
    for (int i = 0; i < n; i++) {
        if (curr == 0) {
            if (pre[i] + lazy <= 0) {
                curr_ans += llabs(pre[i] + lazy) + 1;
                lazy += llabs(pre[i] + lazy) + 1;
            }
        } else {
            if (pre[i] + lazy >= 0) {
                curr_ans += (pre[i] + lazy) + 1;
                lazy -= (pre[i] + lazy) + 1;
            }
        }
        curr ^= 1;
    }

    ans = min(ans, curr_ans);
    lazy = 0, curr = 1, curr_ans = 0;
    for (int i = 0; i < n; i++) {
        if (curr == 0) {
            if (pre[i] + lazy <= 0) {
                curr_ans += llabs(pre[i] + lazy) + 1;
                lazy += llabs(pre[i] + lazy) + 1;
            }
        } else {
            if (pre[i] + lazy >= 0) {
                curr_ans += (pre[i] + lazy) + 1;
                lazy -= (pre[i] + lazy) + 1;
            }
        }
        curr ^= 1;
    }
    ans = min(ans, curr_ans);

    cout << ans << "\n";
}


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

int main()
{
	int n,k; cin>>n>>k;
	int ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];
	int dp[n]={0};
	for(int i=1;i<n;i++){
		int maxa=INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				maxa=min(maxa,abs(ar[i]-ar[i-j])+dp[i-j]);
			}
		}
		dp[i]=maxa;
	}//
	//for(int i=0;i<n;i++) cout<<dp[i]<<" ";
	cout<<dp[n-1]<<endl;
} 


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

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

	int n;
	cin >> n;
	vector<long long> v(n);
	unsigned int allxor = 0;
	for(auto &el: v) {
		cin >> el;
		allxor ^= el;
	}
	for(auto& el: v) {
		cout << (el ^ allxor) << " ";
	}
	cout << "\n";
    
	return 0;
}


Measured memory_bytes: 4380
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vii;
typedef vector<pll>         vll;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int TEST_CASE){
    int n;
    cin >> n;
    int d = n%10;
    if(d==3){
        cout << "bon";
    }else if(d==0 || d==1 || d==6 || d==8){
        cout << "pon";
    }else{
        cout << "hon";
    }
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>

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

int main(void)
{
    int n;
    scanf("%d",&n);
    int a[n-1];
    for(int i=0;i<n-1;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n-1,sizeof(int),cmp);
    int num[n];
    for(int i=0;i<n;i++){
        num[i]=0;
    }
    for(int i=0;i<n-1;i++){
        int s=a[i]-1;
        num[s]++;
    }
    for(int i=0;i<n;i++){
        printf("%d\n",num[i]);
    }
    return 0;
}

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


class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine().trim());
		String[] s=br.readLine().split(" ");
		int[] a=new int[n];
		int i=0;
		for(String s1:s) {
			a[i]=Integer.parseInt(s[i].trim());
			i++;
		}
		System.out.println(algo(a,n));
		
		
		

	}
	
	public static int algo(int[] a,int n) {
		int[] dp=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
//		dp[0]=0;
		dp[0]=0;
		for(int i=1;i<n;i++) {
			if(i-1>=0) {
				int x=dp[i-1]+Math.abs(a[i]-a[i-1]);
				dp[i]=Math.min(dp[i],x);
			}
			if(i-2>=0) {
				int x=dp[i-2]+Math.abs(a[i]-a[i-2]);
				dp[i]=Math.min(dp[i],x);
			}
			
		}
		return dp[n-1];
		
	}
	
	
	
	

}


Measured memory_bytes: 44180
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  constexpr int N = 1e6;
  V<> a, b;
  for (int i = 1; ; ++i) {
    a.push_back(i * (i + 1) * (i + 2) / 6);
    if (a.back() >= N) {
      a.pop_back();
      break;
    }
    if (a.back() & 1) b.push_back(a.back());
  }
  V<> p(N, -1), q(N, -1);
  p[0] = q[0] = 0;
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int i = que.front(); que.pop();
    for (int e : a) if (i + e < N and p[i + e] == -1) {
      p[i + e] = p[i] + 1;
      que.push(i + e);
    }
  }
  que.push(0);
  while (!que.empty()) {
    int i = que.front(); que.pop();
    for (int e : b) if (i + e < N and q[i + e] == -1) {
      q[i + e] = q[i] + 1;
      que.push(i + e);
    }
  }
  while (true) {
    int n; cin >> n;
    if (!n) break;
    cout << p[n] << ' ' << q[n] << '\n';
  }
}


Measured memory_bytes: 14080
//#include <bits/stdc++.h>
//using namespace std;
//#define ll long long
//
//int main() {
//    ios::sync_with_stdio(false);
//    int n,k;cin>>n>>k;
//    while(n){
//
//    }
//    return 0;
//}
#include <iostream>
using namespace std;

int main()
{
    long n;
    int x,a,m=0,s[10000];
    cin>>n>>x;

    while (n!=0)
    {
        a=n%x;
        n=n/x;
        m++;
        s[m]=a;
    }
    cout<<m<<endl;
//    for(int i=m;i>=1;i--)
//    {
//        if(s[i]>=10)
//            cout<<(char)(s[i]+55);
//        else
//            cout<<s[i];
//    }



    return 0;
}


Measured memory_bytes: 256
import numpy as np
 
n, k = map(int, input().split())
ans = 0
 
for i in range(1, n + 1):
  if i>= k:
    ans += 1 / n
  else:
    ans += np.power(1 / 2, np.ceil(np.log2(k / i))) / n
    
print(ans)

Measured memory_bytes: 12484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int X;
    static void INPUT()
    {
        X = NextInt();
    }

    static void OUT()
    {
        for (var a = -150; a <= 150; a++)
        {
            var A5 = Math.Pow(a, 5);
            for (var b = -150; b <= 150; b++)
            {
                var B5 = Math.Pow(b, 5);
                if (A5 - B5 == X)
                {
                    Console.WriteLine(string.Format("{0} {1}", a, b));
                    return;
                }
            }
        }

        Console.WriteLine(string.Format("{0}:{1}", 0, 0));
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        //INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 18400
#include <bits/stdc++.h>
using namespace std;
int main(){
double W;
double H;
double x;
double y;
cin >>W>>H>>x>>y;
  cout<<(W*H)/2.0<<" ";
  if(W==x*2 && H==y*2){
    cout<<1<<endl;
  }
 else{
cout <<0<<endl;
 }  
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;

void solve()
{
    int n;
    cin>>n;
    int x,pos=1;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(!(x%2))
        {
            if((x%3)&&(x%5))
                pos=0;
        }
    }
    if(pos)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorString(vector<string> * p, long long a){
    rep(i, a){
        string input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const long long MOD = 10*10*10*10*10*10*10*10*10+7;

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    long long N = inputValueLongLong();
    long long K = inputValueLongLong();
    long long sunuke[N];
    for(ll i=0;i<N;i++){
        sunuke[i] = 0;
    }
    for(ll i=0;i<N;i++){
        ll d = inputValueLongLong();
        for(ll j=0;j<d;j++){
            ll kashi = inputValueLongLong();
            sunuke[kashi-1]++;
        }
    }
    ll counter = 0;
    for(ll i=0;i<N;i++){
        if(sunuke[i]==0){
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3628
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  while (n--) {
    string m, s;
    cin >> m >> s;
    reverse(all(m));
    for (char &c : m) {
      if (c == 'J') s = s.back() + s.substr(0, s.size() - 1);
      if (c == 'C') s = s.substr(1, s.size() - 1) + s.front();
      if (c == 'E') s = even(s.size()) ? s.substr(s.size() / 2, s.size() / 2) + s.substr(0, s.size() / 2)
                                       : s.substr(s.size() / 2 + 1, s.size() / 2) + s[s.size() / 2] + s.substr(0, s.size() / 2);
      if (c == 'A') reverse(all(s));
      if (c == 'P') transform(all(s), s.begin(), [](char x) {
        return isdigit(x) ? (x - '0' + 9) % 10 + '0' : x;
      });
      if (c == 'M') transform(all(s), s.begin(), [](char x) {
        return isdigit(x) ? (x - '0' + 1) % 10 + '0' : x;
      });
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 3084
N, X, M = map(int, input().split())

if X == 0:
    print(0)
    exit()

A_history = [-1] * M
sum_history = [0] * (M + 1)
A = X
all_sum = A

sum_history[0] = A

for i in range(M):
    Anext = (A * A) % M
    all_sum += Anext
    sum_history[i + 1] = all_sum
    if A_history[A] == -1:
        A_history[A] = i
    else:
        break
    A = Anext

if i >= N:
    print(sum_history[N - 1])
else:
    cycle_start = A_history[A]
    cycle_end = i - 1
    cycle_length = cycle_end - cycle_start + 1
    cycle_time = N - cycle_start
    cycle_count = cycle_time // cycle_length
    cycle_mod = cycle_time % cycle_length
    ans = sum_history[cycle_start] + (sum_history[cycle_end + 1] - sum_history[cycle_start]) * cycle_count + \
          (sum_history[cycle_start + cycle_mod - 1] - sum_history[cycle_start])
    print(ans)


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

int main()
{
	int N, A;
	long ans = 0;
	int pre = 0;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A;
		if (pre > A) {
			ans += pre - A;
		}
		else {
			pre = A;
		}
	}

	cout << ans << endl;	

}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=55;


void solve(){

ll n;
cin>>n;


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









}
int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<":"<<endl;
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
 int n;
 long long an, min, max,sum;
 sum = 0;
 min = 1000000;
 max = -1000000;
 cin >> n;
 for(int i = 1; i <= n; i ++ ){
     cin >> an;
     sum += an;
     if(min > an){
         min = an;
     }
     else{
         min = min;
     }
     if(max < an){
         max = an;
     }
     else{
         max = max;
     }
 }
 cout << min <<" "<< max << " " << sum << endl;
 return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin >> k;
	queue<ll> Q;
	for(int i = 1; i < 10; ++ i) Q.push(i);
	vector<ll> lunlun;
	while(sz(lunlun) < k) {
		ll x = Q.front(); Q.pop();
		lunlun.push_back(x);
		if(x % 10) Q.push(10 * x + x % 10 - 1);
		Q.push(10 * x + x % 10);
		if(x % 10 != 9) Q.push(10 * x + x % 10 + 1);
	}
	cout << lunlun.back() << '\n';
}


Measured memory_bytes: 2676
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int n, T;
    cin >> n >> T;
    int ans = 1001;
    rep(i,n)
    {
        int c, t;
        cin >> c >> t;
        if(t<=T)
        {
            ans = min(ans, c);
        }
    }
    if(ans<=1000) cout << ans << endl;
    else cout << "TLE" << endl;
    
    return 0;
}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

bool solve(int H, int W, int N, int Sr, int Sc, string& S, string& T) {
    // i回目(0..N-1)の行動終了時点でleft <= right の位置に駒があれば後手が勝てる
    int left = 1, right = W;

    RREP(i,0,N) {
        // 後手は範囲を広げようとする
        if (T[i] == 'R') {
            left = max(1, left-1);
        } else if (T[i] == 'L') {
            right = min(W, right+1);
        }

        // 先手は範囲を縮めようとする
        if (S[i] == 'L') {
            left++;
        } else if (S[i] == 'R') {
            right--;
        }

        if (left > right) return false;
    }
    if (left > Sc || right < Sc) return false;

    // i回目(0..N-1)でtop <= bottom の位置に駒があれば後手が勝てる
    int top = 1, bottom = H;

    RREP(i,0,N) {
        // 後手は範囲を広げようとする
        if (T[i] == 'U') {
            bottom = min(H, bottom+1);
        } else if (T[i] == 'D') {
            top = max(1, top-1);
        }

        // 先手は範囲を縮めようとする
        if (S[i] == 'D') {
            bottom--;
        } else if (S[i] == 'U') {
            top++;
        }

        if (top > bottom) return false;
    }
    if (top > Sr || bottom < Sr) return false;

    return true;
}

signed main() {
    int H, W, N, Sr, Sc;
    cin >> H >> W >> N >> Sr >> Sc;
    string S, T;
    cin >> S >> T;

    cout << (solve(H, W, N, Sr, Sc, S, T) ? "YES" : "NO") << '\n';

    return 0;
}



Measured memory_bytes: 776
import numpy as np
 
def LI():
  return [int(s) for s in input().split()]
 
N,K,Q = LI()
Seikai_s = np.array([Q]*N)
 
for i in range(Q):
  seikai = int(input())
  Seikai_s[seikai-1]-=1
      
for i in range(N):
  if K-Seikai_s[i] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 15208
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define RREP(i, a, b) for (ll i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

string a, b;
ll idxa, idxb;
ll cnta, cntb;
int main() {
    cin>>a>>b;

    a=a+"A";
    b=b+"B";

    while(idxa<a.size()-1 && idxb<b.size()-1){
        while(a[idxa]==b[idxb] && (a[idxa]!='[' || b[idxb]!='[')){
            cout<<a[idxa];

            if(a[idxa]=='('){
                cnta++;
                cntb++;
            }
            else if(a[idxa]==')'){
                cnta--;
                cntb--;
            }

            idxa++; idxb++;
        }
        if(a[idxa]=='('){
            cnta++;
            cntb--;
        }
        else if(a[idxa]==')'){
            cnta--;
            cntb++;
        }

        // ignore no match sub string
        if(cnta>cntb){
            while(cnta!=cntb){
                idxa++;
                if(a[idxa]=='(') cnta++;
                else if(a[idxa]==')') cnta--;
            }
        }
        else if(cnta<cntb){
            while(cnta!=cntb){
                idxb++;
                if(b[idxb]=='(') cntb++;
                else if(b[idxb]==')') cntb--;
            }
        }

        // add node value
        if(a[idxa]=='[' && b[idxb]=='['){
            idxa++; idxb++;

            ll suma=0, sumb=0;
            while(isdigit(a[idxa])){
                suma=10*suma+(a[idxa]-'0');
                idxa++;
            }
            while(isdigit(b[idxb])){
                sumb=10*sumb+(b[idxb]-'0');
                idxb++;
            }
            cout<<"["<<suma+sumb<<"]";
            idxa++; idxb++;
        }
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

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

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

int main() {

  int N, M, a, b, c, x, y, z;
  string s, t;

  cin >> s;
  N = s.size();
  string T = "CODEFESTIVAL2016";
  int cnt = 0;
  rep(i, 16) {
    if(T[i] != s[i]) cnt ++;
  }

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

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    // vector<int> p(N);
    ll num;
    vector<bool> index(N, true);
    ll issue = 0;
    for (int i = 1; i < N; i++)
    {
        cin >> num;
        if (num == i)
        {
            index[i] = false;
            issue++;
        }
    }

    // debug
    // for (int i = 1; i < N; i++)
    // {
    //     if (index[i] == true)
    //     {
    //         printf("X ");
    //     }
    //     else
    //     {
    //         printf("O ");
    //     }
    // }

    ll ans = 0;
    ll i = 1;
    while (issue > 0 || i < N - 1)
    {
        if (index[i] == false)
        {
            if (index[i + 1] == false)
            {
                issue -= 2;
                i += 2;
            }
            else
            {
                issue--;
                i++;
            }
            ans++;
        }
        else
        {
            i++;
        }
    }
    cout << ans << endl;

    return (0);
}

Measured memory_bytes: 256
n,m = [int(i) for i in input().split()]
p = ['P']*n
k = ['I']*m
al = p+k
ans = 0
for i in range(len(al)):
    for j in range(i+1,len(al)):
        if al[i] == 'I' and al[j]=='I':ans+=1
        if al[i] == 'P' and al[j] == 'P': ans+=1
print(ans)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}

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

    vector<ll> diff(N);
    rep(i,N){
        diff[i] = abs(X-x[i]);
    }
    
    ll ans;
    rep(i,N){
        if (i == 0) ans = diff[i];
        else ans = gcd(ans, diff[i]);
    }

    cout << ans << endl;
}



Measured memory_bytes: 4592
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    long long A, B, C;
    cin >> A >> B >> C;

    if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
    {
        cout << 0 << std::endl;
    }

    else
    {
        cout << min(min(A * B, B * C), A * C) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {
	int h = -1, w;
	cin >> h >> w;
	vector<string> b(h);
	for (int i = 0; i < h; ++i) {
		cin >> b[i];
	}
	int dp[102][102][2] = {};
	memset(dp, 0x3f, sizeof(dp));
	dp[0][1][0] = 0, dp[0][1][1] = 1;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int is_black = b[i][j] != '.';
			dp[i + 1][j + 1][is_black] = min({
				dp[i][j + 1][0] + is_black, 
				dp[i][j + 1][1],
				dp[i + 1][j][0] + is_black,
				dp[i + 1][j][1]
				});
		}
	}
	cout << min(dp[h][w][0], dp[h][w][1]) << endl;
	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    string S; ll K; cin >> S >> K;
    ll lenS = S.length();
    //問題となるのはS[0]=S[lenS-1]のとき
    ll same_front_end = 0;
    ll start = 0;
    ll end = lenS-1;
    bool flg = false;
    if(S[lenS-1] == S[0]){
        flg = true;
        for(int i = 0; i < lenS-1; i++){
            if(S[i] != S[0]){
                start = i;
                break;
            }
            same_front_end++;
        }
        for(int i = lenS-1; i >= 0; i--){
            if(S[i] != S[0]){
                end = i;
                break;
            }
        }
    }
    same_front_end = 1;
    if(S[0] == S[lenS-1]){
        int r = lenS-2;
        int l = 0;
        while(S[r] == S[0]) {same_front_end++; r--;}
        while(l < r && S[l] == S[0]){same_front_end++; l++;}

    }
    //S[0]からS[end], S[start]からS[lenS-1]までのは?
    int row = 1;
    int aim = 0;
    int ans1 = 0;
    bool cont = true;
    for(int i = 1; i <= end; i++){
        if(cont && S[i] == S[aim]) row++;
        else if(S[i] == S[aim]){
            cont = true;
            row++;
        }
        else{
            ans1 += row/2;
            cont = false;
            row = 1;
            aim = i;
        }
    }
    ans1 += row/2;

    row = 1;
    aim = start;
    cont = false;
    int ans2 = 0;

    for(int i = start+1; i <= lenS-1; i++){
        if(cont && S[i] == S[aim]) row++;
        else if(S[i] == S[aim]){
            cont = true;
            row++;
        }
        else{
            ans2 += row/2;
            cont = false;
            row = 1;
            aim = i;
        }
    }
    ans2 += row/2;

    row = 1;
    aim = start;
    cont = false;
    int ans3 = 0;

    for(int i = start+1; i <= end; i++){
        if(cont && S[i] == S[aim]) row++;
        else if(S[i] == S[aim]){
            cont = true;
            row++;
        }
        else{
            ans3 += row/2;
            cont = false;
            row = 1;
            aim = i;
        }
    }
    ans3 += row/2;

    if(K == 1){
        row = 1;
        aim = 0;
        cont = false;
        int ans2 = 0;

        for(int i = 1; i <= lenS-1; i++){
            if(cont && S[i] == S[aim]) row++;
            else if(S[i] == S[aim]){
                cont = true;
                row++;
            }
            else{
                ans2 += row/2;
                cont = false;
                row = 1;
                aim = i;
            }
        }
        ans2 += row/2;
        cout << ans2 << endl;
        return 0;
    }

    bool allsame = true;
    for(int i = 1; i < lenS; i++) if(S[i] != S[i-1]) allsame = false;

    if(!flg){
        cout << ans1*K << endl;
    }
    else if(allsame){
        cout << lenS*K/2 << endl;
    }
    else{
        cout << same_front_end/2 * (K-1) + (K-2)*ans3 + ans1 + ans2 << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 256
def main():
    s=input()
    s+="R"
    n=len(s)
    ans=[0]*(n-1)
    res="R"
    resRL=0
    cnt=0
    cntR=0
    for i in range(n):
        if s[i]==res:
            cnt+=1
            if s[i]=="R":
                cntR+=1
        elif s[i]=="L":
            cnt+=1
            res="L"
            resRL=i
        else:
            if cnt%2==0:
                ans[resRL-1]=cnt//2
                ans[resRL]=cnt//2
            elif cntR%2==0:
                ans[resRL-1]=cnt//2
                ans[resRL]=cnt//2+1
            else:
                ans[resRL-1]=cnt//2+1
                ans[resRL]=cnt//2
            cnt=1
            cntR=1
            res="R"
            resRL=0
    print(" ".join(str(_) for _ in ans))
if __name__=="__main__":
    main()

Measured memory_bytes: 17324
// include
#include <array>
#include <algorithm>
#include <set>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <unordered_map>


// pow(10, 15) 10の15乗

//  多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;


// ============================================
int main() {
    int N;
    std::cin >> N;
  
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for (int i = 0; i < N; ++i) {
      std::string s;
      std::cin >> s;
      const char* const c = s.c_str();
      if (c[0] == 'A') {
        ac++;
      } else if (c[0] == 'W') {
        wa++;
      } else if (c[0] == 'T') {
        tle++;
      } else {
        re++;
      }
    }

  std::cout << "AC x " << ac << std::endl;
  std::cout << "WA x " << wa << std::endl;
  std::cout << "TLE x " << tle << std::endl;
  std::cout << "RE x " << re << std::endl;
  
  
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
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; }

// ****************************************CODE***************************************//


ll n;
ll a[110000][3];
ll dp[110000][3];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++)for(int j = 0; j < 3; j++) cin >> a[i][j];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < 3; i++) ans = max(ans, dp[n][i]);

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


Measured memory_bytes: 5120
#Coins
a = int(input()) #500円玉
b = int(input()) #100円玉
c = int(input()) #50円玉
x = int(input()) #総額
#硬貨の選び方は何通りあるか
count = 0
for i in range(0,a+1):
  y = x - 500 * i
  if y < 0:
    break
  for j in range(0,b+1):
    z = y - 100 * j
    if z < 0:
      break
    elif (z / 50) <= c:
      count += 1
print(count)

Measured memory_bytes: 9016
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n;
	cin >> n;
	int x[n];
	int y[n];
	rep(i,n){
		cin >> x[i];
		y[i]=x[i];
	}
	sort(y,y+n);
	int a,b;
	if(n%2==0){
		a=y[n/2-1];
		b=y[n/2];
	}else{
		a=y[n/2];
		b=y[n/2+1];
	}

	rep(i,n){
		if(x[i]<=a){
			cout << b << endl;
		}else{
			cout << a << endl;
		}
	}
	return 0;
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

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


Measured memory_bytes: 3712