akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n = int(input())
A = list(map(int, input().split()))
if n % 2 == 0:
    dp = [[-float("inf")] * 2 for i in range(n)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    for i in range(2, n):
        dp[i][0] = dp[i - 2][0] + A[i]
        dp[i][1] = max(dp[i - 2][1], dp[i - 3][0] if i >= 3 else float("-inf")) + A[i]

    # print(dp)
    print(max(dp[-1][1], dp[-2][0]))
else:
    dp = [[-float("inf")]*3 for i in range(n)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    for i in range(2, n):
        dp[i][0] = dp[i-2][0] + A[i]
        dp[i][1] = max(dp[i-2][1], dp[i-3][0] if i>=3 else float("-inf")) + A[i]
        dp[i][2] = max(dp[i-2][2], dp[i-3][1] if i>=3 else float("-inf"), dp[i-4][0] if i>=4 else float("-inf")) + A[i]
        if i == 2:
            dp[i][2] = A[2]

    # print(dp)
    print(max(dp[-1][2], dp[-2][1], dp[-3][0]))



Measured memory_bytes: 130692
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

struct City {
    int pref, year, id;
    std::string recognizer;
};

bool compare_year(const City &a, const City &b) {
    return a.year < b.year;
}

bool compare_id(const City &a, const City &b) {
    return a.id < b.id;
}

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    City *city = new City[m];
    for (int i = 0; i < m; i++) {
        int m1, m2;
        cin >> m1 >> m2;
        city[i].pref = m1;
        city[i].year = m2;
        city[i].id   = i;
    }

    std::vector<City> id_sorter;

    std::vector<City> sorter[100010];
    for (int i = 0; i < m; i++) {
        sorter[city[i].pref].push_back(city[i]);
    }
    for (int i = 1; i <= n; i++) {
        std::sort(sorter[i].begin(), sorter[i].end(), compare_year);
    }
    for (int64_t i = 1; i <= n; i++) {
        for (int j = 0; j < sorter[i].size(); j++) {
            //cout << "i j=" << i << " " << j << endl;
            int64_t temp = 0;
            temp += j + 1;
            //cout << temp << endl;
            temp += i * 1000000L;
            //cout << "temp:" << temp << endl;
            City target_city       = sorter[i][j];
            target_city.recognizer = std::to_string(temp);
            //cout << "recognizer_unnormalized:" << target_city.recognizer
            //     << endl;
            while (target_city.recognizer.size() < 12) {
                target_city.recognizer = "0" + target_city.recognizer;
            }
            //cout << "recognizer_normalized:" << target_city.recognizer << endl;
            id_sorter.push_back(target_city);
        }
    }

    std::sort(id_sorter.begin(), id_sorter.end(), compare_id);
    for (auto x : id_sorter) {
        cout << x.recognizer << endl;
    }

    delete[] city;

    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)

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

    vector<int> a(n+1);
    a[0] = 0;
    int ans = 0;

    rep1(i,n) cin >> a[i];

    rep1(i,n){
        if(a[a[i]] == i) ans++;
    }

    cout << ans/2 << endl;
}

Measured memory_bytes: 640
from collections import deque

N, M = map(int, input().split())

X = [0 for _ in range(N+1)]
edges = [[] for _ in range(N+1)]

contradiction = False

for i in range(M):
    l, r, d = map(int, input().split())
    edges[l].append((r, d))
    edges[r].append((l, -d))

searched = set()
q = deque()

# assign x coordinate for each vertex
for i in range(N+1):
    if i in searched:
        continue
    q.append(i)
    searched.add(i)
    X[i] = 0
    while len(q) != 0:
        a = q.pop()
        for b, d in edges[a]:
            if b not in searched:
                q.append(b)
                searched.add(b)
                X[b] = X[a] + d
            else:
                if X[b] != X[a] + d:
                    contradiction = True
                    print("No")
                    break
        if contradiction:
            break
    if contradiction:
        break    
else:
    print("Yes")

Measured memory_bytes: 72452
s = input()
s2 = s[::-1]
n = len(s)
sa=s[:(n-1)//2]
sa2 = sa[::-1]
sb=s[(n+1)//2:]
sb2 = sb[::-1]
if s==s2 and sa == sa2 and sb==sb2:
    print("Yes")
else:
    print("No")

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> vec(0);
    for(int i=1; i<=A; i++) {
        if(A % i == 0 && B % i == 0) {
            vec.push_back(i);
        }
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    cout << vec[K-1] << endl;
}



Measured memory_bytes: 3620
H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
for i in range(2 ** H):
    H_target = [0]*H
    for k in range(H):
        if 1 & i>>k:
            H_target[k] = 1
    for j in range(2 ** W):
        W_target = [0]*W
        for k in range(W):
            if 1 & j>>k:
                W_target[k] = 1
        tmp = 0
        for h in range(H):
            for w in range(W):
                if grid[h][w] == '#':
                    if H_target[h] == 0 and W_target[w] == 0:
                        tmp += 1
        if tmp == K:
            ans += 1
print(ans)

Measured memory_bytes: 74196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  map<int, int> A{};
  int over = 0;
  REP(i, N) {
    int a;
    cin >> a;
    if (3200 <= a) {
      over++;
      continue;
    }
    a /= 400;
    A[a]++;
  }
  int ans = 0;
  REP(i, 8) {
    if (0 < A[i]) ans++;
  }
  if (ans == 0) {
    ans++, over = max(0, over - 1);
  }
  cout << ans << " " << ans + over << endl;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n, k;
  cin >> n >> k;

  vi h(n);
  rep(i, 0, n) cin >> h[i];

  vi dp(n, inf);
  dp[0] = 0;
  rep(i, 0, n){
    rep(j, 1, k+1){
      if(i+j < n) chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

ll g(ll n) {
    if(n%4 == 0) {
        return n;
    }
    else if(n%4 == 1) {
        return 1LL;
    }
    else if(n%4 == 2) {
        return n+1;
    }
    else if(n%4 == 3) {
        return 0;
    }
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans;
    if(a == 0) {
        ans = g(b);
    }
    else {
        ans = g(a-1)^g(b);
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2 * (10 ** 5 ))

input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
mod = 10 ** 9 + 7
a = [0] * M
memo = [-1] * (N + 1)

for i in range(M):
	a[i] = int(input())

def step(n):
	if memo[n] >= 0:
		return memo[n]
	elif n < 2:
		memo[n] = 1
		return 1
	else:
		memo[n] = (step(n - 1) + step(n - 2)) % mod
		return memo[n]
			
for i in a:
	memo[i] = 0
	
print(step(N))

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define ll long long
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define N 500010

int main() {
	int n;
	char aa[N];
	string a;
	vector<int>sa;
	vector<int>lcp;
	ll ans = 0;
	rep(i, N)aa[i] = 0;
	cin >> aa;
	n = strlen(aa);
	rep(i, n)a += aa[i];
	sa = suffix_array(a);
	lcp = lcp_array(a, sa);
	ans = n;
	ans = (ans * (ans + 1)) / 2;
	rep(i, n - 1)ans -= lcp[i];
	cout << ans << endl;
}


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

int H, W, N;
int A[1001][1001];
int dp[1001][1001];

int main() {
  while (cin >> H >> W >> N) {
    if (H == 0 && W == 0 && N == 0) break;
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        cin >> A[j][i];
      }
    }
    for (int x=0; x<=W; x++) {
      for (int y=0; y<=H; y++) {
        dp[x][y] = 0;
      }
    }
    dp[0][0] = N-1;
    for (int x=0; x<W; x++) {
      for (int y=0; y<H; y++) {
        if (dp[x][y] % 2 == 0) {
          dp[x+1][y] += dp[x][y] / 2;
          dp[x][y+1] += dp[x][y] / 2;
          continue;
        }
        if (A[x][y] == 1) {
          dp[x+1][y] += (dp[x][y]+1) / 2;
          dp[x][y+1] += (dp[x][y]-1) / 2;
        }
        else {
          dp[x+1][y] += (dp[x][y]-1) / 2;
          dp[x][y+1] += (dp[x][y]+1) / 2;
        }
      }
    }

    int x = 0, y = 0;
    while (x != W && y != H) {
      int t = (dp[x][y] % 2) ^ A[x][y];
      if (t == 1) x += 1;
      else        y += 1;
    }
    cout << y+1 << " " << x+1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 10804
#include<bits/stdc++.h>
#define int long long int
#define hell (int)(1e9+7)
#define inf 1000000000000

using namespace std;

int modi[500005];
int fact[500005];

int power(int x,int n){
    if(n==0)
        return 1;
    if(n%2==0)
        return power((x*x)%hell,n/2)%hell;
    else
        return (x*power((x*x)%hell,n/2))%hell;
}

void preprocess(){
    modi[0]=fact[0]=1;
    for(int i=1;i<500005;i++){
        fact[i]=(fact[i-1]*i)%hell;
        modi[i]=(modi[i-1]*power(i,hell-2))%hell;
    }
}

int ncr(int n,int r){
    int ans=fact[n];
    ans=(ans*modi[r])%hell;
    ans=(ans*modi[n-r])%hell;
    return ans;
}

void solve(){
    preprocess();
    int n,k,ans;
    cin>>n>>k;
    ans=ncr(n+n-1,n-1);
    if(k>=n-1)
        cout<<ans;
    else{
        ans=0;
        for(int i=0;i<=min(n-1,k);i++){
            ans=(ans+(ncr(n-1,(n-i)-1)*ncr(n,i))%hell)%hell;
        }
        cout<<ans;
    }
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 8064
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m,s,f[1000005],w[105],v[105];
int main(){
	in(n);in(m);
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    for(int i=1;i<=n;i++)in(w[i]),in(v[i]),s+=v[i];
    for(int i=1;i<=n;i++){
        for(int j=s;j>=v[i];j--){
            if(f[j-v[i]]+w[i]<=m)f[j]=min(f[j],f[j-v[i]]+w[i]);
        }
    }
    for(int i=1000000;i>=0;i--){
        if(f[i]!=0x3f3f3f3f){
            printf("%d\n",i);
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 4224
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[] a = new String[n];
		String[] b = new String[m];
		for(int i = 0; i < n; i++){
		    a[i] = sc.next();
		}
		for(int i = 0; i < m; i++){
		    b[i] = sc.next();
		}
		
		// 計算
		String result = "No";
		for(int i = 0; i < n-m+1; i++){
		    for(int j = 0; j < n-m+1; j++){
		        boolean flg = true;
		        for(int k = 0; k < m; k++){
		            for(int l = 0; l < m; l++){
		                if(a[i+k].charAt(j+l) != b[k].charAt(l)){
		                    flg = false;
		                    break;
		                }
		            }
		            if(!flg) break;
		        }
		        if(flg) result = "Yes";
		    }
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 25480
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

namespace My
{
template <typename ArrayT>
static void DumpArray(const ArrayT &arr)
{
#if defined(HOME)
	for (auto it = std::begin(arr); it != std::end(arr); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
#endif
}
template <typename T>
static void DumpGrid(const vector<vector<T>> &grid)
{
#if defined(HOME)
	REP (i, grid.size()) {
		REP (j, grid[i].size()) {
			cerr << grid[i][j] << " ";
		}
		cerr << endl;
	}
#endif
}
template <class ArrayT, typename T>
static void InitArray(ArrayT &arr, T initValue)
{
	for (auto &v : arr) {
		v = initValue;
	}
}
template <typename T>
static bool ReplaceIfSmaller(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
static bool ReplaceIfBigger(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

class Solver
{
  public:
	Solver() {}

	void Solve(istream &cin, ostream &cout) {
		int X;
		cin >> X;

		// a5 = X + b5

		// あらかじめ -200 ~ 200 の5乗数を作っておく
		std::map<int, ll> dic;
		for (int i = -200; i <= 200; i++){
			dic.emplace(i, pow(i, 5));
		}
		// cout << dic.size() << endl;
		// for (auto &&kv : dic) {
		// 	cout << kv.first << " " << kv.second << endl;
		// }
		for (auto&& kv : dic) {
			auto targetValue = kv.second + X;

			for (auto&& tv : dic) {
				if (tv.second == targetValue){
					cout << tv.first << " " << kv.first << endl;
					return;
				}
			}
		}
	}
};
} // namespace My

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 4116
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

const int maxm=200;

int n,m,u,v;
double p;
int begin[14],end[maxm],next[maxm],k;
double dp[1<<14],x;
int maxn;
bool vis[1<<14];
bool dis[14][14];

double dfs(int s)
{
    if(vis[s])return dp[s];
    vis[s]=1;
    dp[s]=0;
    for(int i=(s-1)&s;i;i=(i-1)&s)
    {
        if((i&(-i))!=(s&(-s)))continue;
        double x=1;
        for(u=0;u<n;u++)
            if(i&(1<<u))
            {
                for(v=0;v<n;v++)
                {
                    if(!dis[u][v])continue;
                    if((1<<v)&(s^i))
                    {
                        x=x*p;
                    }
                }
            }
        dp[s]+=dfs(i)*x;
        //printf("%d,%d:%.10f %.10f\n",s,i,x,dp[s]);
    }
    //printf("%d:%.10f\n",s,dp[s]);
    dp[s]=1-dp[s];
    return dp[s];
}

void insert(const int &u,const int &v)
{
    end[k]=v;
    next[k]=begin[u];
    begin[u]=k++;
}

int main()
{
    while(scanf("%d%d%lf",&n,&m,&p)==3)
    {
        memset(begin,-1,sizeof(begin));
        p=p/100.0;
        maxn=(1<<n);
        for(int i=0;i<maxn;i++)
            dp[i]=0.0;
        k=0;
        memset(dis,0,sizeof(dis));
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&u,&v);
            u--;
            v--;
            dis[u][v]=dis[v][u]=1;
            insert(u,v);
            insert(v,u);
        }
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++)
            dp[1<<i]=1.0,vis[1<<i]=1;
        printf("%.10f\n",dfs(maxn-1));
    }
    return 0;
}

Measured memory_bytes: 1228
N = int(input())
A = [int(x) for x in input().split()]

first_x2 = 0
flag = 1
for a in A:
    first_x2 += flag * a
    flag = -flag


ret = []
ret.append(str(first_x2))
for a in A:
    first_x2 = (a - (first_x2 // 2)) *2
    ret.append(str(first_x2))

ret.pop()
print(" ".join(ret))


Measured memory_bytes: 17228
N, K = map(int, input().split())

MAX = 6 * 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


def comb_rep(n, k):
    return comb(n + k - 1, n - 1)


if K >= N - 1:
    print(comb_rep(N + 1, N - 1))
else:
    ans = 0
    for i in range(K + 1):
        ans += comb(N, i) * comb_rep(N - i, i) % MOD
        ans %= MOD
    print(ans)


Measured memory_bytes: 84668
import itertools

n = input()
f = []
for _ in range(n):
    f.append(map(int, raw_input().split()))
p = []
for _ in range(n):
    p.append(map(int, raw_input().split()))

best = -100000000000
for i in range(1, 11):
    for x in itertools.combinations(range(0, 10), i):
        sum = 0
        for j in range(n):
            fs = 0
            for k in x:
                if f[j][k] == 1: fs += 1
            sum += p[j][fs]
        if sum > best:
            best = sum
print best


Measured memory_bytes: 2692
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char> > a(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
    }
  }

  vector<int> r(H,1),c(W,1);

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
        r[i]=0;
        c[j]=0;
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if((r[i]==0)&&(c[j]==0)) cout<<a[i][j];
    }
    if(r[i]==0)cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 256
N,C=map(int,input().split())
f=[[0]*int(1e5) for _ in range(C)]

for i in range(N):
	s,t,c=map(int,input().split())
	f[c-1][s-1:t]=[1]*(t-s+1)

print(max(map(sum,zip(*f))))


Measured memory_bytes: 70360
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s == "ani") cout << "square1001" << endl;
    else cout << "e869120" << endl;
    return 0;
}




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

int main(void){
    int i;
    char s[100000];
    scanf("%s", s);
    int n = strlen(s);
    
    int Rlist[100000];
    int Llist[100000];
    
    int Rcounter = 0;
    int Lcounter = 0;
    
    for(i = 0; i < n; i++){
        if (s[i] == 'L'){
            Lcounter++;
            Llist[i] = Lcounter;
        }
        else {
            Lcounter = 0;
        }
        
        if (s[n-1-i] == 'R'){
            Rcounter++;
            Rlist[n-1-i] = Rcounter;
        }
        else {
            Rcounter = 0;
        }
    }
    
    int anslist[100000];
    
    for(i = 0; i < n; i++){
        if (Rlist[i] != 0){
            if (Rlist[i] % 2 == 0){
                anslist[i + Rlist[i]]++;
            }
            else {
                anslist[i+Rlist[i]-1]++;
            }
        }
        
        if (Llist[i] != 0){
            if (Llist[i] % 2 == 0){
                anslist[i-Llist[i]]++;
            }
            else {
                anslist[i-Llist[i]+1]++;
            }
        }
    }
    
    for (i = 0; i < n - 1; i++){
        printf("%d ", anslist[i]);
    }
    printf("%d", anslist[i]);
}

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

int main()
{
  int k, s;
  cin >> k >> s;
  
  int count = 0;
  for (int x = 0; x <= k; x ++)
  {
    for (int y = 0; y <= k; y ++)
    {
      if (s - (x + y) >= 0 && s - (x + y) <= k) count ++;
    }
  }
  
  cout << count;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	X := scanInt()
	Y := scanInt()
	Z := scanInt()
	K := scanInt()
	a := scanInts(X)
	b := scanInts(Y)
	c := scanInts(Z)

	bc := make([]int, Y*Z)
	for i := 0; i < Y; i++ {
		for j := 0; j < Z; j++ {
			bc[i*Z+j] = b[i] + c[j]
		}
	}

	sort.Ints(bc)

	K++
	n := Y * Z
	l, r := 0, 1<<40
	for l+1 < r {
		mid := (l + r) / 2
		cnt := 0
		for i := 0; i < X; i++ {
			cnt += n - sort.Search(n, func(j int) bool {
				return mid <= a[i]+bc[j]
			})
		}

		if cnt >= K {
			l = mid
		} else {
			r = mid
		}
	}

	arr := []int{}

	for i := 0; i < X; i++ {
		for j := 0; j < n; j++ {
			if a[i]+bc[n-1-j] < l {
				break
			}
			arr = append(arr, a[i]+bc[n-1-j])
		}
	}

	sort.Ints(arr)

	// debug(arr)

	for i := 0; i < K-1; i++ {
		fmt.Fprintln(wr, arr[len(arr)-1-i])
	}
}


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

#define ll long long int

int main()
{
    ll n, i, max_height = INT_MIN, stool_height=0;
    cin >> n;
    vector<ll> v(n);
    for(i=0;i<n;i++)
    {
        cin >> v[i];
    }
    
    for(i=0;i<n;i++)
    {
        if(max_height<v[i])
        {
            max_height = v[i];
        }
        else{
            stool_height += (max_height-v[i]);
        }
    }
    
    cout << stool_height << "\n";
    return 0;
}

Measured memory_bytes: 4748
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

vector<vector<int> > indexList(200001);
int a[200001];
int nextStart[200001];
vector<long long int> stepNum(200001, -1);

int main()
{
	long long int n;
	long long int k;
	cin >> n >> k;
	k *= n;
	// cout << k << endl;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		indexList[a[i]].push_back(i);
	}
	if(n == 1){
		if((n * k) % 1 == 0) cout << a[0] << endl;
		return 0;
	}
	for(int i = 0; i < 200001; i++){
		for(int j = 0; j < indexList[i].size(); j++){
			nextStart[indexList[i][j]] = (indexList[i][(j + 1) % indexList[i].size()] + 1);
		}
	}
	int now = 0;
	stepNum[0] = 0;
	bool loopChecked = false;
	while(k > 0){
		long long int stepNumToNextStart = (nextStart[now] - now + n) % n;
		if(stepNumToNextStart == 1) stepNumToNextStart += n;
		int next = nextStart[now];
		// cout << now << " " << next << " " << k << " " << stepNum[now] << " " << stepNumToNextStart << " " << stepNum[next] << endl;
		if(k <= stepNumToNextStart) break;
		if(stepNum[next] >= 0 && !loopChecked){
			int loopStart = next;
			long long int loopStepNum = stepNum[now] + stepNumToNextStart - stepNum[loopStart];
			// cout << "koko " << loopStepNum  << endl;
			k %= loopStepNum;
			now = loopStart;
			loopChecked = true;
		} else {
			stepNum[next] = stepNum[now] + stepNumToNextStart;
			now = next;
			k -= stepNumToNextStart;
		}
	}

	while(k > 0){
		long long int stepNumToNextStart = (nextStart[now] - now + n) % n;
		if(stepNumToNextStart == 1) stepNumToNextStart += n;
		if(stepNumToNextStart <= k){
			k -= stepNumToNextStart;
			now = nextStart[now];
		} else {
			cout << a[now] << " ";
			now++;
			k--;
		}
	}
	cout << endl;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int n, m, w, v;
long long dp[mx], ans;
int main(){
	scanf("%d%d", &n, &m);

	for(int i = 0; i < n; i++){
		scanf("%d%d", &w, &v);
		for(int j = m-w; j >= 0; j--){
			if(!j || dp[j]) dp[j+w] = max(dp[j+w], dp[j] + v);
		}
	}
	for(long long i : dp) ans = max(ans, i);
	printf("%lld", ans);
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int a, b, c; cin >> a >> b >> c;
    if(c - (a - b) < 0) cout << 0 << endl;
    else cout << c - (a - b)  << endl;

    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;

int n,x,a[2000],ans=INF;

signed main() {
    cin >> n >> x;
    rep(i,n) cin >> a[i];
    rep(i,n+1) {
        int tmpans=i*x;
        deque<pair<int,int>> d;
        for(int j=n-i;j<n;++j) {
            while(d.size() && d.back().fi > a[j]) d.pop_back();
            d.push_back(mp(a[j],j-n));
        }
        rep(j,n) {
            while(d.size() && j - d.front().se > i) d.pop_front();
            while(d.size() && d.back().fi > a[j]) d.pop_back();
            d.push_back(mp(a[j], j));
            tmpans += d.front().fi;
        }
        ans = min(ans, tmpans);
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
const int maxn = 1e5 + 100;
int dp[2][3];
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.txt");
#endif
	int N;
	cin >> N;
	int cur = 0, ans =0;
	for (int i = 1; i <= N; i++)
	{
		cur = !cur;
		int a, b, c;
		cin >> a >> b >> c;
		dp[cur][0] = max(dp[!cur][1], dp[!cur][2]) + a;
		ans = max(dp[cur][0], ans);
		dp[cur][1] = max(dp[!cur][0], dp[!cur][2]) + b;
		ans = max(dp[cur][1], ans);
		dp[cur][2] = max(dp[!cur][1], dp[!cur][0]) + c;
		ans = max(dp[cur][2], ans);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    String ans = "No";
    for(int i = 0; i < 200; i++) {
      if((i % 2) == 0) {
        c -= b;
        if(c <= 0) {
          ans = "Yes";
          break;
        }
      } else {
        a -= d;
        if(a <= 0) break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35740
import bisect
a,b,q=map(int,input().split())
s=[]
t=[]
for i in range(a):
    s.append(int(input()))
for j in range(b):
    t.append(int(input()))

def main(s,t,xi):
    sidx=bisect.bisect_left(s,xi)
    if sidx==0:
        shidari=10**11
        smigi=s[sidx]-xi
    elif sidx==len(s):
        shidari=xi-s[sidx-1]
        smigi=10**11
    elif s[sidx]==xi:
        shidari=0
        smigi=0
    else:
        shidari=xi-s[sidx-1]
        smigi=s[sidx]-xi
    tidx=bisect.bisect_left(t,xi)
    if tidx==0:
        thidari=10**11
        tmigi=t[tidx]-xi
    elif tidx==len(t):
        thidari=xi-t[tidx-1]
        tmigi=10**11
    elif t[tidx]==xi:
        thidari=0
        tmigi=0
    else:
        thidari=xi-t[tidx-1]
        tmigi=t[tidx]-xi
    k=min(2*shidari+tmigi,2*tmigi+shidari,2*smigi+thidari,2*thidari+smigi)
    return min(max(thidari,shidari),max(tmigi,smigi),k)
for k in range(q):
    print(main(s,t,int(input())))

Measured memory_bytes: 12168
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll R, C, ans = 0;
    cin >> R >> C;
    if(C == 1 || R == 1) ans = 1;
    else if(C % 2 == 0)
        ans = R * (C / 2);
    else
        ans = ((R / 2) * C) + ((R % 2) * ((C + 1)/2));
    cout << ans << "\n";    
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int a, b; cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}

Measured memory_bytes: 256
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e5 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int dp[N],w[N],v[N];

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 1;i <= n; i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 1;i <= n; i++){
        for(int j = k;j - w[i] >= 0; j--){
            dp[j] = max(dp[j],dp[j - w[i]] + v[i]);
        }
    }

    cout << dp[k];
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
unsigned long f(unsigned long a, unsigned long x){
  if(a==-1) return 0;
  else return a/x+1;
}

int main(){
  unsigned long a, b, x;
  cin >> a >> b >> x;
  unsigned long ans;
  ans = f(b, x) - f(a-1,x);
  cout << ans << endl;
  return 0;
}

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

int main()
{
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  
  sa += 'f'; sb += 'f'; sc += 'f';
  int a = 0, b = 0, c = 0;
  char turn = 'a';
  while(1){
    if(turn == 'a'){
      if(sa[a] == 'f'){
        cout << 'A' << endl;
        return 0;
      }
      turn = sa[a];
      a++;
    }else if(turn == 'b'){
      if(sb[b] == 'f'){
        cout << 'B' << endl;
        return 0;
      }
      turn = sb[b];
      b++;
    }else if(turn == 'c'){
      if(sc[c] == 'f'){
        cout << 'C' << endl;
        return 0;
      }
      turn = sc[c];
      c++;
    }
  }
}

Measured memory_bytes: 3584
n = int(input())
P = list(map(int, input().split()))

Ps = sorted(P)
c = 0
for i in range(n):
  if P[i] == Ps[i]:
    continue
  else:
    c += 1
    if c == 3:
      print("NO")
      exit()
print("YES")
         

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

int main() {
	int i,m,d,ans;
	cin>>m>>d;
	ans=0;
	for(i=22;i<=d;i++) {
		if((i/10>=2)&&(i%10>=2)) {
			if((i/10)*(i%10)<=m) ans++;
		}
	}
	cout<<ans;
}

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

const ll INF = 1ll<<60;
using P = pair<ll, ll>;
struct grid{ll to; ll cost;};
using Graph = vector<vector<grid>>;

int main(int argc, char **argv)
{
	ll n, m, s, t; cin >> n >> m >> s >> t;
	--s, --t;
	vector<ll> U(m), V(m), A(m), B(m);
	for (ll i = 0; i < m; ++i)
	{
		cin >> U[i] >> V[i] >> A[i] >> B[i];
		--U[i], --V[i];
	}

	Graph GO(n), BACK(n);
	for (ll i = 0; i < m; ++i)
	{
		GO[U[i]].push_back(grid{V[i], A[i]});
		GO[V[i]].push_back(grid{U[i], A[i]});
		BACK[U[i]].push_back(grid{V[i], B[i]});
		BACK[V[i]].push_back(grid{U[i], B[i]});
	}

	priority_queue<P, vector<P>, greater<P>> que;

	vector<ll> dist1(n, INF), dist2(n, INF);
	dist1[s] = 0;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		ll now = p.second;
		if (dist1[now] < p.first) continue;

		for (auto &nv : GO[now])
		{
			if (dist1[nv.to] > dist1[now] + nv.cost)
			{
				dist1[nv.to] = dist1[now] + nv.cost;
				que.push(P(dist1[nv.to], nv.to));
			}
		}
	}

	dist2[t] = 0;
	que.push(P(0, t));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		ll now = p.second;
		if (dist2[now] < p.first) continue;

		for (auto &nv : BACK[now])
		{
			if (dist2[nv.to] > dist2[now] + nv.cost)
			{
				dist2[nv.to] = dist2[now] + nv.cost;
				que.push(P(dist2[nv.to], nv.to));
			}
		}
	}

	vector<ll> dist_min(n); dist_min[n-1] = dist1[n-1] + dist2[n-1];
	for (ll i = n-2; i >= 0; --i)
	{
		dist_min[i] = min(dist1[i]+dist2[i], dist_min[i+1]);
	}
	for (ll times = 0; times < n; ++times)
	{
		std::cout << 1000000000000000 - dist_min[times] << std::endl;
	}
}


Measured memory_bytes: 22648
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,K = map(int,input().split())

slis = []
llis = []
if 2*K>=(B-A+1):
    ans = list(range(A,B+1))
else:
    for i in range(K):
        slis.append(A+i)
        if not B-i in slis:
            llis.append(B-i)
    ans = slis + llis[::-1]

print(*ans,sep="\n")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 3060
import io, sys, atexit, os

import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations


def li ():
	return list (map (int, input ().split ()))


def num ():
	return map (int, input ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


mm = 1000000007


def computeXOR ( n ):
	# Modulus operator are expensive
	# on most of the computers. n & 3
	# will be equivalent to n % 4.

	# if n is multiple of 4
	if n % 4 == 0:
		return n

	# If n % 4 gives remainder 1
	if n % 4 == 1:
		return 1

	# If n%4 gives remainder 2
	if n % 4 == 2:
		return n + 1

	# If n%4 gives remainder 3
	return 0

def solve ():
	t = 1
	for it in range (t):
		a,b=num()
		if(a<=1):
			print(computeXOR(b))
		else:
			print(computeXOR(b)^computeXOR(a-1))






if __name__ == "__main__":
	solve ()

Measured memory_bytes: 5456
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n){
    int x;
    cin >> x;
    ans += x-1;
  }
  cout << ans << endl;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N,Np,A,B;
ll i,j, an;
ll ans;


void calc(ll n,ll a,ll b,ll msk){
    if(n==1){
        printf("%lld %lld ", a, b);
        return;
    }
    ll abx = a ^ b;
    ll i = 0;
    ll c = 0, d = 0, flg = 3;
    fornum(i,0,N){
        if(msk&(1<<i)){
            c |= a & (1 << i);
            continue;
        }
        if(abx&(1<<i)){
            if(flg&1){
                c |= a & (1 << i);
                d = (1 << i);
                flg &= 2;
            }else if(flg&2){
                c |= ~a & (1 << i);
                flg &= 1;
            }else{
                c |= a & (1 << i);
            }
        }else{
            if(flg&2){
                c |= ~a & (1 << i);
                flg &= 1;
            }else{
                c |= a & (1 << i);
            }
        }
    }
    calc(n - 1, a, c, msk | d);
    calc(n - 1, c ^ d, b, msk | d);
}

int main(){
    scanf("%lld%lld%lld", &N, &A, &B);
    if(N==1){
        printf("YES\n%lld %lld\n", A, B);
        return 0;
    }
    ll a = __builtin_popcountll(A ^ B);
    if(a%2==0){
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
    calc(N, A, B, 0);


    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,q,i,l,r;string s;cin >> n >> q >> s;
  int a[n] = {};
  for(i=1;i<n;i++){
    if(s[i]=='C' && s[i-1]=='A') a[i] = a[i-1]+1;
    else a[i] = a[i-1];
  }
  while(cin >> l >> r){
    cout << a[r-1]-a[l-1] << endl;
  }
}

Measured memory_bytes: 1408
N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)


Measured memory_bytes: 14068
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

vector<int> sieve(int N)
{
	vector<int> p;
	vector<bool> flgs(N + 1, true);

	flgs[0] = false;
	flgs[1] = false;

	reple(i, 2, N)
	{
		if (flgs[i])
		{
			p.push_back(i);

			for (int j = i; j <= N; j += i) flgs[j] = false;
		}
	}

	return p;
}

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

	for (int i = X;; i++)
	{
		bool flg = true;

		for (int j = 2; j * j <= i; j++)
		{
			if (i % j == 0)
			{
				flg = false;
				break;
			}
		}

		if (flg)
		{
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int x = scan.nextInt();
      for(int i = 6 ; i >=0 ; i--){
          if(Math.pow(2,i)<=x){
            System.out.println((int)Math.pow(2,i));
            break;
          }
      }
    }
}

Measured memory_bytes: 22868
import math
n=int(input())
line=[list(map(int,input().split())) for i in range(n)]
cnt=0
for a,b in line[::-1]:
    A=a+cnt
    if A%b==0:continue
    elif A<=b:cnt +=b-A
    else:cnt +=b*(math.ceil(A/b))-A
print(cnt)

Measured memory_bytes: 28196
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007

int n,k;
int a[100];
int dp[2][100001];


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

	cin >> n >> k;
	rep(i, n)cin >> a[i];

	int *cur = dp[0], *nxt = dp[1];
	cur[0] = 1;

	rep(i,n) {
		memset(nxt, 0, sizeof(dp[0]));
		int s = 0;
		rep(j, k + 1) {
			s += cur[j];
			s %= MOD;
			nxt[j] = s;
			if (a[i] <= j) {
				s = (s - cur[j - a[i]] + MOD) % MOD;
			}
		}
		swap(cur, nxt);
	}
	cout << cur[k] << endl;

	return 0;
}


Measured memory_bytes: 1024
/* ex4_3
   seira3 */

#include <stdio.h>

int answer(int smallNum, int largeNum){ //答えを出力する関数
    int diff = largeNum - smallNum; //二つの引数の差
    int ans = 0; //答えを入れる変数を宣言，0を代入
    for(int i = 1; i < diff; i++){ //1+2+...+diff-1，つまり西側の塔の高さをansに代入
        ans += i;
    }
    ans -= smallNum; //全体から雪に埋もれていないところを引く
    return ans; //答えを返す
}

int main(void){
    int lenA, lenB; //変数宣言
    scanf("%d %d", &lenA, &lenB); //代入
    printf("%d\n",answer(lenA,lenB)); //答えを出力
    return 0;
}

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


int main() {
    int n,a;
    long long m=0,s=0;
    cin >> n ;
    for (int i=0; i<n; i++) {
        cin >> a;
        if (m < a) {
            m = a;
        } else if (i!=0) {
            s += m - a;
        }
    }


    cout << s << endl;
    return 0;
}

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

int main(){
  vector<char> n(2);
  for(int i=0;i<2;i++){
    cin >> n.at(i);
  }
  bool ans=false;
  for(int i=0;i<2;i++){
    if(n.at(i)=='9'){
      ans=true;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

char s[10];
int a[10086];

int main(void)
{
    scanf("%s", s);
    ++a[s[0] - 'A'], ++a[s[1] - 'A'], ++a[s[2] - 'A'], ++a[s[3] - 'A'];
    if (a[s[0] - 'A'] == 2 && a[s[1] - 'A'] == 2 && a[s[2] - 'A'] == 2 && a[s[3] - 'A'] == 2)
        printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
g=[[]for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    g[a].append((b,c))
    g[b].append((a,c))


q,k=map(int,input().split())
k-=1

dist=[float("inf")]*n
dist[k]=0
def dfs(s):
    for v,c in g[s]:
        if dist[v]==float("inf"):
            dist[v]=dist[s]+c
            dfs(v)


dfs(k)

for _ in range(q):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    print(dist[x]+dist[y])


Measured memory_bytes: 184240
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[10][10];

int main(int argc, char* argv[])
{
    int h,w;
    scanf("%d%d", &h, &w);
    int i,j;
    for(i=0; i<h; i++) {
        scanf("%s", &str[i]);
    }
    int cnt=0;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            if(str[i][j]=='#') {
                cnt++;
                if(i==0 && j==0) continue;
                int num=0;
                if(i>0 && str[i-1][j]=='#') num++;
                if(j>0 && str[i][j-1]=='#') num++;
                if(num!=1) {
                    printf("Impossible\n"); return 0;
                }
            }
        }
    }
    if(cnt==h+w-1) printf("Possible\n");
    else printf("Impossible\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin>>N;
long long counter=0;
long long a[N+10]={};
for(long long i=0;i<N;i++){
cin>>a[i];}
for(long long i=0;i<N;i++){
if(a[i]==a[i+1]){
if(a[i+1]==a[i+2]){
counter++;
i++;
continue;}
else{
counter++;
i++;
continue;}}
else{
continue;}}
cout<<counter<<endl;}


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

using namespace std;

vector<int> cijene;
int dp[100002];

int rek(int x) {
    if (dp[x] != -1) return dp[x];

    int rj = min(
        rek(x-1) + abs(cijene[x] - cijene[x-1]), 
        rek(x-2) + abs(cijene[x] - cijene[x-2])
    );

    dp[x] = rj;

    return dp[x];
}

int main() {
    int n, a;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a;
        cijene.push_back(a);
    }

    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(cijene[1] - cijene[0]);

    cout << rek(n-1) << endl;

    // for (int i=0; i<n; i++) {
    //     cout << dp[i] << endl;
    // }

    return 0;
}


Measured memory_bytes: 6428
package main

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

func main() {
	sc = initScanner(os.Stdin)
	str := scanString(sc)
	fmt.Println(solve(str))
}

func solve(str string) string {
	var n, w, e, s bool
	ss := strings.Split(str, "")

	for _, v := range ss {
		if v == "N" {
			n = true
		} else if v == "W" {
			w = true
		}  else if v == "E" {
			e = true
		} else if v == "S" {
			s = true
		}
	}

	if n != s {
		return "No"
	}
	if w != e {
		return "No"
	}

	return "Yes"
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1808