akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r, h, w;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;
    vector<string> sr;
    vector<vector<char>> arr;

    cin >> s >> t;
    sans = "No";

    rep(i,s.size()){
        string head = s.substr(0,i);
        string tail = s.substr(i);

        if(tail + head == t){
            std::cout << "Yes" << endl;
            return;
        }
    }

    // std::cout << ans << endl;

    std::cout << sans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

using ll = long long;
using ull = unsigned long long;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;


int main()
{
	string s, t;
	cin >> s >> t;
	ll tLen = t.length();
	ll sLen = s.length();
	ll ans = tLen;
	for( ll i = 0; i <= sLen - tLen; i++ )
	{
		ll tmp = 0;
		for( ll j = 0; j < tLen; j++ )
		{
			if( s[i+j] != t[j] )
			{
				tmp++;
			}
		}
		if( tmp < ans )
		{
			ans = tmp;
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

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

	public Main() {
		new aoj0042().doIt();
	}

	class aoj0042 {	
		void DP(int W,int TE[],int TW[],int n,int sum[]){
			for(int i = 0;i < n;i++){
				for(int j = W;j > 0;j--){
					if(sum[j] > 0)sum[j+TW[i]] = Math.max(sum[j+TW[i]], sum[j] + TE[i]);
				}
				sum[TW[i]] = Math.max(sum[TW[i]], TE[i]);
			}
		}
		void doIt() {
			int cnt = 1;
			while (true) {
				int W = sc.nextInt();
				if (W == 0)break;
				int n = sc.nextInt();
				int sum[] = new int [3*W];
				int TE[] = new int [n];
				int TW[] = new int [n];
				for (int i = 0; i < n; i++) {
					String[] node = sc.next().split(",");
					TE[i] = Integer.valueOf(node[0]);
					TW[i] = Integer.valueOf(node[1]);
				}
				System.out.println("Case "+cnt+":");
				DP(W,TE,TW,n,sum);
				int Eans = 0;
				int Wans = 0;
				for(int i = 0;i <= W;i++){
					if(Eans < sum[i]){
						Eans = sum[i];
						Wans = i;
					}
				}
				System.out.println(Eans);
				System.out.println(Wans);
				cnt++;
			}
		}
	}
}

Measured memory_bytes: 24148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define int long long
 
#define iin(x) scanf("%d", &x)
#define lin(x) scanf("%lld", &x)
#define fin(x) scanf("%lf", &x)
 
#define iout(x) printf("%d", x)
#define lout(x) printf("%lld", x)
#define fout(x) printf("%.10f", x)
#define _ putchar(' ')
#define endl puts("")
 
#define reps(i, x, n) for(i = (x); i < (n); i++)
#define rep(i, n) reps(i, 0, n)
 
int L[500001], R[500001];
 
int merge(int A[], int left, int mid, int right) {
  int res = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  int i, j, k;
  rep(i, n1) L[i] = A[left+i];
  rep(i, n2) R[i] = A[mid+i];
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  i = 0, j = 0;
  reps(k, left, right) {
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
      res += n1 - i;
    }
  }
  return res;
}
 
int mergeSort(int A[], int left, int right) {
  int a = 0, b = 0, c = 0;
  if(left + 1 < right) {
    int mid = (left + right) / 2;
    a = mergeSort(A, left, mid);
    b = mergeSort(A, mid, right);
    c = merge(A, left, mid, right);
  }
  return a+b+c;
}
 
int A[500001];
 
signed main() {
  int n; lin(n);
  int i;
  rep(i, n) lin(A[i]);
  lout(mergeSort(A, 0, n)),endl;
 
  return 0;
}

Measured memory_bytes: 9580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int cnt=0;

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

		System.out.println(cnt);
	}
}

Measured memory_bytes: 22868
#include<stdio.h>
int main()
{
	long long int a,b,k;
	scanf("%lld%lld%lld",&a,&b,&k);

	if(a>=k)
		printf("%lld %lld\n",a-k,b);
	else if(a+b>=k)
		printf("0 %lld\n",a+b-k);
	else 
		printf("0 0\n");


}



Measured memory_bytes: 128
fn f(n: usize, x: i64, a: &[i64], b: &[i64]) -> i64 {
    if n == 0 {
        return if x <= 0 { 0 } else { 1 };
    }
    if x <= 1 + a[n - 1] {
        return f(n - 1, x - 1, a, b);
    }
    if x == 2 + a[n - 1] {
        return b[n - 1] + 1;
    }
    if x <= 2 + 2 * a[n - 1] {
        return b[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1], a, b);
    }
    if x == 3 + 2 * a[n - 1] {
        return 2 * b[n - 1] + 1;
    }
    //println!("{} {} {}", n, x, a[n - 1]);
    assert!(false);
    0
}
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let x: i64 = sc.read();
    let mut a: Vec<i64> = vec![0i64; n];
    let mut b: Vec<i64> = vec![0i64; n];
    a[0] = 1;
    b[0] = 1;
    for i in 1..n {
        a[i] = 2 * a[i - 1] + 3;
        b[i] = 2 * b[i - 1] + 1;
    }

    let result = f(n, x, &a, &b);
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
/*  ABC146_A */
#include <stdio.h>
#include<string.h>

int main(void){

	char S[5];
	scanf("%s",S);

	char r[7][5] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

	for(int i=0;i<7;i++){
		// printf("%s\n",r[i]);
		if(strcmp(S,r[i])==0){
			printf("%d",7-i);
		}
	}
	return 0;
}


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

int main() {
  int N; cin >> N;
  map<string, int> m;
  vector<string> v;
  int x = 0;
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    m[s]++;
    if (x < m[s]) {
      v = {s};
      x = m[s];
    }
    else if (x == m[s]) v.push_back(s);
  }
  sort(v.begin(), v.end());
  for (string s : v) cout << s << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  map<double, long long> price;
  price[0.25] = a;
  price[0.50] = b;
  price[1.00] = c;
  price[2.00] = d;
  long long n;
  cin >> n;
  auto make_l = [](double x) {
    return (long long) (1.0 / x);
  };
  auto Cost = [&](long long foo) {
    long long res = 1e18;
    for (double x = 0.25; x <= 1; x += 0.25) {
      if (x == 0.75) continue;
      res = min(res, foo * make_l(x) * price[x]);
    }
    return res;
  };
  cout << min(Cost(n), n / 2 * d + Cost(n % 2)) << '\n';
  return 0;
}


Measured memory_bytes: 256
def main():
    N, X = [int(val) for val in input().split()]
    ball_place = 0
    input_line = [int(val) for val in input().split()]
    assert len(input_line) == N
    bounded_num = 1
    for diff in input_line:
        ball_place += diff
        if ball_place <= X:
            bounded_num += 1
        else:
            break
    print(bounded_num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// =====================================================================================
//
//       Filename:  at.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  19/04/20 05:21:38 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:  
//
// =====================================================================================

#include<bits/stdc++.h>


using namespace std;

#define int long long 
#define pb push_back
//#define _SHOW_TIME

void solve(){
    //your code here;
   int n ;
   cin>>n;
   n--;
   vector<int> a(n);

   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a.begin(),a.end());
   vector<int> b(n+1,0);
   for(int i=0;i<a.size();i++){
       b[ a[i]-1 ]++;
   }

   for(int i=0;i<b.size();i++){
       cout<<b[i]<<endl;
   }
}
int32_t main(){
 /////////////////////////////////////
    #ifdef _SHOW_TIME
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
    solve();
    /////////////////////////////////////
    #ifdef _SHOW_TIME
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
    return 0;

}



Measured memory_bytes: 6368
#include<bits/stdc++.h>
#define For(i,j,k)  for(int i=j;i<=k;++i)
#define Dow(i,j,k)  for(int i=k;i>=j;--i)
#define ll long long
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read()
{
	ll t=0,f=1;char c=gc();
	while(!isdigit(c))  {if(c=='-') f=-1;c=gc();}
	while(isdigit(c))   t=t*10+c-'0',c=gc();
	return t*f;
}
inline void write(ll x){if(x<0) {putchar('-');write(-x);return;}if(x>=10)    write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}

ll n,ans,sum;
map<ll,ll> mp;
int main()
{
	n=read();
	mp[0]++;
	For(i,1,n)
	{
		sum+=read();
		ans+=mp[sum];mp[sum]++;
	}
	writeln(ans);
} 

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  string S; cin >> S;
  int ans = 0;
  if(S[0] == 'R'){
    ans++;
  }
  if(S[1] == 'R'){
    ans++;
  }
  if(S[2] == 'R'){
    ans ++;
  }
  if(ans == 2 && S[1] != 'R'){
    ans = 1;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> pii;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	
	vector<pii> rel(m + n + 1);
	vector<vector<int> > G(n + 1), from(n + 1);
	vector<int> cnt(n + 1);
	for(int i = 1; i <= m; ++i){
		scanf("%d%d", &rel[i].first, &rel[i].second);
		G[rel[i].first].push_back(i);
		++cnt[rel[i].second];
	}
	for(int i = 1; i <= n; ++i){
		rel[i + m] = pii(i, 0);
		G[i].push_back(i + m);
		++cnt[0];
	}

	vector<int> d(n + 1, -1);
	queue<int> q;
	for(int i = 0; i <= n; ++i){
		if(cnt[i] == 0){
			d[i] = 0;
			q.push(i);
		}
	}
	q.push(-1);
	int t = 0;
	while(q.size() > 1){
		int a = q.front();
		q.pop();
		if(a == -1){
			q.push(-1);
			++t;
		}
		else if(d[a] == t){
			for(int i = 0; i < G[a].size(); ++i){
				int u = rel[G[a][i]].second;
				if(d[u] <= t){
					d[u] = t + 1;
					from[u].clear();
				}
				if(d[u] == t + 1){
					from[u].push_back(G[a][i]);
				}
				
				if(--cnt[u] == 0){
					q.push(u);
				}
			}
		}
	}
	
	vector<int> ans;
	q.push(0);
	vector<char> vis(n + 1);
	vis[0] = 1;
	while(q.size() > 1){
		int a = q.front();
		q.pop();
		if(a == -1){
			q.push(-1);
		}
		else{
			if(a != 0 && q.size() == 1 && from[a].size() == 1){
				ans.push_back(from[a][0]);
			}
			
			for(int i = 0; i < from[a].size(); ++i){
				int u = rel[from[a][i]].first;
				if(!vis[u]){
					vis[u] = 1;
					q.push(u);
				}
			}
		}
	}
	
	sort(ans.begin(), ans.end());
	if(ans.empty()){ ans.push_back(-1); }
	for(int i = 0; i < ans.size(); ++i){
		printf("%d\n", ans[i]);
	}
}

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

int main(){
  int n;
  cin >> n;
  double su=0,b;
  for(int i=0;i<n;i++){
    cin >> b;
    su+=1/b;
  }
  cout << 1/su << endl;
  return 0;
}

Measured memory_bytes: 3788
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] matrix = new char[H+2][W+2];
    for (int i=1; i<H+1; i++) {
      String s = " " + sc.next() + " ";
      matrix[i] =s.toCharArray();
    }
    for (int i=1; i<H+1; i++) {
      for (int j=1; j<W+1; j++) {
        int count =0;
        if (matrix[i][j] == '#') {
          System.out.print('#');
          continue;
        }
        if (matrix[i-1][j+1] == '#') count++;
        if (matrix[i-1][j] == '#') count++;
        if (matrix[i-1][j-1] == '#') count++;
        if (matrix[i][j+1] == '#') count++;
        if (matrix[i][j-1] == '#') count++;
        if (matrix[i+1][j+1] == '#') count++;
        if (matrix[i+1][j] == '#') count++;
        if (matrix[i+1][j-1] == '#') count++;
        System.out.print(count);
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 22868
n = int(input())
cnt = [0] * 5
ans = 0
for _ in range(n):
    s = input()
    if s[0] == 'M':
        cnt[0] += 1
    elif s[0] == 'A':
        cnt[1] += 1
    elif s[0] == 'R':
        cnt[2] += 1
    elif s[0] == 'C':
        cnt[3] += 1
    elif s[0] == 'H':
        cnt[4] += 1
    else:
        continue

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += cnt[i] * cnt[j] * cnt[k]
            
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,i,j,s=0,a[100010],b[100010];
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld %lld",&a[R],&b[R]);
    hin(a[R]+b[R]);
  }
  for(i=0;i<n;i++){
    j=hout();
    s+=i%2?-b[j]:a[j];
  }
  printf("%lld\n",s);
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << ((k&1) ? b-a : a-b) << endl;

}



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

int main() {
    using namespace std;
    unsigned long K;
    long X, Y, x{1}, y{1};
    cin >> K >> X >> Y;
    if(~K & (X ^ Y) & 1)return 0 & puts("-1");
    Y = -2 * Y + (X = X + Y);
    if(X < 0)X *= x = -1;
    if(Y < 0)Y *= y = -1;
    vector<pair<long, long>> ans;
    if(X < K && Y < K){
        if(X & 1){
            ans.emplace_back(X - K + 1, K);
            ans.emplace_back(X - K, 0);
        }else ans.emplace_back(X - K, K);
    }else{
        unsigned long time = (max(X, Y) - 1) / K + 1;
        if(K & (time ^ X) & 1)++time;
        unsigned long remX{time * K - X}, remY{time * K - Y}, a{0}, b{0}, t, k{0};
        for(unsigned long i = 1; i < time; ++i){
            remX -= t = min(remX, 2 * K);
            if(!t)remY -= k = min(remY, 2 * K);
            ans.emplace_back(a += K - t, b += K - k);
        }
    }
    ans.emplace_back(X, Y);
    cout << ans.size() << endl;
    for(const auto& i : ans)cout << (x * i.first + y * i.second) / 2 << " " << (x * i.first - y * i.second) / 2 << endl;
    return 0;
}

Measured memory_bytes: 5484
colors = ["R", "B", "Y", "G"]

if __name__ == '__main__':
    H, W, d = list(map(int, input().split()))

    ans = [["" for j in range(W)] for i in range(H)]
    for i in range(0, H):
        for j in range(0, W):
            # 45度変換後の値、x,y
            x = i - j
            y = i + j

            if 1 <= x % (2 * d) <= d:
                if 1 <= y % (2 * d) <= d:
                    ans[i][j] = "R"
                else:
                    ans[i][j] = "B"
            else:
                if 1 <= y % (2 * d) <= d:
                    ans[i][j] = "Y"
                else:
                    ans[i][j] = "G"

    for tmpans in ans:
        print("".join(tmpans))


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

int main() {
    /* 入力受け取り */
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    /* しゃくとり法 */
    long long res = 0;
    int right = 0;
    int sum = 0; // AND 和
    for (int left = 0; left < n; ++left) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            ++right;
        }
        res += right - left;
        //if (left == right) ++right;
        //else {
            sum -= a[left]; // a[left] を削除 (sum ^= a[left] でも OK)
        //}
    }

    cout << res << endl;
}

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

class Cube
{
  public:
	  int f[6];
	  Cube (){}
	  void roll_z()
	  {
		  roll(1, 2, 4, 3);
	  }
	  void roll_y()
	  {
		  roll(0, 2, 5, 3);
	  }
	  void roll_x()
	  {
		  roll(0, 1, 5, 4);
	  }
	  void roll(int i, int j, int k, int l)
	  {
		  int t = f[i];
		  f[i] = f[j];
		  f[j] = f[k];
		  f[k] = f[l];
		  f[l] = t;
	  }
};

bool eq( Cube c1, Cube c2 )
{
	for ( int i = 0; i < 6; i++)
	{
		if ( c1.f[i] != c2.f[i] )
		{
			return false;
		}
	}
	return true;
}

bool equal( Cube c1, Cube c2 )
{
	for ( int i = 0; i < 6; i++)
	{
		for ( int j = 0; j < 4; j++)
		{
			if ( eq(c1, c2) )
			{
				return true;
			}
			else 
			{
			c1.roll_z();
			}
		}
		if ( i % 2 == 0 )
		{
			c1.roll_y();
		}
		else
		{
			c1.roll_x();
		}
	}
		return false;
	}

int n;
Cube c[100];

bool Check ( )
{
	for ( int i = 0; i < n-1; i++)
	{
		for ( int j = i+1; j < n; j++)
		{
			if ( equal(c[i], c[j]) )
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{	
	cin >> n;
	for ( int i = 0; i < n; i++ )
	{
	for ( int j = 0; j < 6; j++ )
	{
		cin >> c[i].f[j];
	}
	}

	if ( Check( ) )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


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

int main()
{
	// 整数の入力
	int n, t;
	cin >> n >> t;

	int ci[1000], ti[1000];
	int minVal = 1001;
	for (int i = 0; i < n; i++) {
		cin >> ci[i] >> ti[i];

		if (t >= ti[i]) {
			minVal = min(minVal, ci[i]);
		}
	}

	if (minVal == 1001) cout << "TLE";
	else  cout << minVal;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    auto good = [&](long long x) {
        int f = 0;
        while (x > 0) {
            int d = x % 10;
            x /= 10;
            if (d == 7 || d == 5 || d == 3) {
                f |= 1 << ((d - 3) / 2); 
            } else {
                return false;
            }
        }
        return f == 7;
    };
    queue<long long> que;
    que.push(0);


    int res = 0;
    while (!que.empty()) {
        long long x = que.front();
        que.pop();
        if (good(x)) {
            ++res;
        }
        for (auto d : {7, 5, 3}) {
            long long nx = x * 10 + d;
            if (nx <= n) {
                que.push(nx);
            }
        }
    }
    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
typedef long long LL;
int N,i,j,x,A[200000],here[200000],town[200000];LL K;
inline LL IN(void)
{
  LL x=0;int f=1;char c=getchar();
  while((c<'0'||c>'9')&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();
  return f*x;
}
int main(void)
{
  N=IN(),K=IN();
  for(i=0;i<N;i++)A[i]=IN(),here[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return printf("%d\n",town[K]+1),0;
}

Measured memory_bytes: 3840
N = int(input())
A = [int(x) for x in input().split()]
key = 1000000007
sum = 0
sum2 = 0
for i in range(N):
    sum += A[i]
    #if sum >= key:
     #   sum %= key

for i in range(N):
    sum2 += A[i]**2
    #if sum2 >= key:
     #   sum2 %= key
        
ans = (sum*sum - sum2)//2%key
print(ans)
    

Measured memory_bytes: 31684
package main

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	x := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		x[i], _ = strconv.Atoi(sc.Text())
	}
	result := 100000000000
	for i := 0; i < n-k+1; i++ {
		d := x[i+k-1] - x[i]
		m := min(abs(x[i+k-1]), abs(x[i]))
		r := d + m
		result = min(r, result)
	}
	fmt.Println(result)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    ll ans = 0;
    REP(i, N-1) {
        ans += A[i] / 2;
        if (A[i] % 2 == 1 && A[i+1] > 0) {
            A[i+1]--;
            ans++;
        }
    }
    ans += A.back() / 2;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	ll a[n], b[n];
	REP(i, n) cin >> a[i] >> b[i];
	ll ans = 0;
	ll cur = 0;
	for(int i = n-1; i >= 0; i--){
		int diff;
		if((a[i] + cur) % b[i] == 0) diff = 0;
		else diff = b[i] - ((a[i] + cur) % b[i]);
		ans += diff;
		cur += diff;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())

Road = []
for _ in range(m):
    a, b = map(int, input().split())
    Road.append((a, b))

tmp = sorted(Road)
#print(tmp)

ans = [0]*n
for t in tmp:
  ans[t[0]-1] += 1
  ans[t[1]-1] += 1

for a in ans:
  print(a)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define mx 200000
int tr[mx*5];
int ar[mx+3];
void seg(int no,int s,int e,int ind){
    if(s==e){
        tr[no] = s;
        return;
    }
    int mid=(s+e)/2;
    if(mid>=ind)
    seg(no*2,s,mid,ind);
    else 
    seg(no*2+1,mid+1,e,ind);
    if(ar[tr[no*2]]>ar[tr[no*2+1]])tr[no] = tr[no*2];
    else tr[no] = tr[no*2+1];
}
int val;
int qu(int no,int s,int e,int st,int en, bool fl){
    if(s>=st&&e<=en){
        if(s==e)return tr[no];
        int mid =(s+e)/2;
        if(fl==0){
            int pos= tr[no*2];
            int pos1=tr[no*2+1];
           // cout<<st<<" "<<en<<" "<<pos<<" "<<pos1<<endl;
            if(ar[pos1]>val)return qu(no*2+ 1,mid+1,e,st,en,fl);
            else return qu(no*2,s,mid,st,en,fl);
        }
        else 
        {
            int pos= tr[no*2];
            int pos1=tr[no*2+1];
           // cout<<s<<" "<<e<<" "<<pos<<" "<<pos1<<" "<<val<<" "<<ar[pos]<<endl;
            if(ar[pos]>val)return qu(no*2,s,mid,st,en,fl);
            else return  qu(no*2+1,mid+1,e,st,en,fl);
        }
    }
    int mid = (s+e)/2;
    if(mid>=en)return qu(no*2,s,mid,st,en,fl);
    else if(mid<st)return qu(no*2+1, mid+1,e,st,en,fl);
    else
    {
        if(fl==0){
            int pos= qu(no*2, s, mid,st,mid,fl);
            int pos1=qu(no*2+1,mid+1,e,mid+1,en,fl);
            if(ar[pos1]>val)return pos1;
            else return pos;
        }
        else 
        {
     
            int pos= qu(no*2, s, mid,st,mid,fl);
            int pos1=qu(no*2+1,mid+1,e,mid+1,en,fl);
                   //cout<<st<<" "<<mid<<" "<<en<<" "<<pos<<" "<<pos1<<endl;
            if(ar[pos]>val)return pos;
            else return pos1;
        }
    }
    
}
#define ll long long 
int main(){

    int tc,n;
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }
       ar[0] = n+1, ar[n+1] = n+1;
    for(int i=0;i<=n+1;i++)seg(1,0,n+1,i);
 
//     seg(1,0,n+1);
//     //val = ar[2];
//    // cout<<(qu(1,0,n+1,3,n+1,1))<<endl;
//     for(int i=1;i<=n;i++){
//         val = ar[i];
        
//     }

    //cout<<qu(1,0,n+1,0,0,0)<<endl;
    ll ans =0;
    for(int i=1;i<=n;i++){
        val = ar[i];
        int fi1,fi2=-1,sc1,sc2=n+2;
        fi1 = qu(1,0,n+1, 0, i-1,0);
        if(fi1>0)fi2=qu(1,0,n+1,0,fi1-1,0);
         sc1 = qu(1,0,n+1, i+1, n+1,1);
        if(sc1 <= n)sc2=qu(1,0,n+1,sc1+1,n+1,1);
       // cout<<i<<" "<<fi2<<" "<<fi1<<" "<<sc1<< " "<<sc2<<endl;
        ll kol = (fi1>0?((fi1-fi2)*(sc1-i)):0) + (sc1<=n?((sc2-sc1)*(i-fi1)):0);
       // cout<<kol<<endl;
        ans+=kol*(ll)val;

    } 
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1664
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)

	n := len(s)
	sum := make([]int, n+1)
	for i := 0; i < n; i++ {
		sum[i+1] = sum[i]
		if s[i] == 'p' {
			sum[i+1] = sum[i] + 1
			continue
		}
	}
	p := n >> 1

	ans := p - sum[n]

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 1664
#include <iostream>
#define N 8
#define Free -1
#define Not_Free 1

int row[N], col[N];
int dposition[2*N-1], dnegotiation[2*N-1];
bool X[N][N];

void Initialize(){
  for(int i=0; i<N; i++){ row[i] = Free, col[i] = Free; }
  for(int i=0; i<2*N-1; i++){ dposition[i] = Free, dnegotiation[i] = Free; }
}

void PrintBoard(){
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if( X[i][j] ){
        if( row[i] != j ) return;
      }
    }
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      std::cout << ((row[i] == j) ? "Q" : "." );
    }
    std::cout << std::endl;
  }
}

void Recursive(int i){
  //success placement of Queen
  if( i == N ){
    PrintBoard();
    return;
  }
  //if attacked by Queen, ignore.
  for(int j=0; j<N; j++){
    if( col[j] == Not_Free ||
        dposition[i+j] == Not_Free ||
        dnegotiation[i-j+N-1] == Not_Free ) continue;

    //placement of Queen in (i,j)
    row[i] = j;
    col[j] = dposition[i+j] = dnegotiation[i-j+N-1] = Not_Free;
    //next row
    Recursive(i+1);
    //Remove Queen placed in (i,j)
    row[i] = col[j] = dposition[i+j] = dnegotiation[i-j+N-1] = Free;
  }
  //Failure
}

int main(){
  Initialize();

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      X[i][j] = false;
    }
  }
  int k;
  std::cin >> k;
  for(int i=0; i<k; i++){
    int r, c;
    std::cin >> r >> c;
    X[r][c] = true;
  }
  Recursive(0);
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
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; }

signed main(){
    int n, x, t;
    cin >> n >> x >> t;
    int i = 0;
    int cnt = 0;
    while(true){
        cnt += x;
        i += t;
        if(cnt >= n) break;
    }
    cout << i << endl;
}

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

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

Measured memory_bytes: 3628
while(1):
    try:
        alist = list(map(int, input().split()))
        blist = list(map(int, input().split()))
    except:
        break
 
    hit = 0
    blow = 0
 
    for i in range(4):
        for j in range(4):
            if alist[i] == blist[j]:
                if i == j:
                    hit += 1
                else:
                    blow += 1
 
    print(hit, blow)


Measured memory_bytes: 5592
import java.util.ArrayList;
    import java.util.List;
    import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            int M = sc.nextInt();
            List<List<Integer>> s = new ArrayList<>(M);
            for(int i = 0; i < M; i++) {
                int k = sc.nextInt();
                List<Integer> l  = new ArrayList<>();
                for(int j = 0; j < k; j++) {
                    l.add(sc.nextInt() - 1);
                }
                s.add(l);
            }
            List<Integer> p = new ArrayList<>();
            for(int i = 0; i < M; i++) {
                p.add(sc.nextInt());
            }
     
            long res = 0;
            for(int bit = 0; bit < (1 << N); bit++) {
                boolean ok = true;
                for(int i = 0; i < M; i++) {
                    int count = 0;
                    for(int t : s.get(i)) {
                        if(((bit >> t) & 1) == 1) count++;
                    }
                    if(count % 2 != p.get(i)) {
                        ok = false;
                        break;
                    }
                }
                if(ok) res++;
            }
            System.out.println(res);
        }
    }

Measured memory_bytes: 36328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int V, E; cin >> V >> E;
    vector<vector<int>> to(V);
    vector<int> Nyuji(V);
    for(int i=0; i<E; i++){
        int s, t; cin >> s >> t;
        to[s].push_back(t);
        Nyuji[t]++;
    }
    
    vector<PII> S;
    for(int i=0; i<V; i++){
        if(Nyuji[i]==0) S.push_back({i, 1});
    }
    
    vector<int> ans;
    int done = 0;
    while(S.size()){
        PII p = S.back();
        done++;
        ans.push_back(p.fs);
        S.pop_back();
        for(int t:to[p.fs]){
            Nyuji[t]--;
            if(Nyuji[t]==0){
                S.push_back({t, p.sc+1});
            }
        }
    }
    
    if(done!=V){
        cout << -1 << endl;
        return 0;
    }
    
    for(int a:ans) cout << a << endl;
    
    return 0;
}




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

int main(){
	int n; cin >> n;
  	int k = n%10;
  	if(k==2||k==4||k==5||k==7||k==9) cout << "hon";
  	else if(k==3) cout << "bon";
  	else cout << "pon";
}

Measured memory_bytes: 3632
num = int(input())

def exe001(num):
    factor = 2
    factor_list = []
    flag = 'Yes'

    while num > 1 or factor < 10:
        if num % factor == 0:
            factor_list.append(factor)
            num //= factor
        else:
            factor += 1
    # print(factor_list)

    if len(factor_list) > 3:
        for item in factor_list:
            if item >= 5:
                flag = 'No'
                break
            else:
                if len(factor_list) > 6:
                    flag = 'No'
                    break
                elif len(factor_list) > 5:
                    if 3 in factor_list:
                        flag = 'No'
                        break                      

    elif len(factor_list) == 3:
        if factor_list[0] * factor_list[1] < 10 and factor_list[2] < 10:
            pass
        else:
            flag = 'No'

    else:
        for item in factor_list:
            if item >= 10:
                flag = 'No'
                break


    print(flag)
exe001(num)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cctype>
using namespace std;
int main(){
  string N;cin>>N;
  if (N[0]==N[2]){
    puts("Yes");
  } else {
    puts("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string N;
int S;

int main(void){
	//IO("test.in", "test.out");
	cin >> N;
	for(int i = 0; i < N.length(); i++) S += N[i] - '0';
	if(stoi(N) % S == 0) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  char s[100005];
  gets(s);
  int n = strlen(s), ans[n];
  for (size_t i = 0; i < n; i++) {
    ans[i] = 1;
  }
  for (size_t i = 0; i < n-1; i++) {
    if (s[i] == 'R' && s[i+1] == 'R') {
      ans[i+2] += ans[i];
      ans[i] = 0;
    }
  }
  for (size_t i = n-1; i > 0; i--) {
    if (s[i] == 'L' && s[i-1] == 'L') {
      ans[i-2] += ans[i];
      ans[i] = 0;
    }
  }
  for (size_t i = 0; i < n; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include<algorithm>
using namespace std;
int p[1000];
int main()
{
	int n,k;
	
	cin>>n>>k;
	for(int i=0;i<n;i++)
	cin>>p[i];
	sort(p,p+n);
	int sum=0;
	for(int i=0;i<k;i++)
	sum+=p[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3180
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	while(true) {

		int e;

		scanf("%d", &e);
		if(e == 0)
			break;

		int m = e;

		for(int z = 0; z * z * z <= e; ++z) {

			int z3 = z * z * z;

			for(int y = 0; y * y + z3 <= e; ++y) {

				int y2 = y * y;
				int x = e - z3 - y2;

				m = min(m, (x + y + z));
			}
		}

		printf("%d\n", m);
	}

	return 0;
}

Measured memory_bytes: 1028
n = int(input())
anss = ["1","2","3","4","5","6","7","8","9"]
cot  = 0

cot = 9
while cot < n:
    for temp in anss: #tempは条件を満たしている→tempの後ろにiが付けられたらそれも条件を満たす
        temp_int = int(temp[-1])
        start = max(0,temp_int - 1)
        end = min(10, temp_int + 2)
        for i in range(start,end):
            anss.append(temp + str(i))
            cot += 1
        if cot > n:
            break




anss = list(map(int,anss))
anss.sort()
print(anss[n -1])

Measured memory_bytes: 53884
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
a = list(map(int, input().split()))

one = a.count(1)
two = a.count(2)
three = a.count(3)

dp = [[[-1] * 301 for _ in range(301)] for _ in range(301)]

def rec(i, j, k):
    if dp[i][j][k] >= 0:
        return dp[i][j][k]

    if i == 0 and j == 0 and k == 0:
        return 0.0

    res = 0.0

    if i > 0:
        res += rec(i - 1, j, k) * i
    if j > 0:
        res += rec(i + 1, j - 1, k) * j
    if k > 0:
        res += rec(i, j + 1, k - 1) * k
        
    res += N

    res /= i + j + k

    dp[i][j][k] = res
    return res

res = rec(one, two, three)

print(res)


Measured memory_bytes: 397984
#include <iostream>

using namespace std;

int main()
{
  int A,B;
  cin>>A>>B;
 if(A>=0&&A<=100&&B>=2&&B<=1000){
  if(A>=13){
      cout<<B;
  }
  else if(A>=6&&A<=12){
      cout<<B/2;
  }
  else{
      cout<<0;
  }
 }
    return 0;
}

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

int main() {
    int n;
    string a="No";
    cin >> n;

    for (int i = 0; i < 26; i++)
    {
        for (int j = 0; j < 15; j++)
        {
            if(i*4+j*7==n) a="Yes";
        }
        
    }
    cout << a << endl; 
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]


def inputlist():
  return [int(j) for j in input().split()]


 
for i in range(n-m+1):
    for j in range(n-m+1):
        a1 = [a[k][j:j+m] for k in range(i,i+m)]
        if a1 == b:
            print('Yes')
            exit()
 
print('No')

Measured memory_bytes: 39152
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
 
int main(){
    
		ll  a,b,c,k;
		cin>>a>>b>>c>>k;
		ll ans=0;
		ans+=min(a,k);
		k-=min(a,k);
		k-=min(k,b);
		ans-=min(k,c);
		cout<<ans;
	
	
}

Measured memory_bytes: 3636
s = input()
base = ord('a')
col = [-1 for x in range(26)]
check = [0 for x in range(26)]
maxi = [0 for x in range(26)]
for index, i in enumerate(s):
    check[ord(i) - base] = 1
    if index - col[ord(i) - base] - 1  > maxi[ord(i) - base]:
        maxi[ord(i) - base] = index - col[ord(i) - base] - 1
    col[ord(i) - base] = index
leng = len(s)
out = [10**9 for x in range(26)]
min = 10**9
#print(col,maxi,check)
for i in range(26):
    if check[i] != 0:
        store = 0
        if maxi[i] > leng - 1 - col[i]:
            store = maxi[i]
        else:
            store = leng - 1 - col[i]
        if min > store:
            #print(chr(base+i))
            min = store
print(min)


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;


// dp[i][j] := i個目までの品物で、重さjとなるときの最大の価値
lli dp[101][100001];

int main() {
    lli n, W;
    cin2(n, W);
    lli w[n+1];
    lli v[n+1];
    REP(i,0,n) {
        cin >> w[i+1] >> v[i+1];
    }
    w[0] = v[0] = 0;

    lli ans = 0;
    REPE(i,1,n) {
        REPE(j,0,W) {
            if (j - w[i] >= 0) {
                dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 78336
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<stdlib.h>

using namespace std;

int main()
{
    int n,sum;
    double p1=0,p2=0,p3=0,pp=0,max=0;
    cin >> n;
    int x[n],y[n];
    for(int i = 0;i < n;i++){
        cin >> x[i];
    }
    for(int i = 0;i < n;i++){
        cin >> y[i];
    }
    for(int i = 0;i < n;i++){
        p1 += abs(x[i]-y[i]);
    }
    for(int i = 0;i < n;i++){
        p2 += pow(x[i]-y[i],2);
    }
    p2 = sqrt(p2);

    for(int i = 0;i < n;i++){
        p3 += pow(abs(x[i]-y[i]),3);
    }
    p3 = pow(p3,1.0*1/3);
    for(int i = 0;i < n;i++){
        if(abs(x[i]-y[i]) > max) max = abs(x[i]-y[i]);
    }
    pp = max;

    cout << fixed << setprecision(8);
    cout << p1 << endl << p2 << endl << p3 << endl << pp << endl;


    return 0;
}


Measured memory_bytes: 3456