akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

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


  for(int c = 97; c <= 122; c++) {
    bool flag = false;
    for(int i = 0; i < s.size(); i++)
      flag |= s[i]==c;
    if(flag)
      continue;
    else {
      cout << (char)c << endl;
      return 0;
    }
  }
  cout << "None" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<math.h>
using namespace std;

int main() {
        int N;
        int num[10010];
        int ans=0;
        cin >> N;
        for(int i=0; i<N; i++) cin >> num[i];

        for(int i=0; i<N; i++){
                while(num[i]%2==0){
                        num[i]/=2;
                        ans++;
                }
        }
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt()-1;
		int b = sc.nextInt()-1;

		if (b == 1) {
			System.out.println("0");
			System.exit(0);
		}

		if (b % a == 0) {
			System.out.println(b / a);
		} else {
			System.out.println(b / a + 1);
		}

		sc.close();

	}
}

Measured memory_bytes: 35768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  int key;
  struct node *right, *left, *parent;
};

struct node *root, *NIL;

struct node *find(struct node *,int);
void insert(int);
void inorder(struct node *);
void preorder(struct node *);

int main() {
  int n, i, x;
  char s[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s%d",s,&x);
    if(s[0]=='i') insert(x);
    else if(s[0]=='f'){
      struct node *t = find(root, x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else{
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y==NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(struct node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

struct node *find(struct node *u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u = u->left;
    else u = u->right;
  }
  return u;
}



Measured memory_bytes: 20604
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int n,a,b;
	cin>>n;
	vector<int>vec(n),vek(n);
	for(int i=0;i<n;i++){
		cin>>vec[i];
		vek[i]=vec[i];
	}
	sort(vek.begin(),vek.end());
	a=vek[n/2-1];
	b=vek[n/2];
	for(int i=0;i<n;i++){
		if(vec[i]<=a){
			cout<<b<<endl;
		}
		else{
			cout<<a<<endl;
		}
	}
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


#define MAX 510000
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<int> L(N);
    rep(i,N) cin >> L[i];
    
    COMinit();
    sort(all(L));

    ll ans = 0;
    
    rep(i,N)
    {
        REP(j, i+1 ,N)
        {
            int k = N-1;
            while( L[i] + L[j] <= L[k] )
            {
                if( k == j )break;
                k--;
            }
            ans += k-j;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i, j, k;
	int N;
	long long int patterns;
	int I[5];
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	for(i = 0; i < 5; i += 1) {
		I[i] = 0;
	}

	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		if(buf[0] == 'M') {
			I[0] += 1;
		} else if(buf[0] == 'A') {
			I[1] += 1;
		} else if(buf[0] == 'R') {
			I[2] += 1;
		} else if(buf[0] == 'C') {
			I[3] += 1;
		} else if(buf[0] == 'H') {
			I[4] += 1;
		}
	}

	patterns = 0;
	for(i = 0; i < 5; i += 1) {
		for(j = 0; j < i; j += 1) {
			for(k = 0; k < j; k += 1) {
				patterns += I[i] * I[j] * I[k];
			}
		}
	}
	printf("%lld\n", patterns);

	return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main() {

    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);

    ll totalA = 0;

    rep(i, N) {
        cin >> A[i];
        totalA += A[i];
    }
    
    ll totalB = 0, count = 0;

    rep(i, N) {
        cin >> B[i];
        totalB += B[i];
        C[i] = A[i] - B[i];
        if (C[i] < 0) {
            count++;
        }
    }

    ll ans = 0;

        if (count == 0) {
        ans = 0;
    }
    else if (totalA < totalB) {
        ans = -1;
    }
    else {
        sort(C.begin(), C.end());
        ll i = 0, j = N - 1, stack = 0;
        while (C[i] < 0) {
            stack += C[i];
            while (stack < 0) {
                stack += C[j];
                j--;
                count++;
            }
            i++;
        }
        ans = count;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5632
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n = int(input())
cnt = 1
for i in range(1,n+1):
    cnt *= i 
    cnt %= MOD
print(cnt)


Measured memory_bytes: 12412
#include<stdio.h>

int main(){
	
	
	int n, k;
	int ans = 1;
	
	scanf("%d %d", &n, &k);
	
	for(int i = 0; i < n; i++){
		if(ans <= k){
			ans *= 2;
		}else{
			ans += k;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 1704
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	a := y - 2*x
	b := 4*x - y
	if y < 2*x || 4*x < y {
		fmt.Println("No")
	} else if a%2 == 0 && b%2 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

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

    int res = a+b;
    res = max(res, a-b);
    res = max(res, a*b);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

ll sum(ll n){
    if (n % 2){
        return n % 4 == 1;
    }else{
        return n ^ (n % 4 == 2);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << (sum(a - 1) ^ sum(b)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, c; cin >> n >> m >> c;
    vector<int> B(m);
    for(int i = 0; i < m; i++) cin >> B[i];
    int A[50][50];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++) cin >> A[i][j];
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int sum = c;
        for(int j = 0; j < m; j++) sum += A[i][j] * B[j];
        if(sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
using namespace std;
#include<string>
#include<cmath>
#include <map>
#include <unordered_map>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9;
#include<iterator>

void solve() {
	ll x; cin >> x;
	if (x >= 30)cout << "Yes";
	else cout << "No";
}


int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif

	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ":\n";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 3648
import itertools

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

ans = []
for X in itertools.product(range(4), repeat=N):
    P = [[] for _ in range(4)]
    for i, x in enumerate(X):
        P[x].append(l[i])
    if min(map(len, P[1:]))==0:
        continue
    
    tmp = 0
    for Q, D in zip(P[1:], [A,B,C]):
        tmp+=10*(len(Q)-1)+abs(D-sum(Q))
    ans.append(tmp)    
print(sorted(ans)[0])

Measured memory_bytes: 5584
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    sa = input()
    sb = input()
    sc = input()
    state = 0
    ai,bi,ci = 0,0,0

    while ai <= len(sa) and bi <= len(sb) and ci <= len(sc):
        if state == 0:
            if ai == len(sa):
                print('A')
                return None
            state = ord(sa[ai])
            ai += 1
            
        elif state == 1:
            if bi == len(sb):
                print('B')
                return None
            state = ord(sb[bi])
            bi += 1
            
        else:
            if ci == len(sc):
                print('C')
                return None
            state = ord(sc[ci])
            ci += 1
            
        state -= ord('a')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   // int n,ans=inf;
   // cin>>n;
   // vector<int>a(n);
   // for(int i=0;i<n;i++)
   // {
   // 	cin>>a[i];
   // }
   int n,d;
   cin>>n>>d;
   int ans=n/(2*d+1);
   if(n%(2*d+1))
   	ans++;
   cout<<ans<<endl;
}	

Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define dup(x) x.erase(unique(x.begin(), x.end()),x.end())
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
// https://atcoder.jp/contests/abc172/tasks/abc172_b
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll ans = 0;
    string s,t;
    cin >> s >> t;
    ll n = s.length();
    for(int i = 0;i<n;i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans;

	return 0;
}

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

int main(){
	int n,m;
	ll l;
	cin >> n >> m >> l;
	vector<vector<ll>> dist(n, vector<ll>(n, INF));
	rep(i,n)dist[i][i] = 0;
	int a,b;
	ll c;
	rep(i,m){
		cin >> a >> b >> c;
		a--;b--;
		dist[a][b]=c;
		dist[b][a]=c;
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				if(dist[i][j] > dist[i][k]+dist[k][j]) dist[i][j]=dist[i][k]+dist[k][j];
			}
		}
	}
	vector<vector<ll>> dist2(n, vector<ll>(n, INF));
	rep(i,n){
		rep(j,n){
			if(dist[i][j] <= l) dist2[i][j] = 1;
		}
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				if(dist2[i][j] > dist2[i][k]+dist2[k][j]) dist2[i][j]=dist2[i][k]+dist2[k][j];
			}
		}
	}
	int q;
	cin >> q;
	int s,t;
	rep(i,q){
		cin >> s >> t;
		if(dist2[s-1][t-1] == INF){
			cout << -1 << endl;
		}else{
			cout << dist2[s-1][t-1]-1 << endl; 
		}
	}
	return 0;
}

Measured memory_bytes: 1920
n = int(input())
a = list(map(int, input().split(" ")))

num = len(a)
b = [0] * num

for i in reversed(range(1, num+1)):
    index = list(range(i, num+1, i))
    # print(index)
    count = 0
    for s in index:
        count += b[s-1]
    # print(count)

    if a[i-1] != count % 2:
        b[i-1] = 1

if max(b) == 0:
    print(0)
else:
    s = []
    for i, x in enumerate(b):
        if x == 1:
            s.append(i+1)
    print(len(s))
    print(" ".join(map(str, s)))


Measured memory_bytes: 27828
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static class Pair<T,U>{
		T l;U r;
		Pair(T L,U R){l=L;r=R;}
		T getL(){return l;}
		U getR(){return r;}
	}

	public static void main(String[]$){
		String in=s.next();
		System.out.println(""+in.charAt(0)+(in.length()-2)+in.charAt(in.length()-1));
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env pypy
 
import sys
import string
from collections import Counter

def get_int(): return int(sys.stdin.readline().strip())
def get_ints(): return map(int, sys.stdin.readline().strip().split()) 
def get_list(): return list(map(int, sys.stdin.readline().strip().split())) 
def get_string(): return sys.stdin.readline().strip()
def out(data): return sys.stdout.write(str(data))
def out_list(arr): return sys.stdout.write(' '.join(str(e) for e in arr))

MAX = 10**9
MOD = 10**9 + 7

n = get_int()
arr = get_list()
d = Counter(arr)
q = get_int()
sum_ = sum(arr)

for _ in range(q):
	a, b = get_ints()
	if a in d.keys() :
		sum_ += d[a] * (b - a)
		count = d[a]
		d.pop(a)
		if not d[b]:
			d[b] = count
		else:
			d[b] += count
	out(sum_)
	out('\n')




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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, S.size()) if (S[i] != T[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3836
#include <stdio.h>
struct node{
  int key;
  int parent;
  int left;
  int right;
};

int main(){
  int h, i;
  scanf("%d", &h);
  struct node A[h+1];
  for(i=1;i<h+1;i++){
    scanf("%d", &A[i].key);
    A[i].parent=0;
    A[i].left=0;
    A[i].right=0;
  }
  for(i=1;i<h+1;i++){
    if(i>=2) A[i].parent = A[i/2].key;
    if((2*i)<=h) A[i].left = A[(2*i)].key;
    if((2*i+1)<=h) A[i].right = A[(2*i+1)].key;
  }
  for(i=1;i<h+1;i++){
    printf("node %d: key = %d,", i, A[i].key);
    if(A[i].parent!=0) printf(" parent key = %d,", A[i].parent);
    if(A[i].left!=0)   printf(" left key = %d,",   A[i].left);
    if(A[i].right!=0)  printf(" right key = %d,",  A[i].right);
    printf(" \n");
  }
  return 0;
}


Measured memory_bytes: 2112
#include <iostream>

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

    int n, k, x, y;
    std::cin >> n >> k >> x >> y;
    if (n > k) {
        std::cout << (k * x + (n - k) * y) << '\n';
    } else {
        std::cout << (n * x) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ 
  int p,l,r;
};

struct Node T[MAX]; 

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

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

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

main(){
  int n,i,id,c1,c2;

  scanf("%d",&n);

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

    T[c1].p=id;
    T[c2].p=id;
    T[id].l=c1;
    T[id].r=c2;
  }
  
  for(i=0;i<n;i++){
    if(T[i].p==NIL)break;
  }
  printf("Preorder\n");
  Preorder(i);
  printf("\n");
  
  printf("Inorder\n");
  Inorder(i);
  printf("\n");
  
  printf("Postorder\n");
  Postorder(i);
  printf("\n");

  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    string S;
    cin >> S;

    ll N = S.size();
    vector<ll> ans(N, 1);
    rep (i, N) {
        if (S[i] == 'R' && S[i+1] == 'R') {
            ans[i+2] += ans[i];
            ans[i] = 0;
        }
    }

    reverse(S.begin(), S.end());
    reverse(ans.begin(), ans.end());

    rep (i, N) {
        if (S[i] == 'L' && S[i+1] == 'L') {
            ans[i+2] += ans[i];
            ans[i] = 0;
        }
    }
    
    reverse(S.begin(), S.end());
    reverse(ans.begin(), ans.end());

    rep (i, N) {
        if (i == S.size()-1) {
            cout << ans[i] << endl;
            break;
        }
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 1488
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <sstream>

/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1367
 * test of c++
 */


template <typename T>
std::vector<T> read_input(int &arr_size) {
    std::string input_str;

    std::getline(std::cin, input_str);
    std::istringstream iss(input_str);
    int size, request_size;
    iss >> size >> request_size;
    arr_size = size;

    // this is for myself
    std::vector<T> input_vec(request_size);

    for (int i = 0; i < request_size; i++) {
        std::getline(std::cin, input_str);
        input_vec.at(i) = std::stoi(input_str);
    }
    return input_vec;
}


int main(int argc, char const *argv[]) {
    int arr_size;
    std::vector<int> requests = read_input<int>(arr_size);
    std::vector<int> arr(arr_size);
    std::vector<bool> moved(arr_size, false);
    for (int i = 0; i < arr_size; i++) {
        arr.at(i) = i + 1;
    }

    // moved objects
    std::list<int> header;
    for (auto iter = requests.rbegin(); iter != requests.rend(); ++iter) {
        int value = *iter;
        // std::cout << "requested value: " << value << std::endl;
        if (!moved.at(value - 1)) {
            moved.at(value - 1) = true;
            header.push_back(value);
        }
    }

    // not moved objects
    std::list<int> footer;
    for (int i = 0; i < arr_size; i++) {
        if (!moved.at(i)) {
            // std::cout << "not moved value: " << arr.at(i) << std::endl;
            footer.push_back(arr.at(i));
        }
    }
    header.insert(header.end(), footer.begin(), footer.end());
    for (auto value: header) {
        std::cout << value << std::endl;
    }
    return 0;
}



Measured memory_bytes: 16620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int preA = 0;
		int countA = 0;
		int n = 0;


		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if(preA == a) {
				countA++;
			} else {
				if(countA > 0) {
					n += Math.ceil((double)countA/2);
				}
				countA = 0;
			}
			preA = a;
		}

		if(countA > 0) {
			n += Math.ceil((double)countA/2);
		}

		System.out.println(n);

		return;
	}

}


Measured memory_bytes: 22484
#include<stdio.h>
long long a[10001],b[10001];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0; i<n; ++i)
		scanf("%lld",a+i);
	for(int i=0; i<n; ++i)
		scanf("%lld",b+i);
	long long p=0,q=0;
	for(int i=0; i<n; ++i) {
		if(a[i]>b[i]) p+=a[i]-b[i];
		if(a[i]<b[i]) q+=(b[i]-a[i])>>1;
	}
	puts(p<=q?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    string input;

    cin >> input;
    input = " " + input;
    int ans = 0;
    for (int i = 1; i <= input.length() / 2; i++)
    {
        int j = input.length() - i;
        
        if (input[i] != input[j])
        {
            ans += 1; 
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define INF 214000000
#define MOD 998244353
#define MaxN 1005

using namespace std;

/*#ifdef INFOARENA
FILE* IN=fopen("bacterii2.in","r"), *OUT=fopen("bacterii2.out","w");
#else
FILE* IN=fopen("test.in","r"), *OUT=fopen("test.out","w");
#endif*/

int N,M,Mat[MaxN][MaxN];

int main()
{
    M=1;
    cin>>N;
    while(M*(M-1)/2<N)
        M++;
    if(M*(M-1)/2!=N)
    {
        cout<<"No\n";
    }
    else
    {
        cout<<"Yes\n"<<M<<'\n';
        for(int i=1;i<=M;i++)
        {
            Mat[i][0]=M-1;
        }
        for(int i=2;i<=M;i++)
        {
            int x=i*(i-1)/2;
            for(int j=i-1;j>0;j--)
            {
                Mat[i][j]=x;
                x--;
            }
            Mat[i-1][i-1]=Mat[i][i-1];
            for(int j=i-2;j>0;j--)
                Mat[j][i-1]=Mat[j+1][i-1]-1;
        }
        for(int i=1;i<=M;i++)
        {
            for(int j=0;j<M;j++)
                cout<<Mat[i][j]<<' ';
            cout<<'\n';
        }
    }
    return 0;
}


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

long long m,n,y,x;


int main()
{
	scanf("%lld%lld",&x,&y);
	
	if(y==0)printf("%lld",x);

	else 
	{
		x%=y;
		printf("%lld",min(y-x,x));
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

int main(void){
    int k;
    cin >> k;
    int ans = 0;
    FOR(a,1,k) FOR(b,1,k) FOR(c,1,k){
        ans += gcd(a, gcd(b, c));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char s[100010];

int main()
{
	int c[3]={0,0,0};
	scanf("%s", s);
	for(int i=0; s[i]; ++i) c[s[i]-'a']++;
	sort(c, c+3);
	if(c[2]-c[0] <= 1) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N,M;
int adj[10][10];

signed main(void) {
    vi path;
    cin>>N>>M;
    REP(i,1,N){
        path.pb(i);
        REP(j,1,N) {
            adj[i][j]=0;
        }
    }
    rep(i, M) {
        int a, b;
        cin>>a>>b;
        adj[a][b]=1;
        adj[b][a]=1;
    }
    int cnt=0;
    do {
        if(path[0]!=1) continue;
        bool flag=true;
        rep(i, path.size()-1) {
            if(adj[path[i]][path[i+1]]==0) {
                flag = false;
            }
        }
        if (flag) cnt++;
    } while(next_permutation(all(path)));
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using ll=long long;

template<typename T>
constexpr T modpow(T a,T n,T mod){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

int main() {
    ll n,p;
    std::cin>>n>>p;
    std::string s;
    std::cin>>s;
    ll ans=0;
    if(p==2) {
        for(int i = 0;i < n; ++i) {
            if((int)(s[i]-'0')%2==0)ans+=i+1;
        }
    }
    else if(p==5) {
        for(int i = 0;i < n; ++i) {
            if((int)(s[i]-'0')%5==0)ans+=i+1;
        }
    }
    else {
        std::vector<ll> res(p,0);
        res[0]=1;
        ll t=(s[n-1]-'0')%p;
        ans+=res[t];
        ++res[t];
        for(int i = n-2;i >= 0; --i) {
            t+=(int)(s[i]-'0')*modpow(10LL,n-i-1,p);
            t%=p;
            ans+=res[t];
            ++res[t];
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}


Measured memory_bytes: 640
/*	
TELL YOUR CODE TO START BELIEVING IN GOD!!
THEY HATE US BECAUSE THEY AIN'T US
	ARIJIT SUR 
	@duke_knight
	@surcode
	IIT ISM 
 WORK SO HARD THAT YOUR IDOL BECOMES YOUR COMPETITOR 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define pb push_back
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i=0;i<n;i++) cin>>a[i];}
#define display(a) {for(int i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
void solve(){
	ll n;
    cin>>n;
    vector<ll> a(n);
    input(a);

    ll m = a[0], h=0;
    for(int i=0;i<n;i++){
        m = max(m,a[i]);
        h += max(m-a[i],0);
    }
    printf("%lld\n", h);
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 4740
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


h,w=gi
mp = []
rep h do
  mp << gc
end
dx = [0,1,0,-1]
dy = [1,0,-1,0]
flag = true
rep h do |i|
  rep w do |j|
    next if mp[i][j] == '.'
    tf = false
    rep 4 do |t|
      tx = i+dx[t]
      ty = j+dy[t]
      tf = true if tx >= 0 && tx < h && ty >= 0 && ty < w && mp[tx][ty] == '#'
    end
    flag = flag && tf
  end
end

puts flag ? "Yes" : "No"


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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(abs(A-B)<abs(A-C)){
        cout<<"A"<<endl;
    }else{
        cout<<"B"<<endl;
    }

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream> 
#include <cstring> 
using namespace std ; 
int main () {

int x = 0 , y = 0 ; 
char S[200001] , T[200001] ; 
cin >> S ; 
cin >> T ; 
for (int i = 0 ; i<= strlen(S) ; i++){
if (S[i] == T[i]) y++ ; 
else x++ ; } 
if (0==x && 0 == y ) cout << y ; 
else cout<< x ; 
return 0 ; 
}

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

typedef long long ll;

int main() {
    int M, K;
    cin >> M >> K;
    if (K == 0) {
        rep(i, 1 << M) {
            cout << i << " " << i << " ";
        }
        cout << endl;
    } else if (K >= 1 << M) {
        cout << "-1" << endl;
    } else if (K == 1 && M == 1) {
        cout << "-1" << endl;
    } else {
        cout << K << " ";
        rep(i, 1 << M) {
            if (i == K) continue;
            cout << i << " ";
        }
        cout << K << " ";
        rep(i, 1 << M) {
            if ((1 << M) - i - 1 == K) continue;
            cout << (1 << M) - i - 1 << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void){
	
	int a;

	std::cin >> a;

	if (a >= 1000) {
		std::cout << "ABD" << std::endl;
	}
	else {
		std::cout << "ABC" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  int N,C[500],S[500],F[500];
  int main()
  {
      scanf("%d",&N);
      for(int i=0; i<N-1; i++)
          scanf("%d%d%d",&C[i],&S[i],&F[i]);
      for(int i=0; i<N; i++)
     {
         int t=0;
         for(int j=i; j<N-1; j++)
         {
             
             if(t<S[j])t=S[j];
             else if(t%F[j]==0);
             else t=t+F[j]-t%F[j];
             t+=C[j];
         }
         printf("%d\n",t);
     }
 } 


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

int main(){
  int N;
  int x = 0;
  cin >> N;
  int B[N - 1];
  for(int i = 0; i < N - 1; i++)cin >> B[i];
  int A[N];
  for(int i = 0; i < N - 1; i++){
    if(i == 0)A[i] = B[i], A[i + 1] = B[i];
    if(i != 0 && A[i] > B[i])A[i] = B[i], A[i + 1] = B[i];
    else A[i + 1] = B[i];
  }
  for(int i = 0; i < N; i++) x+= A[i];
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;
#define N (int)1e6+1

int main()
{
	ios
	int h,w;
	cin>>h>>w;
	char c[h+1][w+1];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>c[i][j];
	ll dp[h+1][w+1];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(c[i][j]=='#')dp[i][j]=0;
			else if(i==1 && j==1)dp[i][j]=1;
			else
			{
				dp[i][j]=0;
				if(i>1)dp[i][j]+=dp[i-1][j];
				if(j>1)dp[i][j]+=dp[i][j-1];
				dp[i][j]%=MOD;
			}
		}
	}
	cout<<dp[h][w]<<nl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main(){
	int n, m, x;
	cin >> n >> m >> x;

	VI c(n);
	VVI a(n, VI(m));

	REP(i, n) {
		cin >> c[i];
		REP(j, m)cin >> a[i][j];
	}

	
	int ans = INF;
	REP(i, (1 << n)) {
		VI b(m, 0);

		int cur = 0;
		REP(j, n) {
			if (i&(1 << j)) {
				REP(k, m) {
					b[k] += a[j][k];
				}
				cur += c[j];
			}
		}
		bool flag = true;
		REP(j, m)if (b[j] < x) {
			flag = false;
		}
		if (flag)ans = min(ans, cur);
	}

	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m, x;
  cin >> n >> m >> x;
  vl c(n);
  vector<vl> a(n, vl(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  ll ans = 1e18;
  rep(i, 1 << n) {
    vl b(m, 0);
    ll now = 0;
    rep(j, n) {
      if(i >> j & 1) {
        rep(k, m) b[k] += a[j][k];
        now += c[j];
      }
    }
    bool ok = true;
    rep(j, m) if(b[j] < x) ok = false;
    if(ok) ans = min(ans, now);
  }
  if(ans == 1e18) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int count = 0;

    	while(true){
    		count++;
    		int x = scan.nextInt();

    		if(x == 0){
    			break;
    		}

    		System.out.println("Case " + count + ": " + x);
    	}
    }
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int a; cin >> a;
        while(a%2 == 0){
            cnt++;
            a/=2;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 100005;
const int mod = 1e9+7;
int f[4005][2005][2],s[2005];
int n,m,K,ans; 
int main(){
	n = rd(),m = rd(),K = rd();
	m-=1,K-=1;
	f[0][0][0] = 1;//0表示这一位选0,1表示这一位选择不选择0
	//显然长度不会超过2*max(n,m)位
	for(int i=1;i<=max(n,m) << 1;++i){
		Rep(j,0,n) s[j+1]=((s[j] + f[i-1][j][0]) %mod + f[i-1][j][1]) % mod;
		Rep(j,0,n){
			f[i][j][0] = (f[i-1][j][0]+f[i-1][j][1])%mod;//(s[j+1]-s[j]+mod)%mod;
			int k = max(0,j-K+1-1);
			f[i][j][1] = (s[j]-s[k]+mod)%mod;
		}
		Rep(j,0,n){
			if(j%K==n%K && (i*K-j)%K==m%K && i*K-j<=m)
				ans = (ans + f[i][j][1]) %mod;
		}
	}writeln(ans);
	return 0;
}

Measured memory_bytes: 62976
#include <iostream>

int main() {
	int a, b;

	std::cin >> a >> b;

	if (a >= -1000 && b <= 1000) {
		if (a > b)
			std::cout << "a > b" << std::endl;
		else if (a < b)
			std::cout << "a < b" << std::endl;
		else if (a == b)
			std::cout << "a == b" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
  //宣言
  int N;
  set<string> keihin;
  //入力
  cin >> N;
  //(N回)かぶったら入れない、かぶらなかったら入れる
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    keihin.insert(s);
  }
  //行列のサイズをcout
  cout << keihin.size() << endl;
}

Measured memory_bytes: 19112
#include <stdio.h>

char is_sosuu[10001];

void get_sosuu(char* out,int max) {
	int i,j;
	for(i=0;i<=max;i++)out[i]=1;
	if(max<=0)out[0]=0;
	if(max<=1)out[1]=0;
	for(i=2;i<=max;i++) {
		if(!out[i])continue;
		for(j=i+i;j<=max;j+=i)out[j]=0;
	}
}

int main(void) {
	int now_input;
	int i;
	get_sosuu(is_sosuu,10000);
	while(1) {
		scanf("%d",&now_input);
		if(now_input==0)return 0;
		for(i=now_input;i>=2;i--) {
			if(is_sosuu[i] && is_sosuu[i-2])break;
		}
		printf("%d %d\n",i-2,i);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Long> factors = new ArrayList<>();
        factors.add((long)1);
        for (long i = 2; i <= 130; i++) {
            if (x % Math.abs(i) == 0) factors.add(i);
        }
        long a = -1; long b = -1;
        for (Long dif: factors) {
            for (long lo = -130; lo + dif < 131; lo++) {
                if (Math.pow(lo + dif, 5) - Math.pow(lo, 5) == x) {
                    a = lo + dif; b = lo;
                }
            }

        }
        System.out.println(a + " " + b);
    }


}

Measured memory_bytes: 38848
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 10005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a-1) * (b-1) << endl;
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int K, A, B;
signed main() {
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) { if (i % K == 0) { fin("OK"); }}
    cout << "NG" << endl;
}


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

int main()
{
    int n, d;
    cin >> n >> d;

    if (n <= 2 * d + 1)
        cout << 1 << endl;

    if (n > 2 * d + 1)
    {
        if (n % (2 * d + 1) != 0)
        {
            cout << n / (2 * d + 1) + 1 << endl;
        }
        else
            cout << n / (2 * d + 1) << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
ll n, m;
vector<ll> ve[100005];
ll ans = 1;
bool v[100005];

void dfs(ll p, ll q)
{
    if(m <= q)
    {
        cout<<0<<endl;
        exit(0);
    }
    ans *= (m - q);
    ans %= M;
    ll j = 0;
    for(ll i = 0; i < ve[p].size(); i++)
    {
        if(v[ve[p][i]]) {j = 1; continue;}
        v[ve[p][i]] = true;
        dfs(ve[p][i], i - j + 1 + (p != 1));
    }
}

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < n - 1; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2);
        ve[t2].push_back(t1);
    }
    v[1] = true;
    dfs(1, 0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9344
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var n = double.Parse(Console.ReadLine());
        double a = n % 2 == 0 ? n / 2 / n : ((n - 1) / 2 + 1) / n;


        Console.Write(a);
    }
}

Measured memory_bytes: 11092
/*
                  ,     \    /      ,
                 / \    )\__/(     / \
                /   \  (_\  /_)   /   \
           ____/_____\__\@  @/___/_____\____
          |             |\../|              |
          |              \VV/               |
          |        ------___-------         |
          |__________Chuta Dragon___________|
           |    /\ /      \\       \ /\    |
           |  /   V        ))       V   \  |
           |/     `       //        '     \|
           `              V                '
        */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

#define eb emplace_back

int main()
{


    fastread();


    string s;

    cin>>s;


    if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[3])cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;






}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int x;
int y;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
     cin>>x>>y;
     for(int i=0; i<=x; i++){
         int cnt=i*2+(x-i)*4;
         if(cnt==y){
             cout<<"Yes"<<endl;
             return 0;
         }
     }
     cout<<"No"<<endl;          
    return 0;
}

Measured memory_bytes: 3660